Add promotion details and modal to orders and promotions
Introduces promotion-related fields to the Order interface and displays promotion discounts in both the order details and order table. Adds a PromotionDetailsModal component for viewing detailed promotion analytics and eligibility, and integrates it into the PromotionsList with a new 'view details' action.
This commit is contained in:
@@ -28,7 +28,9 @@ import {
|
||||
ArrowUpDown,
|
||||
Truck,
|
||||
MessageCircle,
|
||||
AlertTriangle
|
||||
AlertTriangle,
|
||||
Tag,
|
||||
Percent
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { clientFetch } from '@/lib/api';
|
||||
@@ -60,6 +62,11 @@ interface Order {
|
||||
underpaymentAmount?: number;
|
||||
lastBalanceReceived?: number;
|
||||
cryptoTotal?: number;
|
||||
// Promotion fields
|
||||
promotion?: string;
|
||||
promotionCode?: string;
|
||||
discountAmount?: number;
|
||||
subtotalBeforeDiscount?: number;
|
||||
}
|
||||
|
||||
type SortableColumns = "orderId" | "totalPrice" | "status" | "orderDate" | "paidAt";
|
||||
@@ -430,6 +437,7 @@ export default function OrderTable() {
|
||||
<TableHead className="cursor-pointer" onClick={() => handleSort("totalPrice")}>
|
||||
Total <ArrowUpDown className="ml-2 inline h-4 w-4" />
|
||||
</TableHead>
|
||||
<TableHead>Promotion</TableHead>
|
||||
<TableHead className="cursor-pointer" onClick={() => handleSort("status")}>
|
||||
Status <ArrowUpDown className="ml-2 inline h-4 w-4" />
|
||||
</TableHead>
|
||||
@@ -468,6 +476,29 @@ export default function OrderTable() {
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{order.promotionCode ? (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-1">
|
||||
<Tag className="h-3 w-3 text-green-500" />
|
||||
<span className="text-xs font-mono bg-green-100 text-green-800 px-2 py-0.5 rounded">
|
||||
{order.promotionCode}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 text-xs text-green-600">
|
||||
<Percent className="h-3 w-3" />
|
||||
<span>-£{(order.discountAmount || 0).toFixed(2)}</span>
|
||||
{order.subtotalBeforeDiscount && order.subtotalBeforeDiscount > 0 && (
|
||||
<span className="text-muted-foreground">
|
||||
(was £{order.subtotalBeforeDiscount.toFixed(2)})
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">-</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className={`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm ${
|
||||
|
||||
Reference in New Issue
Block a user