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
@@ -31,4 +31,19 @@ export class ZibalCallbackQueryDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
hashedCardNumber?: string;
|
hashedCardNumber?: string;
|
||||||
|
|
||||||
|
@ApiPropertyOptional({ description: 'نوع پرداخت (ORDER یا WALLET_TOPUP)' })
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
type?: string;
|
||||||
|
|
||||||
|
@ApiPropertyOptional({ description: 'مبلغ تراکنش' })
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
amount?: string;
|
||||||
|
|
||||||
|
@ApiPropertyOptional({ description: 'پیام تراکنش' })
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
message?: string;
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,14 @@ import {
|
|||||||
Req,
|
Req,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
Query,
|
Query,
|
||||||
|
UseInterceptors,
|
||||||
|
UploadedFile,
|
||||||
|
BadRequestException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
import { FileInterceptor } from '@nestjs/platform-express';
|
||||||
|
import { diskStorage } from 'multer';
|
||||||
|
import { extname, join } from 'path';
|
||||||
|
import * as fs from 'fs';
|
||||||
import { PetsService } from './pets.service';
|
import { PetsService } from './pets.service';
|
||||||
import { CreatePetDto } from './dto/create-pet.dto';
|
import { CreatePetDto } from './dto/create-pet.dto';
|
||||||
import { UpdatePetDto } from './dto/update-pet.dto';
|
import { UpdatePetDto } from './dto/update-pet.dto';
|
||||||
@@ -78,6 +85,37 @@ export class PetsController {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@Post('upload-image')
|
||||||
|
@UseInterceptors(
|
||||||
|
FileInterceptor('file', {
|
||||||
|
storage: diskStorage({
|
||||||
|
destination: (req, file, cb) => {
|
||||||
|
const dir = join(process.cwd(), 'uploads', 'pets');
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
cb(null, dir);
|
||||||
|
},
|
||||||
|
filename: (req, file, cb) => {
|
||||||
|
const randomName = Array(32)
|
||||||
|
.fill(null)
|
||||||
|
.map(() => Math.round(Math.random() * 16).toString(16))
|
||||||
|
.join('');
|
||||||
|
cb(null, `${randomName}${extname(file.originalname)}`);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
limits: { fileSize: 10 * 1024 * 1024 }, // 10MB
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
@ApiOperation({ summary: 'آپلود تصویر حیوان خانگی' })
|
||||||
|
uploadPetImage(@UploadedFile() file: Express.Multer.File) {
|
||||||
|
if (!file) {
|
||||||
|
throw new BadRequestException('فایلی ارسال نشده است');
|
||||||
|
}
|
||||||
|
const url = `/uploads/pets/${file.filename}`;
|
||||||
|
return { url, filename: file.filename };
|
||||||
|
}
|
||||||
|
|
||||||
create(
|
create(
|
||||||
@Req() req: { user: { id: string } },
|
@Req() req: { user: { id: string } },
|
||||||
@Body() createPetDto: CreatePetDto,
|
@Body() createPetDto: CreatePetDto,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export default function FinancialSettingsPage() {
|
|||||||
freeShippingThreshold: 2000000,
|
freeShippingThreshold: 2000000,
|
||||||
standardShippingFee: 85000,
|
standardShippingFee: 85000,
|
||||||
charityDonationOptions: [10000, 20000, 50000],
|
charityDonationOptions: [10000, 20000, 50000],
|
||||||
|
walletWithdrawalEnabled: false,
|
||||||
});
|
});
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
@@ -30,6 +31,7 @@ export default function FinancialSettingsPage() {
|
|||||||
charityDonationOptions: Array.isArray(data.charityDonationOptions)
|
charityDonationOptions: Array.isArray(data.charityDonationOptions)
|
||||||
? data.charityDonationOptions.map(Number)
|
? data.charityDonationOptions.map(Number)
|
||||||
: [10000, 20000, 50000],
|
: [10000, 20000, 50000],
|
||||||
|
walletWithdrawalEnabled: Boolean(data.walletWithdrawalEnabled ?? false),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -168,6 +170,22 @@ export default function FinancialSettingsPage() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Wallet Withdrawal Feature Toggle */}
|
||||||
|
<div className="md:col-span-2 pt-4 border-t border-gray-100">
|
||||||
|
<label className="flex items-center gap-3 cursor-pointer p-4 bg-purple-50/50 hover:bg-purple-50 rounded-2xl border border-purple-100 transition-colors">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={Boolean(financial.walletWithdrawalEnabled)}
|
||||||
|
onChange={(e) => setFinancial({ ...financial, walletWithdrawalEnabled: e.target.checked })}
|
||||||
|
className="w-5 h-5 rounded-lg text-purple-600 focus:ring-purple-500 border-gray-300 cursor-pointer"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<span className="text-sm font-black text-gray-900 block">فعالسازی امکان ثبت درخواست برداشت و تسویهحساب کیف پول (wallet_withdrawal_enabled)</span>
|
||||||
|
<span className="text-xs text-gray-500 font-medium block mt-0.5">در صورت فعال بودن، کاربران میتوانند از طریق داشبورد خود درخواست تسویه و واریز وجه به شماره شبا ثبت کنند.</span>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-end pt-4 border-t border-gray-100">
|
<div className="flex justify-end pt-4 border-t border-gray-100">
|
||||||
|
|||||||
@@ -215,19 +215,37 @@ export default function Reports() {
|
|||||||
{/* Best Sellers */}
|
{/* Best Sellers */}
|
||||||
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
|
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
|
||||||
<h3 className="text-lg font-bold text-gray-900 mb-6">پرفروشترین محصولات</h3>
|
<h3 className="text-lg font-bold text-gray-900 mb-6">پرفروشترین محصولات</h3>
|
||||||
<div className="h-64 w-full" dir="ltr">
|
<div className="min-h-[320px] w-full" dir="ltr">
|
||||||
{bestSellers?.length > 0 ? (
|
{bestSellers && bestSellers.length > 0 ? (
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height={Math.max(300, bestSellers.length * 45)}>
|
||||||
<BarChart data={bestSellers} layout="vertical" margin={{ top: 0, right: 0, left: 0, bottom: 0 }}>
|
<BarChart
|
||||||
|
data={bestSellers}
|
||||||
|
layout="vertical"
|
||||||
|
margin={{ top: 10, right: 30, left: 10, bottom: 10 }}
|
||||||
|
>
|
||||||
<CartesianGrid strokeDasharray="3 3" horizontal={false} stroke="#f3f4f6" />
|
<CartesianGrid strokeDasharray="3 3" horizontal={false} stroke="#f3f4f6" />
|
||||||
<XAxis type="number" stroke="#9ca3af" fontSize={12} />
|
<XAxis type="number" stroke="#9ca3af" fontSize={11} allowDecimals={false} />
|
||||||
<YAxis dataKey="name" type="category" width={120} stroke="#4b5563" fontSize={12} tickLine={false} axisLine={false} style={{ direction: 'rtl' }} />
|
<YAxis
|
||||||
<RechartsTooltip cursor={{ fill: '#f3f4f6' }} />
|
dataKey="name"
|
||||||
<Bar dataKey="quantity" fill="#EC4899" radius={[0, 4, 4, 0]} barSize={20} />
|
type="category"
|
||||||
|
width={180}
|
||||||
|
stroke="#4b5563"
|
||||||
|
fontSize={11}
|
||||||
|
tickLine={false}
|
||||||
|
axisLine={false}
|
||||||
|
tickFormatter={(val: string) => (val && val.length > 24 ? `${val.slice(0, 22)}...` : val)}
|
||||||
|
style={{ direction: 'rtl', textAnchor: 'end' }}
|
||||||
|
/>
|
||||||
|
<RechartsTooltip
|
||||||
|
cursor={{ fill: '#fdf2f8' }}
|
||||||
|
formatter={(val: number) => [`${val.toLocaleString('fa-IR')} عدد`, 'تعداد فروش']}
|
||||||
|
labelFormatter={(lbl: string) => `محصول: ${lbl}`}
|
||||||
|
/>
|
||||||
|
<Bar dataKey="quantity" fill="#EC4899" radius={[0, 6, 6, 0]} barSize={18} />
|
||||||
</BarChart>
|
</BarChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-gray-400 font-medium flex items-center justify-center h-full">دادهای موجود نیست</div>
|
<div className="text-gray-400 font-medium flex items-center justify-center h-64">دادهای موجود نیست</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export default function Settings() {
|
|||||||
ENAMAD_CODE: '',
|
ENAMAD_CODE: '',
|
||||||
THEME_PRIMARY_COLOR: '#7c3aed',
|
THEME_PRIMARY_COLOR: '#7c3aed',
|
||||||
BRAND_TYPOGRAPHY: 'vazirmatn',
|
BRAND_TYPOGRAPHY: 'vazirmatn',
|
||||||
|
shipping_notice: 'ارسال رایگان برای سفارشهای بالای ۱۵۰ هزار تومان — گارانتی اصالت کنینا آلمان — مشاوره تخصصی مکملهای دارویی سگ و گربه با کادر دامپزشکان مجرب',
|
||||||
});
|
});
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
@@ -71,6 +72,7 @@ export default function Settings() {
|
|||||||
ENAMAD_CODE: response.data.data.ENAMAD_CODE || '',
|
ENAMAD_CODE: response.data.data.ENAMAD_CODE || '',
|
||||||
THEME_PRIMARY_COLOR: response.data.data.THEME_PRIMARY_COLOR || '#7c3aed',
|
THEME_PRIMARY_COLOR: response.data.data.THEME_PRIMARY_COLOR || '#7c3aed',
|
||||||
BRAND_TYPOGRAPHY: response.data.data.BRAND_TYPOGRAPHY || 'vazirmatn',
|
BRAND_TYPOGRAPHY: response.data.data.BRAND_TYPOGRAPHY || 'vazirmatn',
|
||||||
|
shipping_notice: response.data.data.shipping_notice || response.data.data.SHIPPING_NOTICE || 'ارسال رایگان برای سفارشهای بالای ۱۵۰ هزار تومان — گارانتی اصالت کنینا آلمان — مشاوره تخصصی مکملهای دارویی سگ و گربه با کادر دامپزشکان مجرب',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@@ -427,6 +429,18 @@ export default function Settings() {
|
|||||||
<p className="text-[10px] text-gray-400 mt-1">این لوگو در صورت پر بودن، جایگزین تایپوگرافی هدر سایت در اپلیکیشن خواهد شد.</p>
|
<p className="text-[10px] text-gray-400 mt-1">این لوگو در صورت پر بودن، جایگزین تایپوگرافی هدر سایت در اپلیکیشن خواهد شد.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="md:col-span-2">
|
||||||
|
<label className="block text-xs font-bold text-gray-700 mb-1">متن نوار متحرک اعلان بالای سایت (Ticker / Announcement Bar)</label>
|
||||||
|
<textarea
|
||||||
|
rows={2}
|
||||||
|
value={settings.shipping_notice}
|
||||||
|
onChange={(e) => setSettings({ ...settings, shipping_notice: e.target.value })}
|
||||||
|
placeholder="ارسال رایگان برای سفارشهای بالای ۱۵۰ هزار تومان — ..."
|
||||||
|
className="w-full border border-gray-200 rounded-xl p-3 outline-none focus:ring-2 focus:ring-purple-500 text-xs font-bold bg-amber-50/50"
|
||||||
|
/>
|
||||||
|
<p className="text-[11px] text-gray-500 mt-1">این متن به عنوان نوار زرد متحرک بالای تمام صفحات سایت نمایش داده میشود.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="md:col-span-2">
|
<div className="md:col-span-2">
|
||||||
<label className="block text-xs font-bold text-gray-700 mb-1">کد و اسکریپت نماد اعتماد الکترونیکی (Enamad HTML/Embed Code)</label>
|
<label className="block text-xs font-bold text-gray-700 mb-1">کد و اسکریپت نماد اعتماد الکترونیکی (Enamad HTML/Embed Code)</label>
|
||||||
<textarea
|
<textarea
|
||||||
|
|||||||
@@ -828,24 +828,24 @@ export default function Transactions() {
|
|||||||
{/* Modal Actions */}
|
{/* Modal Actions */}
|
||||||
<div className="flex items-center justify-between gap-3 pt-2">
|
<div className="flex items-center justify-between gap-3 pt-2">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{selectedTx.status !== 'VERIFIED' && (
|
{selectedTx.gateway !== 'zibal' && selectedTx.gateway !== 'online' && selectedTx.status !== 'VERIFIED' && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => handleManualVerify(selectedTx.id)}
|
onClick={() => handleManualVerify(selectedTx.id)}
|
||||||
className="bg-emerald-600 hover:bg-emerald-700 text-white font-black px-4 py-2.5 rounded-xl text-xs flex items-center gap-1.5 shadow-md shadow-emerald-600/20 transition-all cursor-pointer"
|
className="bg-emerald-600 hover:bg-emerald-700 text-white font-black px-4 py-2.5 rounded-xl text-xs flex items-center gap-1.5 shadow-md shadow-emerald-600/20 transition-all cursor-pointer"
|
||||||
>
|
>
|
||||||
<CheckCircle2 className="w-4 h-4" />
|
<CheckCircle2 className="w-4 h-4" />
|
||||||
<span>تایید دستی و اعمال مالی</span>
|
<span>تایید دستی واریز کارت به کارت</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{selectedTx.status === 'PENDING' && (
|
{selectedTx.gateway !== 'zibal' && selectedTx.gateway !== 'online' && selectedTx.status === 'PENDING' && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => handleManualReject(selectedTx.id)}
|
onClick={() => handleManualReject(selectedTx.id)}
|
||||||
className="bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-200 font-bold px-4 py-2.5 rounded-xl text-xs flex items-center gap-1.5 transition-all cursor-pointer"
|
className="bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-200 font-bold px-4 py-2.5 rounded-xl text-xs flex items-center gap-1.5 transition-all cursor-pointer"
|
||||||
>
|
>
|
||||||
<XCircle className="w-4 h-4" />
|
<XCircle className="w-4 h-4" />
|
||||||
<span>رد کردن تراکنش</span>
|
<span>رد فیش کارت به کارت</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -74,6 +74,30 @@ const GROUPS: Record<string, string[]> = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const KEY_LABELS_FA: Record<string, string> = {
|
||||||
|
shipping_notice: "متن نوار متحرک اعلان بالای سایت (ارسال رایگان، گارانتی و شعار)",
|
||||||
|
brand_name_fa: "نام فارسی برند (کنینا ایران)",
|
||||||
|
brand_subtitle: "زیرعنوان برند (نمایندگی رسمی مکملهای دارویی کنینا آلمان)",
|
||||||
|
nav_solutions: "عنوان راهکارهای درمانی در منو",
|
||||||
|
nav_products: "عنوان کاتالوگ محصولات در منو",
|
||||||
|
nav_wiki: "عنوان دانشنامه در منو",
|
||||||
|
nav_blog: "عنوان وبلاگ در منو",
|
||||||
|
nav_pet_profiles: "عنوان پرونده سلامت در منو",
|
||||||
|
nav_search_placeholder: "متن جستجو در منو",
|
||||||
|
nav_cart: "عنوان سبد خرید",
|
||||||
|
hero_title: "عنوان اصلی بنر (Hero)",
|
||||||
|
hero_desc: "توضیحات بنر اصلی",
|
||||||
|
hero_btn_advisor: "متن دکمه دستیار هوشمند در بنر",
|
||||||
|
hero_btn_products: "متن دکمه مشاهده محصولات در بنر",
|
||||||
|
advisor_title: "عنوان دستیار هوشمند سلامت",
|
||||||
|
advisor_subtitle: "زیرعنوان دستیار هوشمند سلامت",
|
||||||
|
featured_title_line1: "عنوان بخش محصولات برگزیده",
|
||||||
|
cta_title: "عنوان کادر دعوت به اقدام (CTA)",
|
||||||
|
footer_copyright: "متن کپیرایت فوتر",
|
||||||
|
maintenance_mode: "حالت تعمیرات و صیانت سایت",
|
||||||
|
catalog_mode: "حالت کاتالوگمود",
|
||||||
|
};
|
||||||
|
|
||||||
const GROUP_PAGE_MAP: Record<string, string> = {
|
const GROUP_PAGE_MAP: Record<string, string> = {
|
||||||
"بنر اصلی (Hero)": "hero",
|
"بنر اصلی (Hero)": "hero",
|
||||||
"هدر و ناوبری": "header",
|
"هدر و ناوبری": "header",
|
||||||
@@ -241,7 +265,8 @@ export default function UITexts() {
|
|||||||
const filteredKeys = keys.filter(key => {
|
const filteredKeys = keys.filter(key => {
|
||||||
if (!search) return true;
|
if (!search) return true;
|
||||||
const currentVal = edits[key] ?? texts[key] ?? '';
|
const currentVal = edits[key] ?? texts[key] ?? '';
|
||||||
return key.toLowerCase().includes(search.toLowerCase()) || currentVal.includes(search);
|
const faLabel = KEY_LABELS_FA[key] || '';
|
||||||
|
return key.toLowerCase().includes(search.toLowerCase()) || faLabel.includes(search) || currentVal.includes(search);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (filteredKeys.length === 0) return null;
|
if (filteredKeys.length === 0) return null;
|
||||||
@@ -264,9 +289,16 @@ export default function UITexts() {
|
|||||||
return (
|
return (
|
||||||
<div key={key} className="space-y-2 p-4 bg-gray-50/70 rounded-2xl border border-gray-100">
|
<div key={key} className="space-y-2 p-4 bg-gray-50/70 rounded-2xl border border-gray-100">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<label className="text-xs font-black text-gray-700 font-mono" dir="ltr">
|
<div>
|
||||||
{key}
|
{KEY_LABELS_FA[key] && (
|
||||||
</label>
|
<span className="text-xs font-black text-gray-900 block mb-0.5">
|
||||||
|
{KEY_LABELS_FA[key]}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<label className="text-[10px] font-mono text-gray-400 font-bold block" dir="ltr">
|
||||||
|
{key}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
{isSaved && (
|
{isSaved && (
|
||||||
<span className="text-[10px] text-green-600 font-black flex items-center gap-1">
|
<span className="text-[10px] text-green-600 font-black flex items-center gap-1">
|
||||||
<Check className="w-3 h-3" /> ذخیره شد
|
<Check className="w-3 h-3" /> ذخیره شد
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ export interface FinancialSettings {
|
|||||||
freeShippingThreshold: number;
|
freeShippingThreshold: number;
|
||||||
standardShippingFee: number;
|
standardShippingFee: number;
|
||||||
charityDonationOptions: number[];
|
charityDonationOptions: number[];
|
||||||
|
walletWithdrawalEnabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SystemSettings {
|
export interface SystemSettings {
|
||||||
@@ -180,6 +181,7 @@ export interface SystemSettings {
|
|||||||
allowGuestCheckout: boolean;
|
allowGuestCheckout: boolean;
|
||||||
b2bRegistrationOpen: boolean;
|
b2bRegistrationOpen: boolean;
|
||||||
supportPhone: string;
|
supportPhone: string;
|
||||||
|
walletWithdrawalEnabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Product {
|
export interface Product {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import SafeImage from "./SafeImage";
|
import SafeImage from "./SafeImage";
|
||||||
import { toPersian } from "../lib/utils";
|
import { toPersian } from "../lib/utils";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
export default function B2BPortal({ onClose }: { onClose: () => void }) {
|
export default function B2BPortal({ onClose }: { onClose: () => void }) {
|
||||||
const [products, setProducts] = useState<Product[]>([]);
|
const [products, setProducts] = useState<Product[]>([]);
|
||||||
@@ -123,10 +124,10 @@ export default function B2BPortal({ onClose }: { onClose: () => void }) {
|
|||||||
try {
|
try {
|
||||||
const api = (await import('../lib/services/api')).default;
|
const api = (await import('../lib/services/api')).default;
|
||||||
await api.post('/wholesale/apply', { businessName: bName, licenseNumber: phone });
|
await api.post('/wholesale/apply', { businessName: bName, licenseNumber: phone });
|
||||||
alert('درخواست شما با موفقیت ثبت شد. کارشناسان پشتیبانی B2B کنینا به زودی جهت تایید تلفنی با شما تماس خواهند گرفت.');
|
toast.success('درخواست شما با موفقیت ثبت شد. کارشناسان پشتیبانی B2B کنینا به زودی جهت تایید تلفنی با شما تماس خواهند گرفت.');
|
||||||
form.reset();
|
form.reset();
|
||||||
} catch {
|
} catch {
|
||||||
alert('خطا در ثبت درخواست. لطفاً دوباره تلاش کنید.');
|
toast.error('خطا در ثبت درخواست. لطفاً دوباره تلاش کنید.');
|
||||||
}
|
}
|
||||||
}} className="space-y-2">
|
}} 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" />
|
<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 roundStep = Number(useSettingsStore((state) => state.getText('CHARITY_ROUND_STEP', '10000'))) || 10000;
|
||||||
const shippingFeeSetting = useSettingsStore((state) => state.getText('shipping_fee', '0'));
|
const shippingFeeSetting = useSettingsStore((state) => state.getText('shipping_fee', '0'));
|
||||||
const shippingFee = Number(shippingFeeSetting) || 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 subtotal = getSubtotal();
|
||||||
const remainder = subtotal % roundStep;
|
const remainder = subtotal % roundStep;
|
||||||
const roundUpDiff = remainder === 0 ? roundStep : roundStep - remainder;
|
const roundUpDiff = remainder === 0 ? roundStep : roundStep - remainder;
|
||||||
@@ -410,7 +415,7 @@ export default function CheckoutPage() {
|
|||||||
label: getText('PAY_GATEWAY_CARD_LABEL', 'کارت به کارت (واریز مستقیم)'),
|
label: getText('PAY_GATEWAY_CARD_LABEL', 'کارت به کارت (واریز مستقیم)'),
|
||||||
desc: getText('PAY_GATEWAY_CARD_DESC', 'واریز به شماره کارت بانک سامان'),
|
desc: getText('PAY_GATEWAY_CARD_DESC', 'واریز به شماره کارت بانک سامان'),
|
||||||
icon: <CreditCard className="w-5 h-5 sm:w-6 sm:h-6" />,
|
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',
|
id: 'wallet',
|
||||||
@@ -488,7 +493,7 @@ export default function CheckoutPage() {
|
|||||||
})()}
|
})()}
|
||||||
</div>
|
</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="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">
|
<div className="flex items-center gap-2 text-canina-blue font-bold text-sm">
|
||||||
<CreditCard className="w-5 h-5" />
|
<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" />
|
<HeartPulse className="w-3.5 h-3.5 text-canina-blue" />
|
||||||
پتهای من ({pets.length})
|
پتهای من ({pets.length})
|
||||||
</span>
|
</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>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -488,14 +488,23 @@ export default function PetProfile({ initialView }: {
|
|||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
fd.append('file', file);
|
fd.append('file', file);
|
||||||
try {
|
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;
|
const url = res.data?.url || res.data?.path || res.data?.data?.url;
|
||||||
if (url) {
|
if (url) {
|
||||||
setFormData({ ...formData, imageUrl: url });
|
setFormData({ ...formData, imageUrl: url });
|
||||||
toast.success("تصویر با موفقیت آپلود شد");
|
toast.success("تصویر با موفقیت آپلود شد");
|
||||||
}
|
}
|
||||||
} catch {
|
} 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 { addPet, setActivePet } = usePetStore();
|
||||||
const getText = useSettingsStore(state => state.getText);
|
const getText = useSettingsStore(state => state.getText);
|
||||||
|
|
||||||
const [advisorRules, setAdvisorRules] = useState<unknown[]>(rules);
|
const [advisorRules, setAdvisorRules] = useState<unknown[]>(rules || []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (rules && rules.length > 0) {
|
if (rules && rules.length > 0) {
|
||||||
Promise.resolve().then(() => setAdvisorRules(rules));
|
setAdvisorRules(rules);
|
||||||
} else {
|
return;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}, [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);
|
const [step, setStep] = useState(1);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { motion } from "motion/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 } from "lucide-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 { OrderRowSkeleton } from "./Skeleton";
|
||||||
import { useUserStore, Address } from "../lib/store/userStore";
|
import { useUserStore, Address } from "../lib/store/userStore";
|
||||||
import { useCartStore } from "../lib/store/cartStore";
|
import { useCartStore } from "../lib/store/cartStore";
|
||||||
|
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||||
import { toPersian, toEnglishDigits, cn } from "../lib/utils";
|
import { toPersian, toEnglishDigits, cn } from "../lib/utils";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import OrderDetailsModal from "./OrderDetailsModal";
|
import OrderDetailsModal from "./OrderDetailsModal";
|
||||||
@@ -14,12 +15,14 @@ import TopUpModal from "./TopUpModal";
|
|||||||
import { ticketService, Ticket, TicketMessage } from "../lib/services/ticketService";
|
import { ticketService, Ticket, TicketMessage } from "../lib/services/ticketService";
|
||||||
import { usePetStore } from "../lib/store/usePetStore";
|
import { usePetStore } from "../lib/store/usePetStore";
|
||||||
|
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
|
|
||||||
export default function UserDashboard() {
|
export default function UserDashboard() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
const { profile, isLoggedIn, logout, updateProfile, addAddress, updateAddress, deleteAddress, setDefaultAddress, topUpWallet } = useUserStore();
|
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(() => {
|
React.useEffect(() => {
|
||||||
if (!isLoggedIn && typeof window !== "undefined") {
|
if (!isLoggedIn && typeof window !== "undefined") {
|
||||||
@@ -29,7 +32,16 @@ export default function UserDashboard() {
|
|||||||
}, [isLoggedIn, router]);
|
}, [isLoggedIn, router]);
|
||||||
|
|
||||||
const { orders } = useCartStore();
|
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);
|
const [isLoadingOrders, setIsLoadingOrders] = useState(false);
|
||||||
|
|
||||||
// Tickets State
|
// Tickets State
|
||||||
@@ -138,6 +150,13 @@ export default function UserDashboard() {
|
|||||||
|
|
||||||
// Wallet State
|
// Wallet State
|
||||||
const [isTopUpModalOpen, setIsTopUpModalOpen] = useState(false);
|
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
|
// Profile State
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
@@ -278,8 +297,44 @@ export default function UserDashboard() {
|
|||||||
setIsAddressModalOpen(true);
|
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 = [
|
const tabs = [
|
||||||
{ id: "profile", label: "اطلاعات فردی", icon: <UserCircle className="w-5 h-5" /> },
|
{ 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: "orders", label: "سفارشات من", icon: <Package className="w-5 h-5" /> },
|
||||||
{ id: "wallet", label: "کیف پول", icon: <Wallet 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" /> },
|
{ id: "addresses", label: "آدرسها", icon: <MapPin className="w-5 h-5" /> },
|
||||||
@@ -596,9 +651,139 @@ export default function UserDashboard() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</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>
|
||||||
</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" && (
|
{activeTab === "orders" && (
|
||||||
<div>
|
<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 className="w-2 h-2 bg-emerald-400 rounded-full animate-pulse shadow-sm shadow-emerald-400/50" />
|
||||||
موجودی زنده و قابل استفاده
|
موجودی زنده و قابل استفاده
|
||||||
</div>
|
</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">
|
<div className="text-3xl sm:text-4xl lg:text-5xl font-black italic tracking-tight whitespace-nowrap">
|
||||||
{toPersian((profile.walletBalance || 0).toLocaleString())}
|
{toPersian((profile.walletBalance || 0).toLocaleString())}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-sm sm:text-base font-bold opacity-90 decoration-white/30 underline underline-offset-8">
|
<span className="text-sm sm:text-base font-bold opacity-90 decoration-white/30 underline underline-offset-8">
|
||||||
تومان
|
تومان
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap sm:flex-nowrap gap-3 w-full lg:w-auto shrink-0 justify-center">
|
<div className="flex flex-wrap sm:flex-nowrap gap-3 w-full lg:w-auto shrink-0 justify-center">
|
||||||
<button
|
{isWithdrawalEnabled && (
|
||||||
type="button"
|
<button
|
||||||
onClick={() => {
|
type="button"
|
||||||
if (profile.walletBalance < 50000) {
|
onClick={() => {
|
||||||
toast.error("حداقل موجودی برای ثبت درخواست برداشت ۵۰,۰۰۰ تومان است.");
|
if ((profile.walletBalance || 0) < 50000) {
|
||||||
return;
|
toast.error("حداقل موجودی برای ثبت درخواست برداشت ۵۰,۰۰۰ تومان است.");
|
||||||
}
|
return;
|
||||||
const withdrawAmountStr = prompt("لطفاً مبلغ مورد نظر برای برداشت (تومان) را وارد کنید:", "100000");
|
}
|
||||||
if (!withdrawAmountStr) return;
|
setWithdrawAmount(String(profile.walletBalance || 50000));
|
||||||
const withdrawAmount = parseInt(withdrawAmountStr);
|
setIsWithdrawModalOpen(true);
|
||||||
if (isNaN(withdrawAmount) || withdrawAmount > profile.walletBalance) {
|
}}
|
||||||
toast.error("مبلغ وارد شده معتبر نیست یا از موجودی کیف پول بیشتر است.");
|
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"
|
||||||
return;
|
>
|
||||||
}
|
<ArrowDownCircle className="w-4 h-4 sm:w-5 sm:h-5 shrink-0" />
|
||||||
const iban = prompt("لطفاً شماره شبا (IR...) جهت واریز را وارد کنید:");
|
برداشت وجه
|
||||||
if (!iban) return;
|
</button>
|
||||||
toast.success(`درخواست برداشت ${toPersian(withdrawAmount.toLocaleString())} تومان با موفقیت ثبت شد و پس از بررسی واریز خواهد شد.`);
|
)}
|
||||||
}}
|
<button
|
||||||
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"
|
type="button"
|
||||||
>
|
onClick={() => setIsTopUpModalOpen(true)}
|
||||||
<ArrowDownCircle className="w-4 h-4 sm:w-5 sm:h-5 shrink-0" />
|
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"
|
||||||
برداشت وجه
|
>
|
||||||
</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" />
|
<ArrowUpCircle className="w-4 h-4 sm:w-5 sm:h-5 group-hover:-translate-y-1 transition-transform shrink-0" />
|
||||||
شارژ آنی
|
شارژ آنی
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1252,6 +1431,125 @@ export default function UserDashboard() {
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user