feat: add document sharing functionality across various modules

- Introduced ShareDocumentButton component for sharing documents.
- Added ShareDocumentDialog for email and WhatsApp sharing options.
- Integrated document sharing in estimates, invoices, inspections, job cards, bills, and purchase orders.
- Implemented useDocumentShare hook for handling share logic.
- Created DocumentShareClient for API interactions related to document sharing.
- Updated layouts and actions to include sharing options for relevant entities.
This commit is contained in:
2026-05-14 12:21:01 +04:00
parent 05b55b5721
commit fcbba6247d
22 changed files with 571 additions and 60 deletions
@@ -5,6 +5,7 @@ import { InvoiceProvider } from '@/modules/invoices/invoice-context'
import { ReceiptIcon } from 'lucide-react'
import React from 'react'
import InvoiceStatusBadge from '@/modules/invoices/invoice-status-badge'
import { ShareDocumentButton } from '@/shared/components/share-document-button'
export default async function InvoiceDetailLayout(props: { params: Promise<{ id: string }>, children: React.ReactNode }) {
const { id } = await props.params
@@ -24,6 +25,7 @@ export default async function InvoiceDetailLayout(props: { params: Promise<{ id:
<div className="flex space-x-2 items-center">
<InvoiceStatusBadge invoice={{id, status:data?.status}} />
<ShareDocumentButton type="invoice" id={id} />
<InvoiceActions invoiceId={id} />
</div>
}
@@ -138,7 +138,7 @@ export default function InvoicesPage() {
cell: ({ row }) => {
const item = row.original as unknown as InvoiceItem
const customerLabel = getCustomerLabel(item)
const subline = item.customer?.phone || item.customer?.company_name || "—"
const phone = item.customer?.phone
return (
<div className="min-w-[190px]">
@@ -146,12 +146,19 @@ export default function InvoicesPage() {
<Button variant="outline" asChild size="sm" onClick={(e) => e.stopPropagation()}>
<Link href={`/sales/customers/${item.customer.id}`}>
<UserIcon /> {customerLabel}
{phone && (
<span className="ms-1 text-muted-foreground">· {phone}</span>
)}
</Link>
</Button>
) : (
<p className="font-medium leading-none">{customerLabel}</p>
<p className="font-medium leading-none">
{customerLabel}
{phone && (
<span className="ms-1 text-muted-foreground">· {phone}</span>
)}
</p>
)}
<p className="mt-1 text-xs text-muted-foreground">{subline}</p>
</div>
)
},