Skip to content

Commit

Permalink
fix: resolve issue with closing button on the Referanda unlock modal (#…
Browse files Browse the repository at this point in the history
…1547)

Co-authored-by: Amir Ekbatanifard <[email protected]>
  • Loading branch information
Nick-1979 and AMIRKHANEF authored Nov 3, 2024
1 parent ac5205e commit ac1a4df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function Review ({ address, api, classToUnlock, setDisplayPopup,
const [txInfo, setTxInfo] = useState<TxInfo | undefined>();
const [estimatedFee, setEstimatedFee] = useState<Balance>();
const [params, setParams] = useState<SubmittableExtrinsic<'promise', ISubmittableResult>[]>();
const [step, setStep] = useState<number>(STEPS.REVIEW);
const [step, setStep] = useState<number>(STEPS.INDEX);

const selectedProxyAddress = selectedProxy?.delegate as unknown as string;

Expand Down Expand Up @@ -113,12 +113,13 @@ export default function Review ({ address, api, classToUnlock, setDisplayPopup,
setDisplayPopup(undefined);
}, [setDisplayPopup]);

const closeProxy = useCallback(() => setStep(STEPS.REVIEW), []);
const closeProxy = useCallback(() => setStep(STEPS.INDEX), []);

return (
<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 All @@ -128,7 +129,7 @@ export default function Review ({ address, api, classToUnlock, setDisplayPopup,
{isPasswordError &&
<WrongPasswordAlert />
}
{[STEPS.REVIEW, STEPS.SIGN_QR].includes(step) &&
{[STEPS.INDEX, STEPS.REVIEW, STEPS.SIGN_QR].includes(step) &&
<>
<SubTitle label={t('Review')} style={{ paddingTop: isPasswordError ? '10px' : '25px' }} />
<Container disableGutters sx={{ px: '30px' }}>
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 ac1a4df

Please sign in to comment.