Skip to content

Commit

Permalink
fix: handle close proxy for non input modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-1979 committed Nov 2, 2024
1 parent 5703ef0 commit 364dc3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default function Review ({ address, api, classToUnlock, setDisplayPopup,
<DraggableModal onClose={onClose} open={show}>
<Grid alignItems='center' container justifyContent='center' maxHeight='650px' overflow='hidden'>
<ModalTitle
closeProxy={closeProxy}
icon={step === STEPS.PROXY ? faUserAstronaut : faLockOpen}
onCancel={step === STEPS.PROXY ? closeProxy : onClose}
setStep={setStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ interface Props {
setRefresh: React.Dispatch<React.SetStateAction<boolean>>
}

export const ModalTitle = ({ icon, onCancel, setStep, step, text }: { text: string, onCancel: () => void, setStep?: React.Dispatch<React.SetStateAction<number>>, icon: IconDefinition, step: number }): React.ReactElement<Props> => {
export const ModalTitle = ({ closeProxy, icon, onCancel, setStep, step, text }: { closeProxy?: () => void, text: string, onCancel: () => void, setStep?: React.Dispatch<React.SetStateAction<number>>, icon: IconDefinition, step: number }): React.ReactElement<Props> => {
const theme = useTheme();
const { t } = useTranslation();

const closeProxy = useCallback(
() => setStep && setStep(STEPS.REVIEW)
, [setStep]);
const _closeProxy = useCallback(() => {
if (closeProxy) {
return closeProxy();
}

setStep && setStep(STEPS.REVIEW);
}, [closeProxy, setStep]);

const onClose = useCallback(() => {
setStep && setStep(STEPS.INDEX);
Expand Down Expand Up @@ -65,7 +69,7 @@ export const ModalTitle = ({ icon, onCancel, setStep, step, text }: { text: stri
step === STEPS.INDEX
? onCancel
: step === STEPS.PROXY
? closeProxy
? _closeProxy
: onClose
}
>
Expand Down

0 comments on commit 364dc3c

Please sign in to comment.