Skip to content

Commit

Permalink
Avoid desctructuring on composable props
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarodE committed May 6, 2024
1 parent 62bc848 commit 32b9b14
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import { FiltersByFacet } from '../store/types';
/**
* Composable to share Facets logic.
*
* @param params - Composable params.
* @param params - Composable props.
* @param props
* @returns Composable.
*
* @public
*/
export function useFacets({
facetsIds,
alwaysVisible = false
}: {
export function useFacets(props: {
/** Array of facets ids used to get the selected filters for those facets. */
facetsIds?: Array<Facet['id']>;
/** Flag to render the component even if there are no filters selected. */
Expand All @@ -39,8 +37,8 @@ export function useFacets({
* @returns Array of selected filters depends on there are facets ids or not.
*/
const selectedFilters = computed<Filter[]>(() => {
if (facetsIds) {
return (facetsIds as string[]).reduce(
if (props.facetsIds) {
return (props.facetsIds as string[]).reduce(
(selectedFilters, facetId) => [
...selectedFilters,
...selectedFiltersByFacet.value[facetId]
Expand All @@ -65,7 +63,7 @@ export function useFacets({
* @returns True whenever alwaysVisible is true or has selected filters. False
* otherwise.
*/
const isVisible = computed<boolean>(() => alwaysVisible || hasSelectedFilters.value);
const isVisible = computed<boolean>(() => !!props.alwaysVisible || hasSelectedFilters.value);

return {
selectedFiltersByFacet,
Expand Down

0 comments on commit 32b9b14

Please sign in to comment.