Compare commits

3 Commits
dev ... main

Author SHA1 Message Date
3365d253a0 remove product image zoom 2025-09-20 09:59:20 +05:30
0777de9290 add clear cart functionality 2025-09-18 22:23:03 +05:30
20adf3439c update credentials 2025-09-18 00:32:03 +05:30
6 changed files with 31 additions and 25 deletions

View File

@@ -1,8 +1,8 @@
import Razorpay from "razorpay"; import Razorpay from "razorpay";
const razorpay = new Razorpay({ const razorpay = new Razorpay({
key_id: process.env.NEXT_RAZORPAY_CLIENT_ID, key_id: "rzp_live_REdeGZclfm8KFo",
key_secret: process.env.NEXT_RAZORPAY_SECRET_KEY, key_secret: "BXgwGPsYhxgUYsozCr2uoEZC",
}); });
export async function POST(req) { export async function POST(req) {

View File

@@ -27,7 +27,7 @@ export const ProductContextProvider = ({ children }) => {
fetchCategory(); fetchCategory();
}, []); }, []);
const cartFn = async (variantId, designId, quantity) => { const cartFn = async (variantId, designId, quantity, showToast = true) => {
try{ try{
const response = await authAxios.post('/orders/cart/manage_item/',{ const response = await authAxios.post('/orders/cart/manage_item/',{
@@ -35,7 +35,9 @@ export const ProductContextProvider = ({ children }) => {
design: designId, design: designId,
quantity: quantity quantity: quantity
}) })
toast.success('Modified Cart Successfully!') if (showToast) {
toast.success('Modified Cart Successfully!')
}
return response return response
} }
catch(error){ catch(error){

View File

@@ -83,7 +83,7 @@ const PaymentComponent = ({ amount, onSuccess }) => {
const order = await createOrder(); const order = await createOrder();
const options = { const options = {
key: "rzp_test_Xf4wnkvQQeUnCq", key: "rzp_live_REdeGZclfm8KFo",
amount: order.amount, amount: order.amount,
currency: order.currency, currency: order.currency,
name: "Rudraksha", name: "Rudraksha",

View File

@@ -78,8 +78,8 @@ const ProductGallery = ({ productId }) => {
<div <div
className="relative mb-4 h-full" className="relative mb-4 h-full"
ref={imageContainerRef} ref={imageContainerRef}
onMouseMove={handleMouseMove} // onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave} // onMouseLeave={handleMouseLeave}
> >
<Image <Image
src={`${backendUrl}${productImages[currentImageIndex]}`} src={`${backendUrl}${productImages[currentImageIndex]}`}

View File

@@ -79,9 +79,8 @@ const ShippingPolicy = () => {
</h2> </h2>
<p className="text-lg mt-6"> <p className="text-lg mt-6">
Note: Gupta Rudraksha only uses the expedited shipping options and Note: Gupta Rudraksha only uses the expedited shipping options and
ensures the fastest delivery using any of the above courier services ensures the fastest delivery using any courier services
based on their estimated delivery date. BlueDart is used for based on their estimated delivery date.
deliveries all over India.
</p> </p>
</div> </div>
</div> </div>

View File

@@ -1,3 +1,4 @@
"use client"; "use client";
import React, { useContext, useEffect, useState } from "react"; import React, { useContext, useEffect, useState } from "react";
import { Trash2, Plus } from "lucide-react"; import { Trash2, Plus } from "lucide-react";
@@ -43,12 +44,12 @@ const ShoppingCart = () => {
}, []); }, []);
const handleQuantityChange = async (variantId, designId, quantityChange) => { const handleQuantityChange = async (variantId, designId, quantityChange, showToast = true) => {
const response = await cartFn(variantId, designId, quantityChange); const response = await cartFn(variantId, designId, quantityChange, showToast);
console.log(response) console.log(response)
if (response?.status == 200 || response?.status == 204) { if (response?.status == 200 || response?.status == 204) {
setCartItems((prev) => { setCartItems((prev) => {
if (!prev) return prev;
const updatedItems = prev[0].items.map((item) => { const updatedItems = prev[0].items.map((item) => {
if (item.variant.id === variantId && item?.design?.id === designId) { if (item.variant.id === variantId && item?.design?.id === designId) {
@@ -86,6 +87,15 @@ const ShoppingCart = () => {
} }
}; };
const clearCart = async () => {
if (!cartItems || !cartItems[0]?.items?.length) return;
for (const item of cartItems[0].items) {
await handleQuantityChange(item.variant.id, item.design?.id, -item.quantity, false);
}
toast.success('Cart cleared successfully!');
};
if (!cartItems) { if (!cartItems) {
return null; return null;
} }
@@ -125,7 +135,7 @@ const ShoppingCart = () => {
payerEmail: order.payer.email_address, payerEmail: order.payer.email_address,
orderId: order.id, orderId: order.id,
cartId: cartItems[0].id, cartId: cartItems[0].id,
address: order.address, address: order.address,
}; };
const apiResponse = await authAxios.post("/orders/payment/", paymentData); const apiResponse = await authAxios.post("/orders/payment/", paymentData);
@@ -138,14 +148,6 @@ const ShoppingCart = () => {
} }
}; };
if (!cartItems) {
return null;
}
if (!cartItems[0]?.items?.length) {
return <EmptyCart />;
}
return ( return (
<div className="w-full bg-white"> <div className="w-full bg-white">
<div className="w-full px-4 md:px-8 max-w-[1600px] mx-auto font-['Inter']"> <div className="w-full px-4 md:px-8 max-w-[1600px] mx-auto font-['Inter']">
@@ -232,8 +234,8 @@ const ShoppingCart = () => {
size={18} size={18}
onClick={() => onClick={() =>
handleQuantityChange( handleQuantityChange(
item.variant.id, item?.variant?.id,
item.design.id, item?.design?.id,
-item.quantity -item.quantity
) )
} }
@@ -250,7 +252,10 @@ const ShoppingCart = () => {
<button className="text-[#c19a5b] hover:text-[#ab885b] font-medium order-2 sm:order-1"> <button className="text-[#c19a5b] hover:text-[#ab885b] font-medium order-2 sm:order-1">
<Link href="/"> CONTINUE SHOPPING</Link> <Link href="/"> CONTINUE SHOPPING</Link>
</button> </button>
<button className="text-[#c19a5b] hover:text-[#ab885b] sm:ml-auto font-medium order-1 sm:order-2"> <button
onClick={clearCart}
className="text-[#c19a5b] hover:text-[#ab885b] sm:ml-auto font-medium order-1 sm:order-2"
>
CLEAR SHOPPING CART CLEAR SHOPPING CART
</button> </button>
</div> </div>