fix(all): resolve wallet callback validation, card-to-card conditional rendering, pet management tab, withdrawal settings, smart advisor loop, reports chart and announcement config
Deploy Canina / deploy (push) Successful in 1m47s
Deploy Canina / deploy (push) Successful in 1m47s
This commit is contained in:
1 parent
b807d25632
commit
d9254e9b01
14 files changed
+533
-77
No files matched your search
@@ -18,6 +18,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import SafeImage from "./SafeImage";
|
||||
import { toPersian } from "../lib/utils";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function B2BPortal({ onClose }: { onClose: () => void }) {
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
@@ -123,10 +124,10 @@ export default function B2BPortal({ onClose }: { onClose: () => void }) {
|
||||
try {
|
||||
const api = (await import('../lib/services/api')).default;
|
||||
await api.post('/wholesale/apply', { businessName: bName, licenseNumber: phone });
|
||||
alert('درخواست شما با موفقیت ثبت شد. کارشناسان پشتیبانی B2B کنینا به زودی جهت تایید تلفنی با شما تماس خواهند گرفت.');
|
||||
toast.success('درخواست شما با موفقیت ثبت شد. کارشناسان پشتیبانی B2B کنینا به زودی جهت تایید تلفنی با شما تماس خواهند گرفت.');
|
||||
form.reset();
|
||||
} catch {
|
||||
alert('خطا در ثبت درخواست. لطفاً دوباره تلاش کنید.');
|
||||
toast.error('خطا در ثبت درخواست. لطفاً دوباره تلاش کنید.');
|
||||
}
|
||||
}} className="space-y-2">
|
||||
<input name="bName" required placeholder="نام مجموعه / کلینیک / داروخانه" className="w-full bg-white/20 text-white text-xs px-3 py-2.5 rounded-xl outline-none placeholder:text-white/50" />
|
||||
|
||||
@@ -71,6 +71,11 @@ export default function CheckoutPage() {
|
||||
const roundStep = Number(useSettingsStore((state) => state.getText('CHARITY_ROUND_STEP', '10000'))) || 10000;
|
||||
const shippingFeeSetting = useSettingsStore((state) => state.getText('shipping_fee', '0'));
|
||||
const shippingFee = Number(shippingFeeSetting) || 0;
|
||||
const isCardToCardEnabled = useSettingsStore((state) =>
|
||||
state.getBoolean('PAY_GATEWAY_CARD_ENABLE', true) &&
|
||||
state.getBoolean('cardToCardEnabled', true) &&
|
||||
state.getBoolean('payment_card_to_card_enabled', true)
|
||||
);
|
||||
const subtotal = getSubtotal();
|
||||
const remainder = subtotal % roundStep;
|
||||
const roundUpDiff = remainder === 0 ? roundStep : roundStep - remainder;
|
||||
@@ -410,7 +415,7 @@ export default function CheckoutPage() {
|
||||
label: getText('PAY_GATEWAY_CARD_LABEL', 'کارت به کارت (واریز مستقیم)'),
|
||||
desc: getText('PAY_GATEWAY_CARD_DESC', 'واریز به شماره کارت بانک سامان'),
|
||||
icon: <CreditCard className="w-5 h-5 sm:w-6 sm:h-6" />,
|
||||
enabled: getText('PAY_GATEWAY_CARD_ENABLE', 'true') === 'true'
|
||||
enabled: isCardToCardEnabled
|
||||
},
|
||||
{
|
||||
id: 'wallet',
|
||||
@@ -488,7 +493,7 @@ export default function CheckoutPage() {
|
||||
})()}
|
||||
</div>
|
||||
|
||||
{paymentMethod === 'card' && (
|
||||
{isCardToCardEnabled && paymentMethod === 'card' && (
|
||||
<div className="mt-6 bg-blue-50/80 border border-blue-200 rounded-2xl p-5 space-y-3 font-vazir">
|
||||
<div className="flex items-center gap-2 text-canina-blue font-bold text-sm">
|
||||
<CreditCard className="w-5 h-5" />
|
||||
|
||||
@@ -234,7 +234,7 @@ export default function Header({
|
||||
<HeartPulse className="w-3.5 h-3.5 text-canina-blue" />
|
||||
پتهای من ({pets.length})
|
||||
</span>
|
||||
<Link href="/dashboard" onClick={() => setIsProfileMenuOpen(false)} className="text-canina-blue hover:underline text-[10px]">
|
||||
<Link href="/dashboard?tab=pets" onClick={() => setIsProfileMenuOpen(false)} className="text-canina-blue hover:underline text-[10px]">
|
||||
مدیریت
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -488,14 +488,23 @@ export default function PetProfile({ initialView }: {
|
||||
const fd = new FormData();
|
||||
fd.append('file', file);
|
||||
try {
|
||||
const res = await api.post('/upload', fd, { headers: { 'Content-Type': 'multipart/form-data' } });
|
||||
const res = await api.post('/pets/upload-image', fd, { headers: { 'Content-Type': 'multipart/form-data' } });
|
||||
const url = res.data?.url || res.data?.path || res.data?.data?.url;
|
||||
if (url) {
|
||||
setFormData({ ...formData, imageUrl: url });
|
||||
toast.success("تصویر با موفقیت آپلود شد");
|
||||
}
|
||||
} catch {
|
||||
toast.error("خطا در آپلود تصویر");
|
||||
try {
|
||||
const res = await api.post('/upload', fd, { headers: { 'Content-Type': 'multipart/form-data' } });
|
||||
const url = res.data?.url || res.data?.path || res.data?.data?.url;
|
||||
if (url) {
|
||||
setFormData({ ...formData, imageUrl: url });
|
||||
toast.success("تصویر با موفقیت آپلود شد");
|
||||
}
|
||||
} catch {
|
||||
toast.error("خطا در آپلود تصویر");
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -56,21 +56,27 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
const { addPet, setActivePet } = usePetStore();
|
||||
const getText = useSettingsStore(state => state.getText);
|
||||
|
||||
const [advisorRules, setAdvisorRules] = useState<unknown[]>(rules);
|
||||
const [advisorRules, setAdvisorRules] = useState<unknown[]>(rules || []);
|
||||
|
||||
useEffect(() => {
|
||||
if (rules && rules.length > 0) {
|
||||
Promise.resolve().then(() => setAdvisorRules(rules));
|
||||
} else {
|
||||
api.get('/smart-advisor/rules')
|
||||
.then(res => {
|
||||
if (Array.isArray(res.data)) {
|
||||
setAdvisorRules(res.data);
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("[SmartAdvisor] Failed to fetch rules:", err));
|
||||
setAdvisorRules(rules);
|
||||
return;
|
||||
}
|
||||
}, [rules]);
|
||||
|
||||
let isMounted = true;
|
||||
api.get('/smart-advisor/rules')
|
||||
.then(res => {
|
||||
if (isMounted && Array.isArray(res.data)) {
|
||||
setAdvisorRules(res.data);
|
||||
}
|
||||
})
|
||||
.catch(err => console.error("[SmartAdvisor] Failed to fetch rules:", err));
|
||||
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [rules?.length]);
|
||||
|
||||
const [step, setStep] = useState(1);
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"use client";
|
||||
import React, { useState } from "react";
|
||||
import { motion } from "motion/react";
|
||||
import { User, ShoppingBag, Wallet, MapPin, LogOut, ChevronRight, Package, Calendar, UserCircle, ShoppingCart, Trash2, Edit2, Phone, Hash, CheckCircle2, ArrowUpCircle, ArrowDownCircle, Info, Clock, CheckCircle, Heart, Sparkles, MessageSquare, Send, Stethoscope, FileText, Lock, Key, Eye, EyeOff, ShieldCheck } from "lucide-react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import { User, ShoppingBag, Wallet, MapPin, LogOut, ChevronRight, Package, Calendar, UserCircle, ShoppingCart, Trash2, Edit2, Phone, Hash, CheckCircle2, ArrowUpCircle, ArrowDownCircle, Info, Clock, CheckCircle, Heart, Sparkles, MessageSquare, Send, Stethoscope, FileText, Lock, Key, Eye, EyeOff, ShieldCheck, Dog, X, Plus, CreditCard, Activity } from "lucide-react";
|
||||
import { OrderRowSkeleton } from "./Skeleton";
|
||||
import { useUserStore, Address } from "../lib/store/userStore";
|
||||
import { useCartStore } from "../lib/store/cartStore";
|
||||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||
import { toPersian, toEnglishDigits, cn } from "../lib/utils";
|
||||
import { toast } from "sonner";
|
||||
import OrderDetailsModal from "./OrderDetailsModal";
|
||||
@@ -14,12 +15,14 @@ import TopUpModal from "./TopUpModal";
|
||||
import { ticketService, Ticket, TicketMessage } from "../lib/services/ticketService";
|
||||
import { usePetStore } from "../lib/store/usePetStore";
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
|
||||
export default function UserDashboard() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { profile, isLoggedIn, logout, updateProfile, addAddress, updateAddress, deleteAddress, setDefaultAddress, topUpWallet } = useUserStore();
|
||||
const { pets } = usePetStore();
|
||||
const { pets, activePetId, setActivePet, removePet } = usePetStore();
|
||||
const isWithdrawalEnabled = useSettingsStore((s) => s.getBoolean('wallet_withdrawal_enabled', false));
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!isLoggedIn && typeof window !== "undefined") {
|
||||
@@ -29,7 +32,16 @@ export default function UserDashboard() {
|
||||
}, [isLoggedIn, router]);
|
||||
|
||||
const { orders } = useCartStore();
|
||||
const [activeTab, setActiveTab] = React.useState<"profile" | "orders" | "wallet" | "addresses" | "tickets" | "overview">("profile");
|
||||
const [activeTab, setActiveTab] = React.useState<"profile" | "orders" | "wallet" | "addresses" | "tickets" | "pets" | "overview">("profile");
|
||||
|
||||
// Set tab from URL query param if present
|
||||
useEffect(() => {
|
||||
const tabParam = searchParams.get('tab');
|
||||
if (tabParam && ['profile', 'orders', 'wallet', 'addresses', 'tickets', 'pets'].includes(tabParam)) {
|
||||
setActiveTab(tabParam as "profile" | "orders" | "wallet" | "addresses" | "tickets" | "pets");
|
||||
}
|
||||
}, [searchParams]);
|
||||
|
||||
const [isLoadingOrders, setIsLoadingOrders] = useState(false);
|
||||
|
||||
// Tickets State
|
||||
@@ -138,6 +150,13 @@ export default function UserDashboard() {
|
||||
|
||||
// Wallet State
|
||||
const [isTopUpModalOpen, setIsTopUpModalOpen] = useState(false);
|
||||
const [isWithdrawModalOpen, setIsWithdrawModalOpen] = useState(false);
|
||||
const [withdrawAmount, setWithdrawAmount] = useState("");
|
||||
const [withdrawIban, setWithdrawIban] = useState("");
|
||||
const [isSubmittingWithdrawal, setIsSubmittingWithdrawal] = useState(false);
|
||||
|
||||
// Pet Delete State
|
||||
const [petToDelete, setPetToDelete] = useState<{ id: string; name: string } | null>(null);
|
||||
|
||||
// Profile State
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
@@ -278,8 +297,44 @@ export default function UserDashboard() {
|
||||
setIsAddressModalOpen(true);
|
||||
};
|
||||
|
||||
const handleWithdrawSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const numAmount = parseInt(toEnglishDigits(withdrawAmount));
|
||||
if (!numAmount || numAmount < 50000) {
|
||||
toast.error("حداقل مبلغ قابل برداشت ۵۰,۰۰۰ تومان است.");
|
||||
return;
|
||||
}
|
||||
if (numAmount > (profile.walletBalance || 0)) {
|
||||
toast.error("مبلغ درخواستی از موجودی کیف پول شما بیشتر است.");
|
||||
return;
|
||||
}
|
||||
if (!withdrawIban.trim() || withdrawIban.trim().length < 10) {
|
||||
toast.error("لطفاً شماره شبا یا شماره کارت معتبر وارد نمایید.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setIsSubmittingWithdrawal(true);
|
||||
await ticketService.createTicket({
|
||||
subject: `درخواست تسویه و برداشت وجه (${toPersian(numAmount.toLocaleString())} تومان)`,
|
||||
message: `درخواست برداشت وجه از کیف پول کاربری:\nمبلغ: ${numAmount.toLocaleString('fa-IR')} تومان\nشماره شبا/کارت: ${withdrawIban}\nشماره همراه کاربر: ${profile.mobile || ''}`,
|
||||
category: 'FINANCIAL',
|
||||
priority: 'HIGH'
|
||||
});
|
||||
toast.success(`درخواست برداشت ${toPersian(numAmount.toLocaleString())} تومان با موفقیت ثبت شد و پس از بررسی واحد مالی واریز خواهد شد.`);
|
||||
setIsWithdrawModalOpen(false);
|
||||
setWithdrawAmount("");
|
||||
setWithdrawIban("");
|
||||
fetchTickets();
|
||||
} catch {
|
||||
toast.error("خطا در ثبت درخواست برداشت. لطفاً با پشتیبانی تماس بگیرید.");
|
||||
} finally {
|
||||
setIsSubmittingWithdrawal(false);
|
||||
}
|
||||
};
|
||||
|
||||
const tabs = [
|
||||
{ id: "profile", label: "اطلاعات فردی", icon: <UserCircle className="w-5 h-5" /> },
|
||||
{ id: "pets", label: "پتهای من", icon: <Dog className="w-5 h-5" /> },
|
||||
{ id: "orders", label: "سفارشات من", icon: <Package className="w-5 h-5" /> },
|
||||
{ id: "wallet", label: "کیف پول", icon: <Wallet className="w-5 h-5" /> },
|
||||
{ id: "addresses", label: "آدرسها", icon: <MapPin className="w-5 h-5" /> },
|
||||
@@ -596,9 +651,139 @@ export default function UserDashboard() {
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === "pets" && (
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<div>
|
||||
<h3 className="text-2xl font-black text-medical-gray-900 italic">پتهای من (حیوانات خانگی)</h3>
|
||||
<p className="text-xs text-medical-gray-500 mt-1 font-medium">مدیریت مشخصات، سوابق سلامت، رژیم غذایی و پت فعال</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
onClick={() => router.push('/profile')}
|
||||
className="px-6 py-3 bg-canina-blue text-white rounded-2xl font-black text-xs flex items-center gap-2 hover:bg-canina-dark transition-all shadow-lg shadow-canina-blue/10 cursor-pointer"
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
افزودن پت جدید
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{(pets || []).length === 0 ? (
|
||||
<div className="text-center py-20 bg-white border-2 border-dashed border-medical-gray-200 rounded-[3rem] p-8">
|
||||
<div className="w-20 h-20 bg-canina-blue/10 rounded-full flex items-center justify-center text-canina-blue mx-auto mb-4">
|
||||
<Dog className="w-10 h-10" />
|
||||
</div>
|
||||
<h4 className="text-lg font-black text-medical-gray-900 mb-2">هنوز حیوانی ثبت نکردهاید</h4>
|
||||
<p className="text-xs text-medical-gray-400 font-medium max-w-md mx-auto mb-6">
|
||||
با ثبت اطلاعات پت خود، پیشنهادهای اختصاصی مکمل، دوز مصرفی دقیق و یادآورهای پزشکی دریافت کنید.
|
||||
</p>
|
||||
<button
|
||||
onClick={() => router.push('/profile')}
|
||||
className="px-8 py-3.5 bg-canina-blue text-white rounded-2xl font-black text-xs inline-flex items-center gap-2 hover:bg-canina-dark transition-all shadow-xl shadow-canina-blue/20 cursor-pointer"
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
ثبت اولین پت
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6">
|
||||
{pets.map((p) => {
|
||||
const isActive = p.id === activePetId;
|
||||
const isDog = p.type === 'سگ' || (p.type as string) === 'dog';
|
||||
return (
|
||||
<div
|
||||
key={p.id}
|
||||
className={cn(
|
||||
"bg-white rounded-3xl p-5 sm:p-6 border-2 transition-all shadow-sm flex flex-col justify-between relative group",
|
||||
isActive ? "border-canina-blue ring-2 ring-canina-blue/10" : "border-medical-gray-100 hover:border-canina-blue/40"
|
||||
)}
|
||||
>
|
||||
<div>
|
||||
<div className="flex items-start justify-between gap-4 mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-14 h-14 rounded-2xl bg-medical-gray-50 border border-medical-gray-100 overflow-hidden flex items-center justify-center shrink-0">
|
||||
{p.imageUrl || p.image ? (
|
||||
<img src={p.imageUrl || p.image} alt={p.name} className="w-full h-full object-cover" />
|
||||
) : (
|
||||
<span className="text-2xl">{isDog ? '🐶' : '🐱'}</span>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<h4 className="text-base font-black text-medical-gray-900">{p.name}</h4>
|
||||
{isActive && (
|
||||
<span className="px-2 py-0.5 bg-emerald-100 text-emerald-700 text-[10px] font-black rounded-full flex items-center gap-1">
|
||||
<CheckCircle2 className="w-3 h-3" /> پت فعال
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-xs text-medical-gray-400 font-bold mt-0.5">
|
||||
{isDog ? 'سگ' : 'گربه'} {p.breed ? `• نژاد ${p.breed}` : ''}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setPetToDelete({ id: p.id, name: p.name })}
|
||||
className="w-8 h-8 rounded-xl bg-red-50 text-red-500 hover:bg-red-500 hover:text-white flex items-center justify-center transition-colors cursor-pointer"
|
||||
title="حذف پت"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-3 gap-2 p-3 bg-medical-gray-50/80 rounded-2xl mb-4 text-center">
|
||||
<div>
|
||||
<span className="text-[10px] text-medical-gray-400 block font-bold">سن</span>
|
||||
<span className="text-xs font-black text-medical-gray-800">{toPersian(p.age)} ساله</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] text-medical-gray-400 block font-bold">وزن</span>
|
||||
<span className="text-xs font-black text-medical-gray-800">{toPersian(p.weight)} کیلو</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-[10px] text-medical-gray-400 block font-bold">فعالیت</span>
|
||||
<span className="text-xs font-black text-medical-gray-800">{p.activityLevel || 'متوسط'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 pt-3 border-t border-medical-gray-100">
|
||||
{!isActive && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setActivePet(p.id);
|
||||
toast.success(`${p.name} به عنوان پت فعال انتخاب شد`);
|
||||
}}
|
||||
className="flex-1 py-2.5 bg-medical-gray-100 hover:bg-canina-blue hover:text-white rounded-xl text-xs font-black text-medical-gray-700 transition-colors flex items-center justify-center gap-1.5 cursor-pointer"
|
||||
>
|
||||
<CheckCircle className="w-3.5 h-3.5" />
|
||||
انتخاب به عنوان پت فعال
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => router.push('/profile')}
|
||||
className={cn(
|
||||
"py-2.5 px-4 rounded-xl text-xs font-black transition-colors flex items-center justify-center gap-1.5 cursor-pointer",
|
||||
isActive ? "flex-1 bg-canina-blue text-white hover:bg-canina-dark" : "bg-medical-gray-50 text-medical-gray-600 hover:bg-medical-gray-200"
|
||||
)}
|
||||
>
|
||||
<Activity className="w-3.5 h-3.5" />
|
||||
شناسنامه و رژیم سلامت
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === "orders" && (
|
||||
<div>
|
||||
@@ -786,48 +971,42 @@ export default function UserDashboard() {
|
||||
<div className="w-2 h-2 bg-emerald-400 rounded-full animate-pulse shadow-sm shadow-emerald-400/50" />
|
||||
موجودی زنده و قابل استفاده
|
||||
</div>
|
||||
<div className="flex items-baseline gap-2 sm:gap-3 justify-center lg:justify-start" dir="rtl">
|
||||
<div className="flex items-baseline gap-2 flex-row-reverse justify-end">
|
||||
<div className="text-3xl sm:text-4xl lg:text-5xl font-black italic tracking-tight whitespace-nowrap">
|
||||
{toPersian((profile.walletBalance || 0).toLocaleString())}
|
||||
</div>
|
||||
<span className="text-sm sm:text-base font-bold opacity-90 decoration-white/30 underline underline-offset-8">
|
||||
تومان
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap sm:flex-nowrap gap-3 w-full lg:w-auto shrink-0 justify-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (profile.walletBalance < 50000) {
|
||||
toast.error("حداقل موجودی برای ثبت درخواست برداشت ۵۰,۰۰۰ تومان است.");
|
||||
return;
|
||||
}
|
||||
const withdrawAmountStr = prompt("لطفاً مبلغ مورد نظر برای برداشت (تومان) را وارد کنید:", "100000");
|
||||
if (!withdrawAmountStr) return;
|
||||
const withdrawAmount = parseInt(withdrawAmountStr);
|
||||
if (isNaN(withdrawAmount) || withdrawAmount > profile.walletBalance) {
|
||||
toast.error("مبلغ وارد شده معتبر نیست یا از موجودی کیف پول بیشتر است.");
|
||||
return;
|
||||
}
|
||||
const iban = prompt("لطفاً شماره شبا (IR...) جهت واریز را وارد کنید:");
|
||||
if (!iban) return;
|
||||
toast.success(`درخواست برداشت ${toPersian(withdrawAmount.toLocaleString())} تومان با موفقیت ثبت شد و پس از بررسی واریز خواهد شد.`);
|
||||
}}
|
||||
className="flex-1 sm:flex-initial sm:w-36 h-12 sm:h-14 bg-white/10 backdrop-blur-md rounded-2xl font-black text-xs sm:text-sm flex items-center justify-center gap-2 border border-white/20 hover:bg-white/20 transition-all cursor-pointer whitespace-nowrap"
|
||||
>
|
||||
<ArrowDownCircle className="w-4 h-4 sm:w-5 sm:h-5 shrink-0" />
|
||||
برداشت وجه
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsTopUpModalOpen(true)}
|
||||
className="flex-1 sm:flex-initial sm:w-36 h-12 sm:h-14 bg-white text-canina-blue rounded-2xl font-black text-xs sm:text-sm flex items-center justify-center gap-2 hover:bg-medical-gray-900 hover:text-white transition-all shadow-xl shadow-black/10 group/topup cursor-pointer whitespace-nowrap"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap sm:flex-nowrap gap-3 w-full lg:w-auto shrink-0 justify-center">
|
||||
{isWithdrawalEnabled && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if ((profile.walletBalance || 0) < 50000) {
|
||||
toast.error("حداقل موجودی برای ثبت درخواست برداشت ۵۰,۰۰۰ تومان است.");
|
||||
return;
|
||||
}
|
||||
setWithdrawAmount(String(profile.walletBalance || 50000));
|
||||
setIsWithdrawModalOpen(true);
|
||||
}}
|
||||
className="flex-1 sm:flex-initial sm:w-36 h-12 sm:h-14 bg-white/10 backdrop-blur-md rounded-2xl font-black text-xs sm:text-sm flex items-center justify-center gap-2 border border-white/20 hover:bg-white/20 transition-all cursor-pointer whitespace-nowrap"
|
||||
>
|
||||
<ArrowDownCircle className="w-4 h-4 sm:w-5 sm:h-5 shrink-0" />
|
||||
برداشت وجه
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsTopUpModalOpen(true)}
|
||||
className="flex-1 sm:flex-initial sm:w-36 h-12 sm:h-14 bg-white text-canina-blue rounded-2xl font-black text-xs sm:text-sm flex items-center justify-center gap-2 hover:bg-medical-gray-900 hover:text-white transition-all shadow-xl shadow-black/10 group/topup cursor-pointer whitespace-nowrap"
|
||||
>
|
||||
<ArrowUpCircle className="w-4 h-4 sm:w-5 sm:h-5 group-hover:-translate-y-1 transition-transform shrink-0" />
|
||||
شارژ آنی
|
||||
</button>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1252,6 +1431,125 @@ export default function UserDashboard() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Wallet Withdrawal Request Modal */}
|
||||
{isWithdrawModalOpen && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm animate-fade-in font-vazir">
|
||||
<div className="bg-white w-full max-w-md rounded-3xl p-6 sm:p-8 shadow-2xl space-y-6" dir="rtl">
|
||||
<div className="flex items-center justify-between pb-4 border-b border-medical-gray-100">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-amber-50 text-amber-600 rounded-xl flex items-center justify-center">
|
||||
<ArrowDownCircle className="w-6 h-6" />
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-base font-black text-gray-900">درخواست برداشت و تسویه وجه</h3>
|
||||
<p className="text-xs text-gray-400 font-bold mt-0.5">
|
||||
موجودی قابل برداشت: {toPersian((profile.walletBalance || 0).toLocaleString())} تومان
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsWithdrawModalOpen(false)}
|
||||
className="w-8 h-8 rounded-full bg-gray-100 hover:bg-gray-200 text-gray-600 flex items-center justify-center font-bold text-sm cursor-pointer"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleWithdrawSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-xs font-black text-gray-700 mb-1">
|
||||
مبلغ درخواستی (تومان) *
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
placeholder="حداقل ۵۰,۰۰۰ تومان"
|
||||
value={withdrawAmount}
|
||||
onChange={(e) => setWithdrawAmount(e.target.value)}
|
||||
className="w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm font-bold text-gray-900 focus:border-canina-blue outline-none"
|
||||
dir="ltr"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-xs font-black text-gray-700 mb-1">
|
||||
شماره شبا یا شماره کارت جهت واریز *
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
placeholder="IR... یا شماره ۱۶ رقمی کارت"
|
||||
value={withdrawIban}
|
||||
onChange={(e) => setWithdrawIban(e.target.value)}
|
||||
className="w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-xs font-mono font-bold text-gray-900 focus:border-canina-blue outline-none"
|
||||
dir="ltr"
|
||||
/>
|
||||
<p className="text-[10px] text-gray-400 font-medium mt-1">
|
||||
شماره حساب باید به نام صاحب حساب کاربری ({profile.firstName} {profile.lastName}) باشد.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-3 bg-amber-50 rounded-xl text-[11px] text-amber-800 font-medium leading-relaxed">
|
||||
واریز مبالغ تسویه پس از تایید واحد مالی کنینا، طی ۲۴ الی ۴۸ ساعت کاری از طریق سامانه پایا انجام خواهد شد.
|
||||
</div>
|
||||
|
||||
<div className="pt-2 flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsWithdrawModalOpen(false)}
|
||||
className="px-5 py-2.5 rounded-xl text-xs font-bold text-gray-600 bg-gray-100 hover:bg-gray-200 cursor-pointer"
|
||||
>
|
||||
انصراف
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isSubmittingWithdrawal}
|
||||
className="px-6 py-2.5 rounded-xl text-xs font-black text-white bg-canina-blue hover:bg-canina-dark disabled:opacity-50 transition-all flex items-center gap-2 cursor-pointer shadow-md shadow-canina-blue/20"
|
||||
>
|
||||
{isSubmittingWithdrawal ? 'در حال ثبت...' : 'ثبت درخواست برداشت'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Pet Delete Confirmation Modal */}
|
||||
{petToDelete && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm animate-fade-in font-vazir">
|
||||
<div className="bg-white w-full max-w-sm rounded-3xl p-6 shadow-2xl text-center space-y-4" dir="rtl">
|
||||
<div className="w-14 h-14 bg-red-50 text-red-500 rounded-2xl flex items-center justify-center mx-auto">
|
||||
<Trash2 className="w-7 h-7" />
|
||||
</div>
|
||||
<h3 className="text-base font-black text-gray-900">حذف پروفایل {petToDelete.name}</h3>
|
||||
<p className="text-xs text-gray-500 font-medium leading-relaxed">
|
||||
آیا از حذف اطلاعات و پرونده پزشکی «{petToDelete.name}» اطمینان دارید؟ این عملیات قابل بازگشت نیست.
|
||||
</p>
|
||||
<div className="flex gap-3 pt-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setPetToDelete(null)}
|
||||
className="flex-1 py-2.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-xl text-xs font-black cursor-pointer transition-colors"
|
||||
>
|
||||
انصراف
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
removePet(petToDelete.id);
|
||||
toast.success(`پروفایل ${petToDelete.name} با موفقیت حذف شد`);
|
||||
setPetToDelete(null);
|
||||
}}
|
||||
className="flex-1 py-2.5 bg-red-600 hover:bg-red-700 text-white rounded-xl text-xs font-black cursor-pointer transition-colors shadow-md shadow-red-200"
|
||||
>
|
||||
بله، حذف کن
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user