Skip to content

Commit

Permalink
Remove duplicate useCategorizationFromApi
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur791004 committed Dec 3, 2024
1 parent c3f2382 commit c3d136f
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions client/signup/steps/design-picker/use-categorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,6 @@ export function useCategorization(
};
}

export function useCategorizationFromApi(
categoryMap: Record< string, Category >,
{ defaultSelection, sort }: UseCategorizationOptions
): Categorization {
const categories = useMemo( () => {
const categoryMapKeys = Object.keys( categoryMap ) || [];
const result = categoryMapKeys.map( ( slug ) => ( {
...categoryMap[ slug ],
slug,
} ) );

return result.sort( sort );
}, [ categoryMap ] );

const [ selection, onSelect ] = useState< string | null >(
chooseDefaultSelection( categories, defaultSelection )
);

useEffect( () => {
if ( shouldSetToDefaultSelection( categories, selection ) ) {
onSelect( chooseDefaultSelection( categories, defaultSelection ) );
}
}, [ categories, defaultSelection, selection ] );

return {
categories,
selection,
onSelect,
};
}

/**
* Check that the current selection still matches one of the category slugs,
* and if it doesn't reset the current selection to the default selection.
Expand Down

0 comments on commit c3d136f

Please sign in to comment.