Merge pull request 'Feature: Filtro de Tipo de Entrega' (#3) from feature/delivery-type-filter into master
Reviewed-on: #3
This commit is contained in:
commit
ad36134655
|
|
@ -55,8 +55,11 @@ interface LocalFilters {
|
||||||
stockId: string[] | null;
|
stockId: string[] | null;
|
||||||
sellerId: string | null;
|
sellerId: string | null;
|
||||||
sellerName: string | null;
|
sellerName: string | null;
|
||||||
|
deliveryType: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DELIVERY_TYPES = ['RI', 'EN', 'EF', 'RP'];
|
||||||
|
|
||||||
const getInitialLocalFilters = (
|
const getInitialLocalFilters = (
|
||||||
urlFilters: Partial<LocalFilters>
|
urlFilters: Partial<LocalFilters>
|
||||||
): LocalFilters => ({
|
): LocalFilters => ({
|
||||||
|
|
@ -74,6 +77,7 @@ const getInitialLocalFilters = (
|
||||||
stockId: urlFilters.stockId ?? null,
|
stockId: urlFilters.stockId ?? null,
|
||||||
sellerId: urlFilters.sellerId ?? null,
|
sellerId: urlFilters.sellerId ?? null,
|
||||||
sellerName: urlFilters.sellerName ?? null,
|
sellerName: urlFilters.sellerName ?? null,
|
||||||
|
deliveryType: urlFilters.deliveryType ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const SearchBar = () => {
|
export const SearchBar = () => {
|
||||||
|
|
@ -135,6 +139,7 @@ export const SearchBar = () => {
|
||||||
partnerName: null,
|
partnerName: null,
|
||||||
productId: null,
|
productId: null,
|
||||||
productName: null,
|
productName: null,
|
||||||
|
deliveryType: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
setLocalFilters(getInitialLocalFilters(resetState));
|
setLocalFilters(getInitialLocalFilters(resetState));
|
||||||
|
|
@ -199,6 +204,7 @@ export const SearchBar = () => {
|
||||||
localFilters.sellerId,
|
localFilters.sellerId,
|
||||||
localFilters.partnerId,
|
localFilters.partnerId,
|
||||||
localFilters.productId,
|
localFilters.productId,
|
||||||
|
localFilters.deliveryType?.length,
|
||||||
].filter(Boolean).length;
|
].filter(Boolean).length;
|
||||||
|
|
||||||
const toggleDrawer = (open: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
|
const toggleDrawer = (open: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
|
||||||
|
|
@ -454,6 +460,16 @@ export const SearchBar = () => {
|
||||||
filterOptions={(x) => x}
|
filterOptions={(x) => x}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Tipo de Entrega */}
|
||||||
|
<Autocomplete
|
||||||
|
multiple
|
||||||
|
size="small"
|
||||||
|
options={DELIVERY_TYPES}
|
||||||
|
value={localFilters.deliveryType ?? []}
|
||||||
|
onChange={(_, newValue) => updateLocalFilter('deliveryType', newValue.length > 0 ? newValue : null)}
|
||||||
|
renderInput={(params) => <TextField {...params} label="Tipo de Entrega" placeholder="Selecione tipo" />}
|
||||||
|
/>
|
||||||
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ export const useOrderFilters = () => {
|
||||||
createDateEnd: parseAsString,
|
createDateEnd: parseAsString,
|
||||||
|
|
||||||
searchTriggered: parseAsBoolean.withDefault(false),
|
searchTriggered: parseAsBoolean.withDefault(false),
|
||||||
|
deliveryType: parseAsArrayOf(parseAsString, ','),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
shallow: true,
|
shallow: true,
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ export const findOrdersSchema = z.object({
|
||||||
deliveryDate: z.string().optional(),
|
deliveryDate: z.string().optional(),
|
||||||
|
|
||||||
shippimentId: z.coerce.number().optional(),
|
shippimentId: z.coerce.number().optional(),
|
||||||
deliveryType: z.string().optional(),
|
deliveryType: z.union([z.string(), z.array(z.string())]).optional(),
|
||||||
status: z.string().optional(),
|
status: z.string().optional(),
|
||||||
type: z.string().optional(),
|
type: z.string().optional(),
|
||||||
|
|
||||||
|
|
@ -111,7 +111,7 @@ export const orderApiParamsSchema = findOrdersSchema
|
||||||
const queryParams: any = { ...rest };
|
const queryParams: any = { ...rest };
|
||||||
|
|
||||||
if (customerId) queryParams.customerId = customerId;
|
if (customerId) queryParams.customerId = customerId;
|
||||||
else if (customerName) queryParams.customerName = customerName;
|
if (customerName) queryParams.customerName = customerName;
|
||||||
|
|
||||||
if (filters.partnerId) queryParams.partnerId = filters.partnerId;
|
if (filters.partnerId) queryParams.partnerId = filters.partnerId;
|
||||||
if (filters.productId) queryParams.productId = filters.productId;
|
if (filters.productId) queryParams.productId = filters.productId;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue