feat(orders): add mark filter (free text) and update UI layout
This commit is contained in:
parent
cd89dff9fa
commit
4d2e6e4859
|
|
@ -57,6 +57,7 @@ interface LocalFilters {
|
|||
sellerName: string | null;
|
||||
deliveryType: string[] | null;
|
||||
statusTransfer: string[] | null;
|
||||
markName: string | null;
|
||||
}
|
||||
|
||||
const DELIVERY_TYPES = ['RI', 'EN', 'EF', 'RP'];
|
||||
|
|
@ -81,6 +82,7 @@ const getInitialLocalFilters = (
|
|||
sellerName: urlFilters.sellerName ?? null,
|
||||
deliveryType: urlFilters.deliveryType ?? null,
|
||||
statusTransfer: urlFilters.statusTransfer ?? null,
|
||||
markName: urlFilters.markName ?? null,
|
||||
});
|
||||
|
||||
export const SearchBar = () => {
|
||||
|
|
@ -144,6 +146,7 @@ export const SearchBar = () => {
|
|||
productName: null,
|
||||
deliveryType: null,
|
||||
statusTransfer: null,
|
||||
markName: null,
|
||||
};
|
||||
|
||||
setLocalFilters(getInitialLocalFilters(resetState));
|
||||
|
|
@ -210,6 +213,7 @@ export const SearchBar = () => {
|
|||
localFilters.productId,
|
||||
localFilters.deliveryType?.length,
|
||||
localFilters.statusTransfer?.length,
|
||||
localFilters.markName,
|
||||
].filter(Boolean).length;
|
||||
|
||||
const toggleDrawer = (open: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
|
||||
|
|
@ -311,6 +315,19 @@ export const SearchBar = () => {
|
|||
Limpar
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
size="small"
|
||||
onClick={handleFilter}
|
||||
disabled={!isDateValid || !!dateError || isFetching}
|
||||
startIcon={isFetching ? <CircularProgress size={16} color="inherit" /> : <SearchIcon />}
|
||||
fullWidth
|
||||
sx={{ textTransform: 'none', minWidth: { xs: '100%', sm: 100 } }}
|
||||
>
|
||||
Buscar
|
||||
</Button>
|
||||
|
||||
<Badge badgeContent={activeDrawerFiltersCount} color="primary" sx={{ width: { xs: '100%', sm: 'auto' } }}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
|
|
@ -324,19 +341,6 @@ export const SearchBar = () => {
|
|||
Filtros
|
||||
</Button>
|
||||
</Badge>
|
||||
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
size="small"
|
||||
onClick={handleFilter}
|
||||
disabled={!isDateValid || !!dateError || isFetching}
|
||||
startIcon={isFetching ? <CircularProgress size={16} color="inherit" /> : <SearchIcon />}
|
||||
fullWidth
|
||||
sx={{ textTransform: 'none', minWidth: { xs: '100%', sm: 100 } }}
|
||||
>
|
||||
Buscar
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
|
@ -430,8 +434,17 @@ export const SearchBar = () => {
|
|||
updateLocalFilter('sellerId', newValue?.seller.id.toString() || null);
|
||||
updateLocalFilter('sellerName', newValue?.seller.name || null);
|
||||
}}
|
||||
isOptionEqualToValue={(option, value) => option.value === value.value}
|
||||
loading={sellers.isLoading}
|
||||
renderInput={(params) => <TextField {...params} label="Vendedor" placeholder="Selecione vendedor" />}
|
||||
renderOption={(props, option) => {
|
||||
const { key, ...restProps } = props;
|
||||
return (
|
||||
<li key={option.id} {...restProps}>
|
||||
{option.label}
|
||||
</li>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Parceiro */}
|
||||
|
|
@ -468,6 +481,16 @@ export const SearchBar = () => {
|
|||
filterOptions={(x) => x}
|
||||
/>
|
||||
|
||||
{/* Marca */}
|
||||
<Autocomplete
|
||||
freeSolo
|
||||
size="small"
|
||||
options={[]}
|
||||
value={localFilters.markName ?? ''}
|
||||
onInputChange={(_, newValue) => updateLocalFilter('markName', newValue || null)}
|
||||
renderInput={(params) => <TextField {...params} label="Marca" placeholder="Digite a marca..." />}
|
||||
/>
|
||||
|
||||
{/* Tipo de Entrega */}
|
||||
<Autocomplete
|
||||
multiple
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export const useOrderFilters = () => {
|
|||
searchTriggered: parseAsBoolean.withDefault(false),
|
||||
deliveryType: parseAsArrayOf(parseAsString, ','),
|
||||
statusTransfer: parseAsArrayOf(parseAsString, ','),
|
||||
markName: parseAsString,
|
||||
},
|
||||
{
|
||||
shallow: true,
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ export const orderApiParamsSchema = findOrdersSchema
|
|||
|
||||
if (filters.partnerId) queryParams.partnerId = filters.partnerId;
|
||||
if (filters.productId) queryParams.productId = filters.productId;
|
||||
if (filters.markName) queryParams.markName = filters.markName;
|
||||
|
||||
return queryParams;
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue