- 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.
29 lines
902 B
TypeScript
29 lines
902 B
TypeScript
"use client"
|
|
|
|
import { useState } from "react"
|
|
import { Share2 } from "lucide-react"
|
|
import type { DocumentShareType } from "@garage/api"
|
|
import { Button } from "@/shared/components/ui/button"
|
|
import { ShareDocumentDialog } from "@/shared/components/share-document-dialog"
|
|
|
|
interface ShareDocumentButtonProps {
|
|
type: DocumentShareType
|
|
id: string | number
|
|
label?: string
|
|
variant?: "default" | "outline" | "ghost" | "secondary"
|
|
}
|
|
|
|
export function ShareDocumentButton({ type, id, label = "Share", variant = "outline" }: ShareDocumentButtonProps) {
|
|
const [open, setOpen] = useState(false)
|
|
|
|
return (
|
|
<>
|
|
<Button variant={variant} onClick={() => setOpen(true)}>
|
|
<Share2 className="size-4" />
|
|
{label}
|
|
</Button>
|
|
<ShareDocumentDialog type={type} id={id} open={open} onOpenChange={setOpen} />
|
|
</>
|
|
)
|
|
}
|