-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ca71fb
commit 4d00e4a
Showing
8 changed files
with
197 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/ui/pages/Menu/components/UpdatePasscode/UpdatePasscode.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.update-passcode-modal { | ||
.responsive-page-content { | ||
justify-content: space-evenly; | ||
} | ||
|
||
.page-header { | ||
ion-toolbar { | ||
--background: transparent; | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/ui/pages/Menu/components/UpdatePasscode/UpdatePasscode.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
import { IonModal } from "@ionic/react"; | ||
import "./UpdatePasscode.scss"; | ||
import { CreatePasscodeModuleRef } from "../../../../components/CreatePasscodeModule/CreatePasscodeModule.types"; | ||
import { ResponsivePageLayout } from "../../../../components/layout/ResponsivePageLayout"; | ||
import { PageHeader } from "../../../../components/PageHeader"; | ||
import { CreatePasscodeModule } from "../../../../components/CreatePasscodeModule"; | ||
import { i18n } from "../../../../../i18n"; | ||
import { UpdatePasscodeModalProps } from "./UpdatePasscode.types"; | ||
|
||
const UpdatePasscode = ({ isOpen, setIsOpen }: UpdatePasscodeModalProps) => { | ||
const pageId = "update-passcode"; | ||
const [passCodeValue, setPassCodeValue] = useState({ | ||
passcode: "", | ||
originalPasscode: "", | ||
}); | ||
|
||
const ref = useRef<CreatePasscodeModuleRef>(null); | ||
|
||
const handlePassAuth = async () => { | ||
// TODO: toast message and close modal | ||
setIsOpen(false); | ||
}; | ||
|
||
useEffect(() => { | ||
console.log(passCodeValue); | ||
console.log(isOnReenterPasscodeStep); | ||
}, [passCodeValue]); | ||
|
||
const handleCancel = () => { | ||
if (isOnReenterPasscodeStep) { | ||
ref.current?.clearState; | ||
setPassCodeValue({ | ||
passcode: "", | ||
originalPasscode: "", | ||
}); | ||
} else { | ||
setIsOpen(false); | ||
} | ||
}; | ||
|
||
const isOnReenterPasscodeStep = | ||
passCodeValue.originalPasscode.length > 0 && | ||
passCodeValue.passcode.length < 6; | ||
|
||
const title = | ||
passCodeValue.originalPasscode !== "" | ||
? i18n.t("settings.updatepasscode.reenterpasscode.title") | ||
: i18n.t("settings.updatepasscode.createpasscode.title"); | ||
|
||
return ( | ||
<IonModal | ||
isOpen={isOpen} | ||
className={pageId + "-modal"} | ||
data-testid={pageId + "-modal"} | ||
onDidDismiss={() => setIsOpen(false)} | ||
> | ||
<ResponsivePageLayout | ||
pageId={pageId} | ||
header={ | ||
<PageHeader | ||
closeButton={true} | ||
closeButtonLabel={`${ | ||
isOnReenterPasscodeStep | ||
? i18n.t("settings.updatepasscode.back") | ||
: i18n.t("settings.updatepasscode.cancel") | ||
}`} | ||
closeButtonAction={handleCancel} | ||
/> | ||
} | ||
> | ||
<CreatePasscodeModule | ||
title={title} | ||
description={`${i18n.t("settings.updatepasscode.description")}`} | ||
ref={ref} | ||
testId={pageId} | ||
onCreateSuccess={handlePassAuth} | ||
onPasscodeChange={(passcode, originalPasscode) => { | ||
setPassCodeValue({ | ||
passcode, | ||
originalPasscode, | ||
}); | ||
}} | ||
/> | ||
</ResponsivePageLayout> | ||
</IonModal> | ||
); | ||
}; | ||
|
||
export { UpdatePasscode }; |
6 changes: 6 additions & 0 deletions
6
src/ui/pages/Menu/components/UpdatePasscode/UpdatePasscode.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
interface UpdatePasscodeModalProps { | ||
isOpen: boolean; | ||
setIsOpen: (value: boolean) => void; | ||
} | ||
|
||
export type { UpdatePasscodeModalProps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./UpdatePasscode"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters