Skip to content

Commit

Permalink
[Issue-234][Mythical Telegram App] Remove all default cards when any …
Browse files Browse the repository at this point in the history
…Rarity filter is applied
  • Loading branch information
dungnguyen-art committed Dec 17, 2024
1 parent 6f4a4db commit 1686bf3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Props extends ThemeProps {
setNumberOptionsSelected: Dispatch<SetStateAction<number>>;
tmpItemsSelected: FilterOptionsSelected;
setTmpItemsSelected: Dispatch<SetStateAction<FilterOptionsSelected>>;
isLinkedMyth: boolean;
onConfirm: () => void;
handleCancel: () => void;
handleReset: () => void;
Expand All @@ -44,7 +45,7 @@ const DEFAULT_FILTER_OPTIONS_SELECTED: FilterOptionsSelected = {

const modalId = 'filter-modal-id';

const Component = ({ className, filterItems, handleCancel, handleReset, onConfirm, setConditionProcess, setNumberOptionsSelected, setTmpItemsSelected, tmpItemsSelected }: Props): React.ReactElement => {
const Component = ({ className, filterItems, handleCancel, handleReset, isLinkedMyth, onConfirm, setConditionProcess, setNumberOptionsSelected, setTmpItemsSelected, tmpItemsSelected }: Props): React.ReactElement => {
const { t } = useTranslation();
const { inactiveModal } = useContext(ModalContext);

Expand Down Expand Up @@ -92,7 +93,7 @@ const Component = ({ className, filterItems, handleCancel, handleReset, onConfir
return [...prev].filter((card) => {
const isCardPositionPassed = tmpItemsSelected[FilterOption.POSITION_OPTION].length === 0 || tmpItemsSelected[FilterOption.POSITION_OPTION].includes(card.position);
const isCardProgramPassed = tmpItemsSelected[FilterOption.PROGRAM_OPTION].length === 0 || tmpItemsSelected[FilterOption.PROGRAM_OPTION].includes(card.program);
const isCardRarityPassed = tmpItemsSelected[FilterOption.RARITY_OPTION].length === 0 || tmpItemsSelected[FilterOption.RARITY_OPTION].includes(card.rarity);
const isCardRarityPassed = tmpItemsSelected[FilterOption.RARITY_OPTION].length === 0 || (tmpItemsSelected[FilterOption.RARITY_OPTION].includes(card.rarity) && isLinkedMyth);
const isCardTeamPassed = tmpItemsSelected[FilterOption.TEAM_OPTION].length === 0 || tmpItemsSelected[FilterOption.TEAM_OPTION].includes(card.team);

let isCardPowerPassed = tmpItemsSelected[FilterOption.POWER_OPTION].length === 0;
Expand Down Expand Up @@ -123,7 +124,7 @@ const Component = ({ className, filterItems, handleCancel, handleReset, onConfir
onConfirm();

inactiveModal('filter-modal-id');
}, [inactiveModal, onConfirm, setConditionProcess, setNumberOptionsSelected, tmpItemsSelected]);
}, [inactiveModal, isLinkedMyth, onConfirm, setConditionProcess, setNumberOptionsSelected, tmpItemsSelected]);

const footerContent = useMemo(() => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { LevelOptions, PositionOptions, PowerOptions, ProgramOptions, RarityOptions, TeamOptions } from '@subwallet/extension-koni-ui/constants/myth';
import { AuthenticationMythContext } from '@subwallet/extension-koni-ui/contexts/AuthenticationMythProvider';
import { useTranslation } from '@subwallet/extension-koni-ui/hooks';
import { ConditionProcessState } from '@subwallet/extension-koni-ui/Popup/Home/Cards';
import { FilterOptionsSelected, ToolFiltersModal } from '@subwallet/extension-koni-ui/Popup/Home/Cards/ToolFiters/ToolFiltersModal';
Expand Down Expand Up @@ -55,7 +56,7 @@ const Component = ({ className, setConditionProcess }: Props): React.ReactElemen
const { activeModal } = useContext(ModalContext);
const [numberOptionsSelected, setNumberOptionsSelected] = useState<number>(0);
const [tmpItemsSelected, setTmpItemsSelected] = useState<FilterOptionsSelected>(_.cloneDeep(DEFAULT_FILTER_OPTIONS_SELECTED));

const { isLinkedMyth } = useContext(AuthenticationMythContext);
const [itemsSelected, setItemsSelected] = useState<FilterOptionsSelected>(DEFAULT_FILTER_OPTIONS_SELECTED);

const handleConfirmSelection = useCallback(() => {
Expand Down Expand Up @@ -114,6 +115,7 @@ const Component = ({ className, setConditionProcess }: Props): React.ReactElemen
filterItems={FilterOptions}
handleCancel={handleCancel}
handleReset={handleReset}
isLinkedMyth={isLinkedMyth}
onConfirm={handleConfirmSelection}
setConditionProcess={setConditionProcess}
setNumberOptionsSelected={setNumberOptionsSelected}
Expand Down

0 comments on commit 1686bf3

Please sign in to comment.