Skip to content

Commit

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

const modalId = 'filter-modal-id';

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

Expand Down Expand Up @@ -93,7 +92,7 @@ const Component = ({ className, filterItems, handleCancel, handleReset, isLinked
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) && isLinkedMyth);
const isCardRarityPassed = tmpItemsSelected[FilterOption.RARITY_OPTION].length === 0 || (tmpItemsSelected[FilterOption.RARITY_OPTION].includes(card.rarity) && card.program !== 'default');
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 @@ -124,7 +123,7 @@ const Component = ({ className, filterItems, handleCancel, handleReset, isLinked
onConfirm();

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

const footerContent = useMemo(() => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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 @@ -56,7 +55,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 @@ -115,7 +114,6 @@ 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 cc093e6

Please sign in to comment.