source: src/sections/invoice/invoice-toolbar.tsx@ 5d6f37a

main
Last change on this file since 5d6f37a was 5d6f37a, checked in by Naum Shapkarovski <naumshapkarovski@…>, 7 weeks ago

add customer

  • Property mode set to 100644
File size: 4.3 KB
Line 
1import { useCallback } from 'react';
2import { PDFDownloadLink, PDFViewer } from '@react-pdf/renderer';
3// @mui
4import Box from '@mui/material/Box';
5import Stack from '@mui/material/Stack';
6import Button from '@mui/material/Button';
7import Dialog from '@mui/material/Dialog';
8import Tooltip from '@mui/material/Tooltip';
9import MenuItem from '@mui/material/MenuItem';
10import TextField from '@mui/material/TextField';
11import IconButton from '@mui/material/IconButton';
12import DialogActions from '@mui/material/DialogActions';
13import CircularProgress from '@mui/material/CircularProgress';
14// routes
15import { paths } from 'src/routes/paths';
16import { useRouter } from 'src/routes/hooks';
17// hooks
18import { useBoolean } from 'src/hooks/use-boolean';
19// types
20import { Invoice } from 'mvpmasters-shared';
21// components
22import Iconify from 'src/components/iconify';
23import InvoicePDF from './invoice-pdf';
24
25// ----------------------------------------------------------------------
26
27type Props = {
28 invoice: Invoice;
29 currentStatus: string;
30 onChangeStatus: (event: React.ChangeEvent<HTMLInputElement>) => void;
31 statusOptions: {
32 value: string;
33 label: string;
34 }[];
35};
36
37export default function InvoiceToolbar({
38 invoice,
39 currentStatus,
40 statusOptions,
41 onChangeStatus,
42}: Props) {
43 const router = useRouter();
44
45 const view = useBoolean();
46
47 const handleEdit = useCallback(() => {
48 router.push(paths.dashboard.invoice.edit(invoice.id));
49 }, [invoice.id, router]);
50
51 return (
52 <>
53 <Stack
54 spacing={3}
55 direction={{ xs: 'column', sm: 'row' }}
56 alignItems={{ xs: 'flex-end', sm: 'center' }}
57 sx={{ mb: { xs: 3, md: 5 } }}
58 >
59 <Stack direction="row" spacing={1} flexGrow={1} sx={{ width: 1 }}>
60 <Tooltip title="Edit">
61 <IconButton disabled={currentStatus === 'processing'} onClick={handleEdit}>
62 <Iconify icon="solar:pen-bold" />
63 </IconButton>
64 </Tooltip>
65
66 <Tooltip title="View">
67 <IconButton onClick={view.onTrue}>
68 <Iconify icon="solar:eye-bold" />
69 </IconButton>
70 </Tooltip>
71
72 <PDFDownloadLink
73 document={<InvoicePDF invoice={invoice} currentStatus={currentStatus} />}
74 fileName={invoice.invoiceNumber}
75 style={{ textDecoration: 'none' }}
76 >
77 {({ loading }) => (
78 <Tooltip title="Download">
79 <IconButton>
80 {loading ? (
81 <CircularProgress size={24} color="inherit" />
82 ) : (
83 <Iconify icon="eva:cloud-download-fill" />
84 )}
85 </IconButton>
86 </Tooltip>
87 )}
88 </PDFDownloadLink>
89
90 {/* <Tooltip title="Print">
91 <IconButton>
92 <Iconify icon="solar:printer-minimalistic-bold" />
93 </IconButton>
94 </Tooltip>
95
96 <Tooltip title="Send">
97 <IconButton>
98 <Iconify icon="iconamoon:send-fill" />
99 </IconButton>
100 </Tooltip>
101
102 <Tooltip title="Share">
103 <IconButton>
104 <Iconify icon="solar:share-bold" />
105 </IconButton>
106 </Tooltip> */}
107 </Stack>
108
109 <TextField
110 fullWidth
111 select
112 label="Status"
113 value={currentStatus}
114 onChange={onChangeStatus}
115 sx={{
116 maxWidth: 160,
117 }}
118 disabled={currentStatus === 'processing'}
119 >
120 {statusOptions.map((option) => (
121 <MenuItem key={option.value} value={option.value}>
122 {option.label}
123 </MenuItem>
124 ))}
125 </TextField>
126 </Stack>
127
128 <Dialog fullScreen open={view.value}>
129 <Box sx={{ height: 1, display: 'flex', flexDirection: 'column' }}>
130 <DialogActions
131 sx={{
132 p: 1.5,
133 }}
134 >
135 <Button color="inherit" variant="contained" onClick={view.onFalse}>
136 Close
137 </Button>
138 </DialogActions>
139
140 <Box sx={{ flexGrow: 1, height: 1, overflow: 'hidden' }}>
141 <PDFViewer width="100%" height="100%" style={{ border: 'none' }}>
142 <InvoicePDF invoice={invoice} currentStatus={currentStatus} />
143 </PDFViewer>
144 </Box>
145 </Box>
146 </Dialog>
147 </>
148 );
149}
Note: See TracBrowser for help on using the repository browser.