Skip to content

Commit

Permalink
fix(storefront): Removing params and fields objects from `SEARCH_…
Browse files Browse the repository at this point in the history
…ENGINE_DEFAULTS`

Changed and persisted by reference, searches with empty results
  • Loading branch information
leomp12 committed Feb 21, 2025
1 parent e6882a7 commit ca1ef2c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/storefront/src/lib/state/search-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,27 @@ export const search = async ({
};

type SearchOptions = Parameters<typeof search>[0];
type RequestParams = Exclude<ApiConfig['params'], string | undefined>;

export const SEARCH_ENGINE_DEFAULTS: {
fields?: readonly string[],
term: string | null,
isWithCount: boolean,
isWithBuckets: boolean,
params: RequestParams,
pageSize: number,
} = {
term: null,
isWithCount: true,
isWithBuckets: true,
params: {},
pageSize: 24,
};

export class SearchEngine {
fields?: readonly string[];
term = ref<string | null>(SEARCH_ENGINE_DEFAULTS.term);
term = ref(SEARCH_ENGINE_DEFAULTS.term);
isWithCount = ref(SEARCH_ENGINE_DEFAULTS.isWithCount);
isWithBuckets = ref(SEARCH_ENGINE_DEFAULTS.isWithBuckets);
params = reactive<RequestParams>(SEARCH_ENGINE_DEFAULTS.params);
pageSize = ref(SEARCH_ENGINE_DEFAULTS.pageSize);
pageNumber = ref(1);
fields?: readonly string[];
params = reactive<Exclude<ApiConfig['params'], string | undefined>>({});
#middlewares: Array<(opt: SearchOptions) => void> = [];
#isFetching = ref(false);
isFetching = computed(() => this.#isFetching.value);
Expand Down

0 comments on commit ca1ef2c

Please sign in to comment.