Skip to content

Commit 4f8a680

Browse files
author
Hector Arce De Las Heras
committed
Make optional the options props inner sections
Modify functionalitiesModule component to have optional options and sections
1 parent f98fb86 commit 4f8a680

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/components/functionalitiesModule/functionalitiesModuleStandAlone.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const FunctionalitiesModuleStandAloneComponent = (
2323
const mergeList = (): ListOptionsOptionType[] => {
2424
return (
2525
props.sections?.reduce((prev: ListOptionsOptionType[], current) => {
26-
return [...prev, ...current.options];
26+
const currentOptions = current.options ? current.options : [];
27+
return [...prev, ...currentOptions];
2728
}, []) ?? []
2829
);
2930
};
@@ -61,7 +62,7 @@ const FunctionalitiesModuleStandAloneComponent = (
6162
content={section.optionsContent}
6263
dataTestId={`${props.dataTestId}ListOptions`}
6364
optionVariant={props.styles.listOptions.optionVariant}
64-
options={section.options}
65+
options={section.options || []}
6566
selectedValue={props.selectedValue}
6667
title={{ component: TextComponentType.H6, ...section.optionsTitle }}
6768
type={ListOptionsType.NAVIGATION}

src/components/functionalitiesModule/stories/fixture.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export const SECTIONS: FunctionalitiesModuleSectionType[] = [
88
content: 'Tab 1',
99
},
1010
options: [
11-
{
12-
label: 'option 0 (disabled)',
13-
disabled: true,
14-
value: '0',
15-
},
11+
// {
12+
// label: 'option 0 (disabled)',
13+
// disabled: true,
14+
// value: '0',
15+
// },
1616
],
1717
},
1818
{

src/components/functionalitiesModule/types/functionalitiesModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type FunctionalitiesModuleActionBottomSheetType = Omit<
2121

2222
export type FunctionalitiesModuleSectionType = {
2323
tab: PrimaryTabTabType;
24-
options: Omit<ListOptionsOptionType, 'highlighted'>[];
24+
options?: Omit<ListOptionsOptionType, 'highlighted'>[];
2525
optionsTitle?: ListOptionsTitleType;
2626
optionsContent?: ReactNode;
2727
};

src/components/functionalitiesModule/utils/functionalitiesModule.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const getDefaultTabSeleted = (
55
sections?: FunctionalitiesModuleSectionType[]
66
): number => {
77
const tab = sections?.findIndex(section =>
8-
section.options.some(option => option.value === selectedValue)
8+
section.options?.some(option => option.value === selectedValue)
99
);
1010
return tab && tab >= 0 ? tab : 0;
1111
};

0 commit comments

Comments
 (0)