Feature: Filtro de Tipo de Entrega #3

Merged
joelson merged 1 commits from feature/delivery-type-filter into master 2026-01-15 20:08:27 +00:00
3 changed files with 19 additions and 2 deletions

View File

@ -55,8 +55,11 @@ interface LocalFilters {
stockId: string[] | null;
sellerId: string | null;
sellerName: string | null;
deliveryType: string[] | null;
}
const DELIVERY_TYPES = ['RI', 'EN', 'EF', 'RP'];
const getInitialLocalFilters = (
urlFilters: Partial<LocalFilters>
): LocalFilters => ({
@ -74,6 +77,7 @@ const getInitialLocalFilters = (
stockId: urlFilters.stockId ?? null,
sellerId: urlFilters.sellerId ?? null,
sellerName: urlFilters.sellerName ?? null,
deliveryType: urlFilters.deliveryType ?? null,
});
export const SearchBar = () => {
@ -135,6 +139,7 @@ export const SearchBar = () => {
partnerName: null,
productId: null,
productName: null,
deliveryType: null,
};
setLocalFilters(getInitialLocalFilters(resetState));
@ -199,6 +204,7 @@ export const SearchBar = () => {
localFilters.sellerId,
localFilters.partnerId,
localFilters.productId,
localFilters.deliveryType?.length,
].filter(Boolean).length;
const toggleDrawer = (open: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
@ -454,6 +460,16 @@ export const SearchBar = () => {
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>
</Box>

View File

@ -34,6 +34,7 @@ export const useOrderFilters = () => {
createDateEnd: parseAsString,
searchTriggered: parseAsBoolean.withDefault(false),
deliveryType: parseAsArrayOf(parseAsString, ','),
},
{
shallow: true,

View File

@ -38,7 +38,7 @@ export const findOrdersSchema = z.object({
deliveryDate: z.string().optional(),
shippimentId: z.coerce.number().optional(),
deliveryType: z.string().optional(),
deliveryType: z.union([z.string(), z.array(z.string())]).optional(),
status: z.string().optional(),
type: z.string().optional(),
@ -111,7 +111,7 @@ export const orderApiParamsSchema = findOrdersSchema
const queryParams: any = { ...rest };
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.productId) queryParams.productId = filters.productId;