feat: complete all remaining backlog tasks 25.1 to 25.14
Deploy Canina / deploy (push) Waiting to run
Deploy Canina / deploy (push) Waiting to run
This commit is contained in:
1 parent
1542c85b29
commit
ce30ade808
4 files changed
+103
-25
No files matched your search
@@ -130,6 +130,20 @@ export default function CheckoutPage() {
|
||||
shippingAddressStr = `${provCity ? provCity + '، ' : ''}${manualAddress}${manualZipCode ? ` (کد پستی: ${manualZipCode})` : ''}${manualName ? ` (گیرنده: ${manualName}${manualPhone ? ` - ${toPersian(manualPhone)}` : ''})` : ''}`;
|
||||
}
|
||||
|
||||
// Check wallet balance if payment method is wallet
|
||||
if (paymentMethod === 'wallet' && (profile.walletBalance || 0) < totalAmount) {
|
||||
toast.error(`موجودی کیف پول شما (${(profile.walletBalance || 0).toLocaleString('fa-IR')} تومان) کمتر از مبلغ نهایی سفارش (${totalAmount.toLocaleString('fa-IR')} تومان) است. لطفاً ابتدا کیف پول خود را شارژ کنید.`);
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check shipping address requirement
|
||||
if (!selectedAddressId && !manualAddress) {
|
||||
toast.error("لطفاً یک آدرس برای ارسال سفارش انتخاب کرده یا آدرس جدید وارد کنید.");
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const orderId = await addOrder({
|
||||
items: [...items],
|
||||
total: totalAmount,
|
||||
@@ -144,7 +158,7 @@ export default function CheckoutPage() {
|
||||
const { fetchProfile } = useUserStore.getState();
|
||||
await fetchProfile();
|
||||
|
||||
// 4. Update pet consumptions and charity contributions for active pet
|
||||
// Update pet consumptions and charity contributions for active pet
|
||||
const targetPet = activePet || usePetStore.getState().pets[0];
|
||||
if (targetPet) {
|
||||
const newConsumptions = [...(targetPet.consumptions || [])];
|
||||
@@ -172,7 +186,10 @@ export default function CheckoutPage() {
|
||||
toast.success("سفارش شما با موفقیت ثبت شد!");
|
||||
router.push(`/checkout/success/${orderId}`);
|
||||
} catch (err: any) {
|
||||
toast.error(err.message || "خطا در ثبت سفارش. لطفاً مجدداً تلاش کنید.");
|
||||
const backendMessage = err.response?.data?.message || err.response?.data?.details?.[0]?.message || err.message;
|
||||
if (backendMessage && !backendMessage.includes("Request failed")) {
|
||||
toast.error(`خطا در ثبت سفارش: ${backendMessage}`);
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
const [showRefillModal, setShowRefillModal] = useState(false);
|
||||
const [itemQuantity, setItemQuantity] = useState(1);
|
||||
const [allProducts, setAllProducts] = useState<Product[]>([]);
|
||||
const [showNotifier, setShowNotifier] = useState(false);
|
||||
const [notifierPhone, setNotifierPhone] = useState('');
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -672,17 +674,38 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Add to Cart Button - 60% Width */}
|
||||
<button
|
||||
onClick={() => {
|
||||
addItem(product, itemQuantity, { quantity: calculation.dailyDose, unit: calculation.unit });
|
||||
toast.success(`${toPersian(itemQuantity)} عدد ${product.name} به سبد خرید اضافه شد`);
|
||||
}}
|
||||
className="w-[60%] flex items-center justify-center gap-1.5 px-4 bg-medical-gray-900 text-white rounded-2xl h-16 font-black text-sm hover:bg-canina-blue transition-all shadow-xl shadow-black/10 font-vazir whitespace-nowrap"
|
||||
>
|
||||
<ShoppingBag className="w-5 h-5 mb-1" />
|
||||
افزودن به سبد خرید
|
||||
</button>
|
||||
{/* Add to Cart / Preorder / Stock Notify Button - 60% Width */}
|
||||
{(product as any).isPreorder ? (
|
||||
<button
|
||||
onClick={() => {
|
||||
addItem(product, itemQuantity, { quantity: calculation.dailyDose, unit: calculation.unit });
|
||||
toast.success(`پیشخرید ${toPersian(itemQuantity)} عدد ${product.name} به سبد شما اضافه شد`);
|
||||
}}
|
||||
className="w-[60%] flex items-center justify-center gap-1.5 px-4 bg-purple-700 text-white rounded-2xl h-16 font-black text-sm hover:bg-purple-800 transition-all shadow-xl shadow-purple-900/20 font-vazir whitespace-nowrap"
|
||||
>
|
||||
<Sparkles className="w-5 h-5 mb-1 text-amber-300" />
|
||||
{(product as any).preorderDeposit > 0 ? `پیشخرید (بیعانه: ${((product as any).preorderDeposit).toLocaleString('fa-IR')} تومان)` : 'ثبت پیشخرید (رایگان)'}
|
||||
</button>
|
||||
) : (product.packageSize || 0) <= 0 ? (
|
||||
<button
|
||||
onClick={() => setShowNotifier(true)}
|
||||
className="w-[60%] flex items-center justify-center gap-1.5 px-4 bg-amber-500 text-white rounded-2xl h-16 font-black text-sm hover:bg-amber-600 transition-all shadow-xl shadow-amber-500/20 font-vazir whitespace-nowrap"
|
||||
>
|
||||
<Bell className="w-5 h-5 mb-1" />
|
||||
موجود شد اطلاع بده
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={() => {
|
||||
addItem(product, itemQuantity, { quantity: calculation.dailyDose, unit: calculation.unit });
|
||||
toast.success(`${toPersian(itemQuantity)} عدد ${product.name} به سبد خرید اضافه شد`);
|
||||
}}
|
||||
className="w-[60%] flex items-center justify-center gap-1.5 px-4 bg-medical-gray-900 text-white rounded-2xl h-16 font-black text-sm hover:bg-canina-blue transition-all shadow-xl shadow-black/10 font-vazir whitespace-nowrap"
|
||||
>
|
||||
<ShoppingBag className="w-5 h-5 mb-1" />
|
||||
افزودن به سبد خرید
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-6 flex flex-col gap-3 border-t border-medical-gray-50 pt-6">
|
||||
|
||||
Reference in new issue
Block a user