From d92ffbae5d80eb61a5ad4b85b3b12b7a21fb1a69 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 4 Jan 2025 17:36:12 +0800 Subject: [PATCH] :recycle: Migrate account flows :lipstick: Optimize container width --- src/components/auth/SnLoginCheckpoint.tsx | 4 +- src/components/auth/SnLoginRouter.tsx | 2 +- src/components/auth/SnLoginStart.tsx | 15 ++-- src/pages/auth/login.tsx | 3 +- src/pages/flow/accounts/confirm.tsx | 71 +++++++++++++++++++ src/pages/flow/accounts/deletion.tsx | 71 +++++++++++++++++++ src/pages/flow/accounts/password-reset.tsx | 79 ++++++++++++++++++++++ 7 files changed, 237 insertions(+), 8 deletions(-) create mode 100644 src/pages/flow/accounts/confirm.tsx create mode 100644 src/pages/flow/accounts/deletion.tsx create mode 100644 src/pages/flow/accounts/password-reset.tsx diff --git a/src/components/auth/SnLoginCheckpoint.tsx b/src/components/auth/SnLoginCheckpoint.tsx index e10d16d..b60c0eb 100644 --- a/src/components/auth/SnLoginCheckpoint.tsx +++ b/src/components/auth/SnLoginCheckpoint.tsx @@ -59,14 +59,14 @@ export function SnLoginCheckpoint({ return ( <> - + } severity="error"> {error}
- + - + {factorList.map((factor) => ( + + + + ) +} diff --git a/src/pages/flow/accounts/password-reset.tsx b/src/pages/flow/accounts/password-reset.tsx new file mode 100644 index 0000000..f6bf694 --- /dev/null +++ b/src/pages/flow/accounts/password-reset.tsx @@ -0,0 +1,79 @@ +import { sni } from '@/services/network' +import { Container, Box, Typography, Alert, Collapse, Button, TextField } from '@mui/material' +import { useRouter } from 'next/router' +import { useState } from 'react' +import { useForm } from 'react-hook-form' + +import ErrorIcon from '@mui/icons-material/Error' + +import 'animate.css' + +export type SnResetPasswordForm = { + password: string +} + +export default function AccountConfirm() { + const router = useRouter() + + const { handleSubmit, register } = useForm() + + const [error, setError] = useState(null) + const [busy, setBusy] = useState(false) + + async function confirm(data: any) { + try { + setBusy(true) + await sni.patch('/cgi/id/users/me/password-reset', { + code: router.query['code'] as string, + new_password: data.password, + }) + router.push('/') + } catch (err: any) { + setError(err.toString()) + } finally { + setBusy(false) + } + } + + return ( + + + + Reset Password + + + Reset your password on Solar Network + + + + } severity="error"> + {error} + + + +
+ + + + + +
+
+
+ ) +}