feat: save pdf as file
This commit is contained in:
@@ -12,6 +12,8 @@ import ShippingWarehouseAutocomplete
|
||||
import {ButtonCopyControlled} from "../../../../../components/ButtonCopyControlled/ButtonCopyControlled.tsx";
|
||||
import {useClipboard} from "@mantine/hooks";
|
||||
import ButtonCopy from "../../../../../components/ButtonCopy/ButtonCopy.tsx";
|
||||
import FileSaver from "file-saver";
|
||||
import {getCurrentDateTimeForFilename} from "../../../../../shared/lib/date.ts";
|
||||
|
||||
type Props = {
|
||||
deal: DealSchema
|
||||
@@ -166,12 +168,20 @@ const Content: FC<Props> = ({deal}) => {
|
||||
Ссылка на оплату
|
||||
</ButtonCopy>
|
||||
:
|
||||
<ButtonCopy
|
||||
value={`${import.meta.env.VITE_API_URL}/deal/document/${deal.id}`}
|
||||
<ButtonCopyControlled
|
||||
onCopyClick={() => {
|
||||
// get current datetime for filename, replaced dots with _
|
||||
const date = getCurrentDateTimeForFilename();
|
||||
|
||||
|
||||
FileSaver.saveAs(`${import.meta.env.VITE_API_URL}/deal/document/${deal.id}`,
|
||||
`bill_${deal.id}_${date}.pdf`);
|
||||
}}
|
||||
copied={false}
|
||||
onCopiedLabel={"Ссылка скопирована в буфер обмена"}
|
||||
>
|
||||
Ссылка на оплату (PDF)
|
||||
</ButtonCopy>
|
||||
</ButtonCopyControlled>
|
||||
}
|
||||
<ButtonCopyControlled
|
||||
onCopyClick={onCopyGuestUrlClick}
|
||||
|
||||
Reference in New Issue
Block a user