chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s
Deploy Canina / deploy (push) Failing after 29s
This commit is contained in:
1 parent
4659a7b1de
commit
9f11d8fb2d
98 files changed
+1272
-1009
No files matched your search
@@ -1,46 +1,43 @@
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
"use client";
|
||||
import React from "react";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import {
|
||||
X,
|
||||
Printer,
|
||||
Download,
|
||||
Package,
|
||||
ShoppingBag,
|
||||
MapPin,
|
||||
Calendar,
|
||||
Clock,
|
||||
CreditCard,
|
||||
CheckCircle2,
|
||||
AlertCircle,
|
||||
Truck,
|
||||
Sparkles,
|
||||
Heart
|
||||
Truck
|
||||
} from "lucide-react";
|
||||
import { toPersian, cn } from "../lib/utils";
|
||||
import SafeImage from "./SafeImage";
|
||||
import { toPersian } from "../lib/utils";
|
||||
|
||||
interface OrderDetailsModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
order: any;
|
||||
order: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetailsModalProps) {
|
||||
if (!order) return null;
|
||||
|
||||
const getProductName = (p: any) => p?.nameFa || p?.name || p?.nameEn || 'محصول کانینا';
|
||||
const getProductImage = (p: any) => p?.imageUrl || p?.image || '/products/product-placeholder.png';
|
||||
const displayTrackingCode = order.trackingNumber || order.id?.substring(0, 8) || 'CN-0000';
|
||||
const getProductName = (p: Record<string, unknown> | undefined) => String(p?.nameFa || p?.name || p?.nameEn || 'محصول کانینا');
|
||||
const getProductImage = (p: Record<string, unknown> | undefined) => String(p?.imageUrl || p?.image || '/products/product-placeholder.png');
|
||||
const displayTrackingCode = String(order.trackingNumber || (typeof order.id === 'string' ? order.id.substring(0, 8) : '') || 'CN-0000');
|
||||
|
||||
const orderDate = new Date(order.date || order.createdAt);
|
||||
const rawDate = order.date || order.createdAt;
|
||||
const orderDate = rawDate ? new Date(String(rawDate)) : new Date();
|
||||
const formattedDate = orderDate.toLocaleDateString("fa-IR");
|
||||
const formattedTime = orderDate.toLocaleTimeString("fa-IR", { hour: '2-digit', minute: '2-digit' });
|
||||
|
||||
const items = order.items || order.orderItems || [];
|
||||
const itemsSubtotal = items.reduce((sum: number, item: any) => {
|
||||
const price = Number(item.product?.priceValue || item.priceValue || 0);
|
||||
return sum + price * (item.quantity || 1);
|
||||
const items = Array.isArray(order.items) ? (order.items as Record<string, unknown>[]) : (Array.isArray(order.orderItems) ? (order.orderItems as Record<string, unknown>[]) : []);
|
||||
const itemsSubtotal = items.reduce((sum: number, item: Record<string, unknown>) => {
|
||||
const prod = item.product as Record<string, unknown> | undefined;
|
||||
const price = Number(prod?.priceValue || item.priceValue || 0);
|
||||
return sum + price * Number(item.quantity || 1);
|
||||
}, 0);
|
||||
|
||||
const charityAmount = Number(order.charityDonation || 0);
|
||||
@@ -53,11 +50,12 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
|
||||
const printWindow = window.open('', '_blank');
|
||||
if (!printWindow) return;
|
||||
|
||||
const itemsHtml = items.map((item: any) => {
|
||||
const pName = getProductName(item.product);
|
||||
const pImg = getProductImage(item.product);
|
||||
const pPrice = Number(item.product?.priceValue || item.priceValue || 0);
|
||||
const rowTotal = pPrice * (item.quantity || 1);
|
||||
const itemsHtml = items.map((item: Record<string, unknown>) => {
|
||||
const prod = item.product as Record<string, unknown> | undefined;
|
||||
const pName = getProductName(prod);
|
||||
const pImg = getProductImage(prod);
|
||||
const pPrice = Number(prod?.priceValue || item.priceValue || 0);
|
||||
const rowTotal = pPrice * Number(item.quantity || 1);
|
||||
return `
|
||||
<tr>
|
||||
<td style="padding: 14px; border-bottom: 1px solid #e5e7eb; vertical-align: middle;">
|
||||
@@ -66,7 +64,7 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
|
||||
<span style="font-weight: 700; color: #111827;">${pName}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="padding: 14px; border-bottom: 1px solid #e5e7eb; text-align: center; font-weight: 700;">${toPersian(item.quantity)}</td>
|
||||
<td style="padding: 14px; border-bottom: 1px solid #e5e7eb; text-align: center; font-weight: 700;">${toPersian(Number(item.quantity || 1))}</td>
|
||||
<td style="padding: 14px; border-bottom: 1px solid #e5e7eb; text-align: left; font-weight: 700;">${toPersian(pPrice.toLocaleString())} تومان</td>
|
||||
<td style="padding: 14px; border-bottom: 1px solid #e5e7eb; text-align: left; font-weight: 900; color: #0055FF;">${toPersian(rowTotal.toLocaleString())} تومان</td>
|
||||
</tr>
|
||||
@@ -246,8 +244,8 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
|
||||
<div className="bg-medical-gray-50 p-4 rounded-2xl">
|
||||
<div className="text-[9px] font-black text-medical-gray-400 uppercase tracking-widest mb-1">وضعیت تحویل</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{getStatusIcon(order.status)}
|
||||
<span className="text-xs sm:text-sm font-black text-medical-gray-900">{getStatusLabel(order.status)}</span>
|
||||
{getStatusIcon(String(order.status || ''))}
|
||||
<span className="text-xs sm:text-sm font-black text-medical-gray-900">{getStatusLabel(String(order.status || ''))}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-medical-gray-50 p-4 rounded-2xl">
|
||||
@@ -270,13 +268,14 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
|
||||
سبد محصولات خریده شده
|
||||
</h4>
|
||||
<div className="space-y-3">
|
||||
{items.map((item: any, idx: number) => {
|
||||
const pName = getProductName(item.product);
|
||||
const pImg = getProductImage(item.product);
|
||||
const pPrice = Number(item.product?.priceValue || item.priceValue || 0);
|
||||
const itemQty = item.quantity || 1;
|
||||
{items.map((item: Record<string, unknown>, idx: number) => {
|
||||
const prod = item.product as Record<string, unknown> | undefined;
|
||||
const pName = getProductName(prod);
|
||||
const pImg = getProductImage(prod);
|
||||
const pPrice = Number(prod?.priceValue || item.priceValue || 0);
|
||||
const itemQty = Number(item.quantity || 1);
|
||||
return (
|
||||
<div key={item.product?.id || idx} className="flex items-center justify-between p-4 border border-medical-gray-100 rounded-2xl hover:border-canina-blue transition-all">
|
||||
<div key={String(prod?.id || idx)} className="flex items-center justify-between p-4 border border-medical-gray-100 rounded-2xl hover:border-canina-blue transition-all">
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="w-14 h-14 bg-medical-gray-50 rounded-xl p-1.5 flex items-center justify-center shrink-0 border border-medical-gray-200">
|
||||
<img
|
||||
@@ -286,12 +285,12 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h5 className="font-black text-medical-gray-900 text-xs sm:text-sm leading-tight mb-1">{pName}</h5>
|
||||
<div className="text-[11px] font-bold text-medical-gray-400">{toPersian(itemQty)} عدد × {toPersian(pPrice.toLocaleString())} تومان</div>
|
||||
<h5 className="font-black text-medical-gray-900 text-sm">{pName}</h5>
|
||||
<p className="text-xs text-medical-gray-400">{toPersian(itemQty)} عدد × {toPersian(pPrice.toLocaleString())} تومان</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<div className="text-base sm:text-lg font-black text-canina-blue italic">{toPersian((pPrice * itemQty).toLocaleString())} <span className="text-[10px] not-italic">تومان</span></div>
|
||||
<div className="text-left font-black text-canina-blue text-sm">
|
||||
{toPersian((pPrice * itemQty).toLocaleString())} تومان
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -307,7 +306,7 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
|
||||
اطلاعات ارسال
|
||||
</h4>
|
||||
<p className="text-xs font-bold text-medical-gray-600 leading-relaxed bg-medical-gray-50 p-4 rounded-2xl border border-medical-gray-100">
|
||||
{order.shippingAddress || "آدرس ثبتی کاربر در حساب کاربری"}
|
||||
{String(order.shippingAddress || "آدرس ثبتی کاربر در حساب کاربری")}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user