Skip to content

Commit

Permalink
Use unique_values_v2 struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Pride committed Jun 25, 2024
1 parent 83d8858 commit 778c409
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion react/src/__rust_generated__/EmbedFilters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FilterConfig } from './FilterConfig';
import type { FilterVariableValue } from './FilterVariableValue';
import type { LabelValue } from './LabelValue';

export interface EmbedFilters {
filters: Array<FilterConfig>;
defaultValues: Record<string, FilterVariableValue>;
uniqueValues: Record<string, Array<[string, string]>>;
// uniqueValues: Record<string, Array<[string, string]>>;
uniqueValuesV2: Record<string, Array<LabelValue>>;
}
6 changes: 6 additions & 0 deletions react/src/__rust_generated__/LabelValue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface LabelValue {
label: string;
value: string;
}
7 changes: 3 additions & 4 deletions react/src/filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ const Filter = ({ canvasData, filter }: { canvasData: EmbedResponse; filter: Fil
if (filterOptionsCache) {
return filterOptionsCache;
}
const uniqueValues = canvasData.filters.uniqueValues[storeId];
const uniqueValues = canvasData.filters.uniqueValuesV2[storeId];
if (!uniqueValues) {
return [];
}
const options = uniqueValues.map((option) => ({ label: option[0], value: option[1] }));
setFilterOptionsCache(options);
return options;
setFilterOptionsCache(uniqueValues);
return uniqueValues;
};
const filterOptions = getFilterOptions();
return (
Expand Down

0 comments on commit 778c409

Please sign in to comment.