Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

refactor(accounts):inline-single-use-presentation-wrappers

Aswin Asokacf1adbaf397
diff --git a/web/packages/accounts/pages/change-password.tsx b/web/packages/accounts/pages/change-password.tsx
index 1d8769f014..a20e52afd2 100644
--- a/web/packages/accounts/pages/change-password.tsx
+++ b/web/packages/accounts/pages/change-password.tsx
@@ -18,7 +18,6 @@ import React, { useCallback, useEffect, useState } from "react";
import {
NewPasswordForm,
type NewPasswordFormProps,
- type NewPasswordPresentationProps,
} from "../components/NewPasswordForm";
import { savedLocalUser } from "../services/accounts-db";
@@ -54,6 +53,7 @@ interface PageContentsProps {
}
const PageContents: React.FC<PageContentsProps> = ({ user, isReset }) => {
+ const { Shell } = useAuthPageConfig();
const router = useRouter();
const handleSubmit: NewPasswordFormProps["onSubmit"] = useCallback(
@@ -73,12 +73,14 @@ const PageContents: React.FC<PageContentsProps> = ({ user, isReset }) => {
if (isReset) {
return (
- <NewPasswordForm
- userEmail={user.email}
- submitButtonTitle={t("change_password")}
- onSubmit={handleSubmit}
- presentation={ConfiguredResetPasswordPresentation}
- />
+ <Shell>
+ <NewPasswordForm
+ userEmail={user.email}
+ submitButtonTitle={t("change_password")}
+ onSubmit={handleSubmit}
+ presentation={SetPasswordForm}
+ />
+ </Shell>
);
}
@@ -97,14 +99,3 @@ const PageContents: React.FC<PageContentsProps> = ({ user, isReset }) => {
</AccountsPageContents>
);
};
-
-function ConfiguredResetPasswordPresentation(
- props: NewPasswordPresentationProps,
-): React.JSX.Element {
- const { Shell } = useAuthPageConfig();
- return (
- <Shell>
- <SetPasswordForm {...props} />
- </Shell>
- );
-}
diff --git a/web/packages/accounts/pages/generate.tsx b/web/packages/accounts/pages/generate.tsx
index 45115e28c9..caf7aafed7 100644
--- a/web/packages/accounts/pages/generate.tsx
+++ b/web/packages/accounts/pages/generate.tsx
@@ -1,10 +1,7 @@
import { useAuthPageConfig } from "ente-accounts/components/auth/AuthPageProvider";
import { RecoveryKeyForm } from "ente-accounts/components/auth/RecoveryKeyForm";
import { SetPasswordForm } from "ente-accounts/components/auth/SetPasswordForm";
-import {
- RecoveryKeyContents,
- type RecoveryKeyPresentationProps,
-} from "ente-accounts/components/RecoveryKey";
+import { RecoveryKeyContents } from "ente-accounts/components/RecoveryKey";
import {
savedJustSignedUp,
savedOriginalKeyAttributes,
@@ -35,11 +32,10 @@ import { useCallback, useEffect, useState } from "react";
import {
NewPasswordForm,
type NewPasswordFormProps,
- type NewPasswordPresentationProps,
} from "../components/NewPasswordForm";
const Page: React.FC = () => {
- const { recoveryKeyCloseDestination } = useAuthPageConfig();
+ const { Shell, recoveryKeyCloseDestination } = useAuthPageConfig();
const { logout, showMiniDialog } = useBaseContext();
const [userEmail, setUserEmail] = useState("");
@@ -98,49 +94,31 @@ const Page: React.FC = () => {
if (openRecoveryKey) {
return (
- <RecoveryKeyContents
- open
- onClose={handleRecoveryKeyClose}
- getRecoveryKeyMnemonic={getPreloginRecoveryKeyMnemonic}
- showMiniDialog={showMiniDialog}
- presentation={ConfiguredRecoveryKeyPresentation}
- />
+ <Shell key="recovery-key">
+ <RecoveryKeyContents
+ open
+ onClose={handleRecoveryKeyClose}
+ getRecoveryKeyMnemonic={getPreloginRecoveryKeyMnemonic}
+ showMiniDialog={showMiniDialog}
+ presentation={RecoveryKeyForm}
+ />
+ </Shell>
);
}
return userEmail ? (
- <NewPasswordForm
- userEmail={userEmail}
- submitButtonTitle={t("set_password")}
- onSubmit={handleSubmit}
- onBack={logout}
- presentation={ConfiguredPasswordPresentation}
- />
+ <Shell>
+ <NewPasswordForm
+ userEmail={userEmail}
+ submitButtonTitle={t("set_password")}
+ onSubmit={handleSubmit}
+ onBack={logout}
+ presentation={SetPasswordForm}
+ />
+ </Shell>
) : (
<LoadingIndicator />
);
};
export default Page;
-
-function ConfiguredPasswordPresentation(
- props: NewPasswordPresentationProps,
-): React.JSX.Element {
- const { Shell } = useAuthPageConfig();
- return (
- <Shell>
- <SetPasswordForm {...props} />
- </Shell>
- );
-}
-
-function ConfiguredRecoveryKeyPresentation(
- props: RecoveryKeyPresentationProps,
-): React.JSX.Element {
- const { Shell } = useAuthPageConfig();
- return (
- <Shell>
- <RecoveryKeyForm {...props} />
- </Shell>
- );
-}