fix(all): auto-create ticket tables, multi-tier otp rate limiting, packaged order status & badges, pet kindness footprint
Deploy Canina / deploy (push) Successful in 1m46s
Deploy Canina / deploy (push) Successful in 1m46s
This commit is contained in:
1 parent
d9254e9b01
commit
884b0486cc
8 files changed
+239
-24
No files matched your search
@@ -15,7 +15,10 @@ import {
|
||||
Mail,
|
||||
Package,
|
||||
Save,
|
||||
Download
|
||||
Download,
|
||||
PackageCheck,
|
||||
Heart,
|
||||
CreditCard
|
||||
} from 'lucide-react';
|
||||
import api from '../services/api';
|
||||
import Skeleton from '../components/ui/Skeleton';
|
||||
@@ -28,11 +31,13 @@ export interface OrderItem {
|
||||
priceValue?: number;
|
||||
quantity?: number;
|
||||
product?: {
|
||||
id?: string;
|
||||
nameFa?: string;
|
||||
name?: string;
|
||||
priceValue?: number;
|
||||
imageUrl?: string;
|
||||
image?: string;
|
||||
images?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,6 +51,7 @@ export interface PaymentTx {
|
||||
message?: string;
|
||||
gateway?: string;
|
||||
createdAt: string;
|
||||
trackingCode?: string;
|
||||
}
|
||||
|
||||
export interface Order {
|
||||
@@ -77,11 +83,24 @@ const statusStyles: Record<string, { label: string; color: string; icon: React.E
|
||||
pending_payment: { label: 'در انتظار پرداخت / ناموفق', color: 'bg-rose-100 text-rose-800 border-rose-200', icon: Clock },
|
||||
pending: { label: 'در حال بررسی', color: 'bg-orange-100 text-orange-700 border-orange-200', icon: Clock },
|
||||
processing: { label: 'در حال پردازش', color: 'bg-amber-100 text-amber-800 border-amber-200', icon: Clock },
|
||||
packaged: { label: 'بستهبندی شده (آماده ارسال)', color: 'bg-purple-100 text-purple-800 border-purple-200', icon: PackageCheck },
|
||||
ready_to_ship: { label: 'آماده ارسال', color: 'bg-purple-100 text-purple-800 border-purple-200', icon: PackageCheck },
|
||||
shipped: { label: 'ارسال شده', color: 'bg-blue-100 text-blue-700 border-blue-200', icon: Truck },
|
||||
delivered: { label: 'تحویل داده شده', color: 'bg-green-100 text-green-700 border-green-200', icon: CheckCircle2 },
|
||||
cancelled: { label: 'لغو شده', color: 'bg-red-100 text-red-700 border-red-200', icon: XCircle },
|
||||
};
|
||||
|
||||
const getPaymentMethodLabel = (method?: string): { label: string; color: string } => {
|
||||
switch (method) {
|
||||
case 'wallet': return { label: 'کیف پول', color: 'bg-purple-50 text-purple-700 border-purple-200' };
|
||||
case 'zibal':
|
||||
case 'online': return { label: 'درگاه زیبال (آنلاین)', color: 'bg-emerald-50 text-emerald-700 border-emerald-200' };
|
||||
case 'card_to_card': return { label: 'کارت به کارت', color: 'bg-blue-50 text-blue-700 border-blue-200' };
|
||||
case 'cod': return { label: 'پرداخت در محل', color: 'bg-amber-50 text-amber-700 border-amber-200' };
|
||||
default: return { label: method || 'آنلاین', color: 'bg-gray-50 text-gray-700 border-gray-200' };
|
||||
}
|
||||
};
|
||||
|
||||
const toPersianDigits = (n: string | number): string => {
|
||||
if (n === null || n === undefined) return '';
|
||||
const farsiDigits = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
@@ -356,6 +375,7 @@ export default function Orders() {
|
||||
<option value="">همه وضعیتها</option>
|
||||
<option value="pending_payment">در انتظار پرداخت / ناموفق</option>
|
||||
<option value="processing">در حال پردازش</option>
|
||||
<option value="packaged">بستهبندی شده (آماده ارسال)</option>
|
||||
<option value="shipped">ارسال شده</option>
|
||||
<option value="delivered">تحویل داده شده</option>
|
||||
<option value="cancelled">لغو شده</option>
|
||||
@@ -380,6 +400,7 @@ export default function Orders() {
|
||||
{ label: 'همه سفارشها', value: '' },
|
||||
{ label: 'در انتظار پرداخت / ناموفق', value: 'pending_payment', color: 'text-rose-700 bg-rose-50 border-rose-200' },
|
||||
{ label: 'در حال پردازش', value: 'processing', color: 'text-amber-700 bg-amber-50 border-amber-200' },
|
||||
{ label: 'بستهبندی شده (آماده ارسال)', value: 'packaged', color: 'text-purple-700 bg-purple-50 border-purple-200' },
|
||||
{ label: 'ارسال شده', value: 'shipped', color: 'text-blue-700 bg-blue-50 border-blue-200' },
|
||||
{ label: 'تحویل شده', value: 'delivered', color: 'text-green-700 bg-green-50 border-green-200' },
|
||||
{ label: 'لغو شده', value: 'cancelled', color: 'text-red-700 bg-red-50 border-red-200' },
|
||||
@@ -439,24 +460,38 @@ export default function Orders() {
|
||||
orders.map((order) => {
|
||||
const isProcessing = processingId === order.id;
|
||||
const displayCode = order.trackingNumber || order.id.slice(0, 8);
|
||||
const orderDate = new Date(order.createdAt || order.date);
|
||||
const orderDate = new Date(order.createdAt || order.date || 0);
|
||||
const customerName = order.user ? `${order.user.firstName || ''} ${order.user.lastName || ''}`.trim() : 'کاربر مهمان';
|
||||
const itemsCount = (order.orderItems || order.items || []).length;
|
||||
const totalAmt = Number(order.totalAmount || order.total || 0);
|
||||
const payInfo = getPaymentMethodLabel(order.paymentMethod);
|
||||
const charityAmt = Number(order.charityDonation || 0);
|
||||
|
||||
return (
|
||||
<tr key={order.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-4 px-6 font-bold text-purple-600 font-mono" dir="ltr">
|
||||
<div>{toPersianDigits(displayCode)}</div>
|
||||
{order.isRefill && (
|
||||
<span className="inline-block mt-1 text-[9px] font-black px-2 py-0.5 rounded-full bg-green-50 text-green-700 border border-green-200">
|
||||
Refill 5%
|
||||
<div className="flex flex-wrap gap-1 mt-1.5" dir="rtl">
|
||||
<span className={`text-[9px] font-black px-2 py-0.5 rounded-md border flex items-center gap-1 ${payInfo.color}`}>
|
||||
<CreditCard className="w-2.5 h-2.5" />
|
||||
{payInfo.label}
|
||||
</span>
|
||||
)}
|
||||
{order.isRefill && (
|
||||
<span className="text-[9px] font-black px-2 py-0.5 rounded-md bg-emerald-50 text-emerald-700 border border-emerald-200">
|
||||
تمدید ۵٪-
|
||||
</span>
|
||||
)}
|
||||
{charityAmt > 0 && (
|
||||
<span className="text-[9px] font-black px-2 py-0.5 rounded-md bg-rose-50 text-rose-700 border border-rose-200 flex items-center gap-1">
|
||||
<Heart className="w-2.5 h-2.5 fill-rose-500 text-rose-500" />
|
||||
مهربانی: {toPersianDigits(charityAmt.toLocaleString())} ت
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
<div className="font-bold text-gray-900">{customerName}</div>
|
||||
<div className="text-xs text-gray-400 font-medium" dir="ltr">{toPersianDigits(order.user?.phone || '')}</div>
|
||||
<div className="text-xs text-gray-400 font-medium" dir="ltr">{toPersianDigits(order.user?.phone || order.user?.mobile || '')}</div>
|
||||
</td>
|
||||
<td className="py-4 px-6 font-black text-gray-900">
|
||||
{toPersianDigits(totalAmt.toLocaleString())} <span className="text-xs font-normal">تومان</span>
|
||||
@@ -477,6 +512,7 @@ export default function Orders() {
|
||||
>
|
||||
<option value="pending_payment">در انتظار پرداخت / ناموفق</option>
|
||||
<option value="processing">در حال پردازش</option>
|
||||
<option value="packaged">بستهبندی شده (آماده ارسال)</option>
|
||||
<option value="shipped">ارسال شده</option>
|
||||
<option value="delivered">تحویل داده شده</option>
|
||||
<option value="cancelled">لغو شده</option>
|
||||
@@ -590,6 +626,7 @@ export default function Orders() {
|
||||
>
|
||||
<option value="pending_payment">در انتظار پرداخت / ناموفق</option>
|
||||
<option value="processing">در حال پردازش</option>
|
||||
<option value="packaged">بستهبندی شده (آماده ارسال)</option>
|
||||
<option value="shipped">ارسال شده</option>
|
||||
<option value="delivered">تحویل داده شده</option>
|
||||
<option value="cancelled">لغو شده</option>
|
||||
|
||||
Reference in new issue
Block a user