feat(orders): add Print Invoice action with standard GST and thermal format options
This commit is contained in:
parent
97edf25b26
commit
5ebac5126b
1 changed files with 66 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
FileText,
|
||||
User,
|
||||
MapPin,
|
||||
ChevronDown,
|
||||
} from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
import { format } from 'date-fns';
|
||||
|
|
@ -69,6 +70,8 @@ interface AdminOrderDetailResponse {
|
|||
package_weight?: number | null;
|
||||
logistics_provider?: string | null;
|
||||
pickup_scheduled?: boolean;
|
||||
invoice_id?: string | null;
|
||||
invoice_no?: string | null;
|
||||
created_at: string;
|
||||
items: OrderItemDetail[];
|
||||
history: StatusHistorySchema[];
|
||||
|
|
@ -188,6 +191,7 @@ export default function OrderIntelligencePage() {
|
|||
const [courier, setCourier] = useState('');
|
||||
const [changeReason, setChangeReason] = useState('');
|
||||
const [updating, setUpdating] = useState(false);
|
||||
const [showInvoiceMenu, setShowInvoiceMenu] = useState(false);
|
||||
|
||||
const [showCreateOrderModal, setShowCreateOrderModal] = useState(false);
|
||||
const [buyerName, setBuyerName] = useState('');
|
||||
|
|
@ -1097,16 +1101,77 @@ export default function OrderIntelligencePage() {
|
|||
🏷️ Discounted Order
|
||||
</span>
|
||||
)}
|
||||
{detailData.invoice_no && (
|
||||
<span className="inline-flex items-center px-2.5 py-1 crm-radius-badge text-[11px] font-mono font-semibold bg-primary/10 text-primary border border-primary/20">
|
||||
📄 {detailData.invoice_no}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{!showStatusForm && (
|
||||
<div className="flex items-center gap-2">
|
||||
{/* Print Invoice with Dropdown */}
|
||||
<div className="relative inline-flex items-center shadow-sm">
|
||||
<a
|
||||
href={`${API_BASE_URL}/api/v1/admin/orders/${detailData.order_id}/invoice?format=standard`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-emerald-600 hover:bg-emerald-700 text-white rounded-l crm-radius-button-l text-[12px] font-semibold transition-colors"
|
||||
title="Print Standard GST Tax Invoice (Letter / A4)"
|
||||
>
|
||||
<FileText className="w-3.5 h-3.5" />
|
||||
Print Invoice
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowInvoiceMenu((prev) => !prev)}
|
||||
className="px-1.5 py-1.5 bg-emerald-700 hover:bg-emerald-800 text-white rounded-r border-l border-emerald-500/40 text-[12px] transition-colors"
|
||||
title="Choose Invoice Format"
|
||||
>
|
||||
<ChevronDown className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
|
||||
{showInvoiceMenu && (
|
||||
<div
|
||||
className="absolute right-0 top-full mt-1 w-52 bg-popover border border-border rounded-md shadow-xl py-1 z-50 text-[12px]"
|
||||
onMouseLeave={() => setShowInvoiceMenu(false)}
|
||||
>
|
||||
<a
|
||||
href={`${API_BASE_URL}/api/v1/admin/orders/${detailData.order_id}/invoice?format=standard`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={() => setShowInvoiceMenu(false)}
|
||||
className="flex items-center gap-2 px-3 py-2 text-foreground hover:bg-muted transition-colors"
|
||||
>
|
||||
<FileText className="w-4 h-4 text-emerald-600" />
|
||||
<div>
|
||||
<div className="font-medium">Standard GST Invoice</div>
|
||||
<div className="text-[10px] text-muted-foreground">Letter / A4 PDF document</div>
|
||||
</div>
|
||||
</a>
|
||||
<a
|
||||
href={`${API_BASE_URL}/api/v1/admin/orders/${detailData.order_id}/invoice?format=thermal`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={() => setShowInvoiceMenu(false)}
|
||||
className="flex items-center gap-2 px-3 py-2 text-foreground hover:bg-muted transition-colors border-t border-border/50"
|
||||
>
|
||||
<Printer className="w-4 h-4 text-amber-500" />
|
||||
<div>
|
||||
<div className="font-medium">Thermal Receipt</div>
|
||||
<div className="text-[10px] text-muted-foreground">80mm POS receipt roll</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{detailData.shipping_label_url && (
|
||||
<a
|
||||
href={detailData.shipping_label_url.startsWith('http') ? detailData.shipping_label_url : `${API_BASE_URL}${detailData.shipping_label_url}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-primary text-white crm-radius-button text-[12px] font-semibold hover:opacity-90 shadow-sm"
|
||||
className="inline-flex items-center gap-1.5 px-3 py-1.5 bg-primary text-white crm-radius-button text-[12px] font-semibold hover:opacity-90 shadow-sm transition-colors"
|
||||
>
|
||||
<Printer className="w-3.5 h-3.5" />
|
||||
Print Shipping Slip
|
||||
|
|
|
|||
Loading…
Reference in a new issue