import { useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { Box, Card, Stack, Button, Typography, Chip, Divider, IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Grid, Dialog, DialogTitle, DialogContent, DialogActions, TextField } from '@mui/material'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import PrintOutlinedIcon from '@mui/icons-material/PrintOutlined'; import PaymentsOutlinedIcon from '@mui/icons-material/PaymentsOutlined'; import PageHeader from '@/components/PageHeader'; import Logo from '@/components/Logo'; import { invoices, invoiceLineItems, tenants } from '@/data/mock'; import { inr } from '@/utils/format'; export default function InvoicePreview() { const navigate = useNavigate(); const { id } = useParams(); const [payOpen, setPayOpen] = useState(false); const invoice = invoices.find((i) => String(i.id) === String(id)) || invoices[0]; const tenant = tenants[0]; const subTotal = invoiceLineItems.reduce((a, l) => a + l.amount, 0); const discount = Math.round(subTotal * 0.05); const taxable = subTotal - discount; const tax = Math.round(taxable * 0.18); const grandTotal = taxable + tax; return ( <> navigate('/invoice')} sx={{ border: 1, borderColor: 'grey.300' }}> } /> {/* Top band */} From Doormile Logistics Pvt. Ltd. No. 7, Brigade Road Bengaluru, Karnataka 560001 GSTIN: 29ABCDE1234F1Z5 billing@doormile.in INVOICE To {tenant.name} {tenant.contact} {tenant.address} {tenant.city} {tenant.postcode} {tenant.email} {/* Invoice meta */} Invoice No {invoice.invoiceId} Date {invoice.invoiceDate} Due Date {invoice.dueDate} Period {invoice.period} {/* Line items */} S.No Particulars Unit Quantity Rate Other Charges Amount {invoiceLineItems.map((l, idx) => ( {idx + 1} {l.particulars} {l.unit} {l.qty} {inr(l.rate)} {inr(l.other)} {inr(l.amount)} ))}
{/* Totals */} Sub Total {inr(subTotal)} Discount (5%) - {inr(discount)} Tax (18% GST) {inr(tax)} Grand Total {inr(grandTotal)} {/* Notes + accent */} Notes & Terms Payment is due within 15 days of the invoice date. Please make payments via NEFT/RTGS to the registered account. A 1.5% monthly interest applies to overdue balances. This is a computer-generated invoice and does not require a signature.
{/* Update Payment Dialog */} setPayOpen(false)} maxWidth="xs" fullWidth> Update Payment ); }