File tree 2 files changed +32
-6
lines changed
2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,14 @@ class ShelterSearch {
31
31
}
32
32
33
33
priority ( supplyIds : string [ ] = [ ] ) : Prisma . ShelterWhereInput {
34
- if ( ! this . formProps . priority ) return { } ;
34
+ if ( ! this . formProps . priority ?. length ) return { } ;
35
35
36
36
return {
37
37
shelterSupplies : {
38
38
some : {
39
- priority : + this . formProps . priority ,
39
+ priority : {
40
+ in : this . formProps . priority ,
41
+ } ,
40
42
supplyId :
41
43
supplyIds . length > 0
42
44
? {
@@ -71,13 +73,31 @@ class ShelterSearch {
71
73
}
72
74
73
75
supplyCategoryIds (
74
- priority ?: SupplyPriority | null ,
76
+ priority ?: SupplyPriority [ ] | null ,
75
77
) : Prisma . ShelterWhereInput {
76
78
if ( ! this . formProps . supplyCategoryIds ) return { } ;
79
+
80
+ if ( ! priority || ! priority . length ) {
81
+ return {
82
+ shelterSupplies : {
83
+ some : {
84
+ priority : undefined ,
85
+ supply : {
86
+ supplyCategoryId : {
87
+ in : this . formProps . supplyCategoryIds ,
88
+ } ,
89
+ } ,
90
+ } ,
91
+ } ,
92
+ } ;
93
+ }
94
+
77
95
return {
78
96
shelterSupplies : {
79
97
some : {
80
- priority : priority ? + priority : undefined ,
98
+ priority : {
99
+ in : priority ,
100
+ } ,
81
101
supply : {
82
102
supplyCategoryId : {
83
103
in : this . formProps . supplyCategoryIds ,
Original file line number Diff line number Diff line change @@ -32,8 +32,14 @@ export type GeolocationFilter = z.infer<typeof GeolocationFilterSchema>;
32
32
export const ShelterSearchPropsSchema = z . object ( {
33
33
search : z . string ( ) . optional ( ) ,
34
34
priority : z . preprocess (
35
- ( value ) => Number ( value ) || undefined ,
36
- z . nativeEnum ( SupplyPriority ) . optional ( ) ,
35
+ ( value ) =>
36
+ typeof value === 'string'
37
+ ? value
38
+ . split ( ',' )
39
+ . map ( ( v ) => Number ( v ) )
40
+ . filter ( ( v ) => ! isNaN ( v ) )
41
+ : [ ] ,
42
+ z . array ( z . nativeEnum ( SupplyPriority ) ) . optional ( ) ,
37
43
) ,
38
44
supplyCategoryIds : z . array ( z . string ( ) ) . optional ( ) ,
39
45
supplyIds : z . array ( z . string ( ) ) . optional ( ) ,
You can’t perform that action at this time.
0 commit comments