forked from SOS-RS/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criação do endpoint para busca de cidades dos abrigos (SOS-RS#82)
Co-authored-by: Pedro Perrone <psperrone@hotmail.com>
- Loading branch information
1 parent
ecb22d8
commit de7e56c
Showing
10 changed files
with
152 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,43 @@ | ||
import { Shelter, ShelterSupply, Supply } from '@prisma/client'; | ||
import { z } from 'zod'; | ||
import { SupplyPriority } from '../../supply/types'; | ||
|
||
export type ShelterAvailabilityStatus = 'available' | 'unavailable' | 'waiting'; | ||
const ShelterStatusSchema = z.enum(['available', 'unavailable', 'waiting']); | ||
|
||
export interface IFilterFormProps { | ||
search: string; | ||
priority: SupplyPriority | null; | ||
supplyCategoryIds: string[]; | ||
supplyIds: string[]; | ||
shelterStatus: ShelterAvailabilityStatus[]; | ||
tags: ShelterTagInfo | null; | ||
} | ||
export type ShelterStatus = z.infer<typeof ShelterStatusSchema>; | ||
|
||
const ShelterTagTypeSchema = z.enum([ | ||
'NeedVolunteers', | ||
'NeedDonations', | ||
'RemainingSupplies', | ||
]); | ||
|
||
const ShelterTagInfoSchema = z.record( | ||
ShelterTagTypeSchema, | ||
z.number().optional(), | ||
); | ||
|
||
export type ShelterTagType = z.infer<typeof ShelterTagTypeSchema>; | ||
|
||
export type ShelterTagInfo = z.infer<typeof ShelterTagInfoSchema>; | ||
|
||
export const ShelterSearchPropsSchema = z.object({ | ||
search: z.string().optional(), | ||
priority: z.preprocess( | ||
(value) => Number(value) || undefined, | ||
z.nativeEnum(SupplyPriority).optional(), | ||
), | ||
supplyCategoryIds: z.array(z.string()).optional(), | ||
supplyIds: z.array(z.string()).optional(), | ||
shelterStatus: z.array(ShelterStatusSchema).optional(), | ||
tags: ShelterTagInfoSchema.nullable().optional(), | ||
cities: z.array(z.string()).optional(), | ||
}); | ||
|
||
export type ShelterSearchProps = z.infer<typeof ShelterSearchPropsSchema>; | ||
|
||
type AllowedShelterFields = Omit<Shelter, 'contact'>; | ||
|
||
export type SearchShelterTagResponse = AllowedShelterFields & { | ||
shelterSupplies: (ShelterSupply & { supply: Supply })[]; | ||
}; | ||
|
||
export type ShelterTagType = | ||
| 'NeedVolunteers' | ||
| 'NeedDonations' | ||
| 'RemainingSupplies'; | ||
|
||
export type ShelterTagInfo = { | ||
[key in ShelterTagType]?: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters