Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 7e1e396

Browse files
committed
fix: removing search values from form not working
1 parent 1fe1b26 commit 7e1e396

4 files changed

Lines changed: 5 additions & 15 deletions

File tree

apps/ui/components/search/SeasonalSearchForm.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,7 @@ export function SeasonalSearchForm({
185185
});
186186

187187
const search: SubmitHandler<FormValues> = (criteria: FormValues) => {
188-
// Remove empty (null || "") values from the criteria
189-
const searchCriteria = Object.entries(criteria).reduce((c, cv) => {
190-
if (cv[1] == null || cv[1] === "") return c;
191-
return { ...c, [cv[0]]: cv[1] };
192-
}, {});
193-
handleSearch(searchCriteria, true);
188+
handleSearch(criteria, true);
194189
};
195190

196191
const translateTag = (key: string, value: string): string | undefined => {

apps/ui/components/search/SingleSearchForm.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,7 @@ export function SingleSearchForm({
272272
};
273273

274274
const onSearch: SubmitHandler<FormValues> = (criteria: FormValues) => {
275-
// Remove empty (null || "") values from the criteria
276-
const searchCriteria = Object.entries(criteria).reduce((c, cv) => {
277-
if (cv[1] == null || cv[1] === "") return c;
278-
return { ...c, [cv[0]]: cv[1] };
279-
}, {});
280-
handleSearch(searchCriteria, true);
275+
handleSearch(criteria, true);
281276
};
282277

283278
const showOptionalFilters =

apps/ui/hooks/useSearchValues.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function useSearchModify() {
2121
const searchValues = useSearchValues();
2222

2323
// TODO type this properly (not a Record)
24-
const handleSearch = (criteria: Record<string, string>, force: boolean) => {
24+
const handleSearch = (criteria: Record<string, unknown>, force: boolean) => {
2525
const { sort, order, ref } = router.query;
2626
const newSort = sort != null && !Array.isArray(sort) ? sort : null;
2727
const newOrder = order != null && !Array.isArray(order) ? order : null;

apps/ui/modules/search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ export function processVariables(
191191
endDate && endDate >= today ? toApiDate(endDate) : null,
192192
}
193193
: {}),
194-
...(values.timeBegin != null
194+
...(values.timeBegin != null && values.timeBegin !== ""
195195
? {
196196
reservableTimeStart: ignoreMaybeArray(values.timeBegin),
197197
}
198198
: {}),
199-
...(values.timeBegin != null
199+
...(values.timeEnd != null && values.timeEnd !== ""
200200
? {
201201
reservableTimeEnd: ignoreMaybeArray(values.timeEnd),
202202
}

0 commit comments

Comments
 (0)