source: src/sections/invoice/invoice-table-toolbar.tsx@ 057453c

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

feat: implement employees

  • Property mode set to 100644
File size: 5.1 KB
Line 
1import { useCallback } from 'react';
2// @mui
3import { DatePicker } from '@mui/x-date-pickers/DatePicker';
4import Stack from '@mui/material/Stack';
5import MenuItem from '@mui/material/MenuItem';
6import TextField from '@mui/material/TextField';
7import InputAdornment from '@mui/material/InputAdornment';
8// types
9import { InvoiceTableFilters, InvoiceTableFilterValue } from 'src/schemas';
10// components
11import Iconify from 'src/components/iconify';
12import CustomPopover, { usePopover } from 'src/components/custom-popover';
13
14// ----------------------------------------------------------------------
15
16type Props = {
17 filters: InvoiceTableFilters;
18 onFilters: (name: string, value: InvoiceTableFilterValue) => void;
19 //
20 dateError: boolean;
21 serviceOptions: string[];
22};
23
24export default function InvoiceTableToolbar({
25 filters,
26 onFilters,
27 //
28 dateError,
29 serviceOptions,
30}: Props) {
31 const popover = usePopover();
32
33 const handleFilterName = useCallback(
34 (event: React.ChangeEvent<HTMLInputElement>) => {
35 onFilters('name', event.target.value);
36 },
37 [onFilters]
38 );
39
40 // const handleFilterService = useCallback(
41 // (event: SelectChangeEvent<string[]>) => {
42 // onFilters(
43 // 'service',
44 // typeof event.target.value === 'string' ? event.target.value.split(',') : event.target.value
45 // );
46 // },
47 // [onFilters]
48 // );
49
50 const handleFilterStartDate = useCallback(
51 (newValue: Date | null) => {
52 onFilters('startDate', newValue);
53 },
54 [onFilters]
55 );
56
57 const handleFilterEndDate = useCallback(
58 (newValue: Date | null) => {
59 onFilters('endDate', newValue);
60 },
61 [onFilters]
62 );
63
64 return (
65 <>
66 <Stack
67 spacing={2}
68 alignItems={{ xs: 'flex-end', md: 'center' }}
69 direction={{
70 xs: 'column',
71 md: 'row',
72 }}
73 sx={{
74 p: 2.5,
75 pr: { xs: 2.5, md: 1 },
76 }}
77 >
78 {/* <FormControl
79 sx={{
80 flexShrink: 0,
81 width: { xs: 1, md: 180 },
82 }}
83 >
84 <InputLabel>Service</InputLabel>
85
86 <Select
87 multiple
88 value={filters.service}
89 onChange={handleFilterService}
90 input={<OutlinedInput label="Service" />}
91 renderValue={(selected) => selected.map((value) => value).join(', ')}
92 sx={{ textTransform: 'capitalize' }}
93 >
94 {serviceOptions.map((option) => (
95 <MenuItem key={option} value={option}>
96 <Checkbox disableRipple size="small" checked={filters.service.includes(option)} />
97 {option}
98 </MenuItem>
99 ))}
100 </Select>
101 </FormControl> */}
102
103 <TextField
104 fullWidth
105 value={filters.name}
106 onChange={handleFilterName}
107 placeholder="Search customer or invoice number..."
108 InputProps={{
109 startAdornment: (
110 <InputAdornment position="start">
111 <Iconify icon="eva:search-fill" sx={{ color: 'text.disabled' }} />
112 </InputAdornment>
113 ),
114 }}
115 />
116
117 <DatePicker
118 label="Start date"
119 value={filters.startDate}
120 onChange={handleFilterStartDate}
121 slotProps={{ textField: { fullWidth: true } }}
122 sx={{
123 maxWidth: { md: 180 },
124 }}
125 />
126
127 <DatePicker
128 label="End date"
129 value={filters.endDate}
130 onChange={handleFilterEndDate}
131 slotProps={{
132 textField: {
133 fullWidth: true,
134 error: dateError,
135 },
136 }}
137 sx={{
138 maxWidth: { md: 180 },
139 }}
140 />
141
142 {/* <Stack direction="row" alignItems="center" spacing={2} flexGrow={1} sx={{ width: 1 }}>
143 <TextField
144 fullWidth
145 value={filters.name}
146 onChange={handleFilterName}
147 placeholder="Search customer or invoice number..."
148 InputProps={{
149 startAdornment: (
150 <InputAdornment position="start">
151 <Iconify icon="eva:search-fill" sx={{ color: 'text.disabled' }} />
152 </InputAdornment>
153 ),
154 }}
155 />
156
157 <IconButton onClick={popover.onOpen}>
158 <Iconify icon="eva:more-vertical-fill" />
159 </IconButton>
160 </Stack> */}
161 </Stack>
162
163 <CustomPopover
164 open={popover.open}
165 onClose={popover.onClose}
166 arrow="right-top"
167 sx={{ width: 140 }}
168 >
169 <MenuItem
170 onClick={() => {
171 popover.onClose();
172 }}
173 >
174 <Iconify icon="solar:printer-minimalistic-bold" />
175 Print
176 </MenuItem>
177
178 <MenuItem
179 onClick={() => {
180 popover.onClose();
181 }}
182 >
183 <Iconify icon="solar:import-bold" />
184 Import
185 </MenuItem>
186
187 <MenuItem
188 onClick={() => {
189 popover.onClose();
190 }}
191 >
192 <Iconify icon="solar:export-bold" />
193 Export
194 </MenuItem>
195 </CustomPopover>
196 </>
197 );
198}
Note: See TracBrowser for help on using the repository browser.