source: src/sections/client/customer-table-filters-result.tsx

main
Last change on this file was 87c9f1e, checked in by Naum Shapkarovski <naumshapkarovski@…>, 6 weeks ago

update the seed script. update the prisma schema, use mapping

  • Property mode set to 100644
File size: 2.6 KB
Line 
1// @mui
2import Box from '@mui/material/Box';
3import Chip from '@mui/material/Chip';
4import Paper from '@mui/material/Paper';
5import Button from '@mui/material/Button';
6import Stack, { StackProps } from '@mui/material/Stack';
7// types
8
9// components
10import Iconify from 'src/components/iconify';
11import { CustomerTableFilterValue, CustomerTableFilters } from 'src/schemas';
12
13// ----------------------------------------------------------------------
14
15type Props = StackProps & {
16 filters: CustomerTableFilters;
17 onFilters: (name: string, value: CustomerTableFilterValue) => void;
18 //
19 onResetFilters: VoidFunction;
20 //
21 results: number;
22};
23
24export default function CustomerTableFiltersResult({
25 filters,
26 onFilters,
27 //
28 onResetFilters,
29 //
30 results,
31 ...other
32}: Props) {
33 const handleRemoveStatus = () => {
34 onFilters('status', 'all');
35 };
36
37 const handleRemoveRole = (inputValue: string) => {
38 const newValue = filters.role.filter((item) => item !== inputValue);
39 onFilters('role', newValue);
40 };
41
42 return (
43 <Stack spacing={1.5} {...other}>
44 <Box sx={{ typography: 'body2' }}>
45 <strong>{results}</strong>
46 <Box component="span" sx={{ color: 'text.secondary', ml: 0.25 }}>
47 results found
48 </Box>
49 </Box>
50
51 <Stack flexGrow={1} spacing={1} direction="row" flexWrap="wrap" alignItems="center">
52 {filters.status !== 'all' && (
53 <Block label="Status:">
54 <Chip size="small" label={filters.status} onDelete={handleRemoveStatus} />
55 </Block>
56 )}
57
58 {!!filters.role.length && (
59 <Block label="Role:">
60 {filters.role.map((item) => (
61 <Chip key={item} label={item} size="small" onDelete={() => handleRemoveRole(item)} />
62 ))}
63 </Block>
64 )}
65
66 <Button
67 color="error"
68 onClick={onResetFilters}
69 startIcon={<Iconify icon="solar:trash-bin-trash-bold" />}
70 >
71 Clear
72 </Button>
73 </Stack>
74 </Stack>
75 );
76}
77
78// ----------------------------------------------------------------------
79
80type BlockProps = StackProps & {
81 label: string;
82};
83
84function Block({ label, children, sx, ...other }: BlockProps) {
85 return (
86 <Stack
87 component={Paper}
88 variant="outlined"
89 spacing={1}
90 direction="row"
91 sx={{
92 p: 1,
93 borderRadius: 1,
94 overflow: 'hidden',
95 borderStyle: 'dashed',
96 ...sx,
97 }}
98 {...other}
99 >
100 <Box component="span" sx={{ typography: 'subtitle2' }}>
101 {label}
102 </Box>
103
104 <Stack spacing={1} direction="row" flexWrap="wrap">
105 {children}
106 </Stack>
107 </Stack>
108 );
109}
Note: See TracBrowser for help on using the repository browser.