Skip to content

Commit

Permalink
apply suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JKobrynski committed Mar 8, 2024
1 parent 07a34ac commit fab486a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
9 changes: 3 additions & 6 deletions src/stories/EReceipt.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */

/* eslint-disable rulesdir/prefer-actions-set-data */
/* eslint-disable @typescript-eslint/naming-convention, rulesdir/prefer-actions-set-data */
import type {ComponentMeta, ComponentStory} from '@storybook/react';
import React from 'react';
import type {NullishDeep} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {EReceiptOnyxProps, EReceiptProps} from '@components/EReceipt';
import EReceipt from '@components/EReceipt';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Transaction} from '@src/types/onyx';
import type CollectionDataSet from '@src/types/utils/CollectionDataSet';

type EReceiptStory = ComponentStory<typeof EReceipt>;

Expand Down Expand Up @@ -154,7 +151,7 @@ const transactionData = {
created: '2023-01-11 13:46:20',
hasEReceipt: true,
},
} as Record<`${typeof ONYXKEYS.COLLECTION.TRANSACTION}${string}`, NullishDeep<Transaction>>;
} as CollectionDataSet<typeof ONYXKEYS.COLLECTION.TRANSACTION>;

Onyx.mergeCollection(ONYXKEYS.COLLECTION.TRANSACTION, transactionData);
Onyx.merge('cardList', {
Expand Down
12 changes: 5 additions & 7 deletions src/stories/SelectionList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function WithTextInput(props: BaseSelectionListProps<ListItem>) {
const [selectedIndex, setSelectedIndex] = useState(1);

const sections = props.sections.map((section) => {
const data = section.data.reduce<Array<ListItem & {isSelected: boolean}>>((memo, item, index) => {
const data = section.data.reduce<ListItem[]>((memo, item, index) => {
if (!item.text.toLowerCase().includes(searchText.trim().toLowerCase())) {
return memo;
}
Expand Down Expand Up @@ -210,9 +210,7 @@ function WithAlternateText(props: BaseSelectionListProps<ListItem>) {
}

WithAlternateText.args = {
sections: SECTIONS,
onSelectRow: () => {},
initiallyFocusedOptionKey: 'option-2',
...Default.args,
};

function MultipleSelection(props: BaseSelectionListProps<ListItem>) {
Expand Down Expand Up @@ -250,7 +248,7 @@ function MultipleSelection(props: BaseSelectionListProps<ListItem>) {
}, [props.sections, selectedIds]);

const onSelectRow = (item: ListItem) => {
const newSelectedIds = selectedIds.includes(item.keyForList) ? selectedIds.filter((i) => i !== item.keyForList) : [...selectedIds, item.keyForList];
const newSelectedIds = selectedIds.includes(item.keyForList) ? selectedIds.filter((id) => id !== item.keyForList) : [...selectedIds, item.keyForList];
setSelectedIds(newSelectedIds);
};

Expand Down Expand Up @@ -315,7 +313,7 @@ function WithSectionHeader(props: BaseSelectionListProps<ListItem>) {
}, [props.sections, selectedIds]);

const onSelectRow = (item: ListItem) => {
const newSelectedIds = selectedIds.includes(item.keyForList) ? selectedIds.filter((i) => i !== item.keyForList) : [...selectedIds, item.keyForList];
const newSelectedIds = selectedIds.includes(item.keyForList) ? selectedIds.filter((id) => id !== item.keyForList) : [...selectedIds, item.keyForList];
setSelectedIds(newSelectedIds);
};

Expand Down Expand Up @@ -378,7 +376,7 @@ function WithConfirmButton(props: BaseSelectionListProps<ListItem>) {
}, [props.sections, selectedIds]);

const onSelectRow = (item: ListItem) => {
const newSelectedIds = selectedIds.includes(item.keyForList) ? selectedIds.filter((i) => i !== item.keyForList) : [...selectedIds, item.keyForList];
const newSelectedIds = selectedIds.includes(item.keyForList) ? selectedIds.filter((id) => id !== item.keyForList) : [...selectedIds, item.keyForList];
setSelectedIds(newSelectedIds);
};

Expand Down

0 comments on commit fab486a

Please sign in to comment.