Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: front page search not working #1523

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions apps/ui/components/search/SeasonalSearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,7 @@ export function SeasonalSearchForm({
});

const search: SubmitHandler<FormValues> = (criteria: FormValues) => {
// Remove empty (null || "") values from the criteria
const searchCriteria = Object.entries(criteria).reduce((c, cv) => {
if (cv[1] == null || cv[1] === "") return c;
return { ...c, [cv[0]]: cv[1] };
}, {});
handleSearch(searchCriteria, true);
handleSearch(criteria, true);
};

const translateTag = (key: string, value: string): string | undefined => {
Expand Down
7 changes: 1 addition & 6 deletions apps/ui/components/search/SingleSearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,7 @@ export function SingleSearchForm({
};

const onSearch: SubmitHandler<FormValues> = (criteria: FormValues) => {
// Remove empty (null || "") values from the criteria
const searchCriteria = Object.entries(criteria).reduce((c, cv) => {
if (cv[1] == null || cv[1] === "") return c;
return { ...c, [cv[0]]: cv[1] };
}, {});
handleSearch(searchCriteria, true);
handleSearch(criteria, true);
};

const showOptionalFilters =
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/hooks/useSearchValues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useSearchModify() {
const searchValues = useSearchValues();

// TODO type this properly (not a Record)
const handleSearch = (criteria: Record<string, string>, force: boolean) => {
const handleSearch = (criteria: Record<string, unknown>, force: boolean) => {
const { sort, order, ref } = router.query;
const newSort = sort != null && !Array.isArray(sort) ? sort : null;
const newOrder = order != null && !Array.isArray(order) ? order : null;
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/modules/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ export function processVariables(
endDate && endDate >= today ? toApiDate(endDate) : null,
}
: {}),
...(values.timeBegin != null
...(values.timeBegin != null && values.timeBegin !== ""
? {
reservableTimeStart: ignoreMaybeArray(values.timeBegin),
}
: {}),
...(values.timeBegin != null
...(values.timeEnd != null && values.timeEnd !== ""
? {
reservableTimeEnd: ignoreMaybeArray(values.timeEnd),
}
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/modules/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function getSeasonalSearchPath(
export function getSingleSearchPath(params?: URLSearchParams): string {
const base = `${singleSearchPrefix}/`;

if (params && Object.keys(params).length > 0) {
if (params != null) {
return `${base}?${params.toString()}`;
}

Expand Down