Update "Password Reset" to "Update Password"

The code changes correspond to the rebranding of "Password Reset" to "Update Password". The names of components, functions, and routes have been updated to reflect this change. Also, a minor code optimization has been made in the i18n.server file for the creation of i18n server instances.
This commit is contained in:
giancarlo
2024-04-19 17:27:11 +08:00
parent cc80b26117
commit c121a3bdad
5 changed files with 15 additions and 10 deletions

View File

@@ -17,9 +17,10 @@ export const generateMetadata = async () => {
};
};
function PasswordResetPage() {
const redirectPath = `${pathsConfig.auth.callback}?next=${pathsConfig.auth.passwordUpdate}`;
const { callback, passwordUpdate, signIn } = pathsConfig.auth;
const redirectPath = `${callback}?next=${passwordUpdate}`;
function PasswordResetPage() {
return (
<>
<Heading level={4}>
@@ -30,7 +31,7 @@ function PasswordResetPage() {
<PasswordResetRequestContainer redirectPath={redirectPath} />
<div className={'flex justify-center text-xs'}>
<Link href={pathsConfig.auth.signIn}>
<Link href={signIn}>
<Button variant={'link'} size={'sm'}>
<Trans i18nKey={'auth:passwordRecoveredQuestion'} />
</Button>

View File

@@ -1,6 +1,6 @@
import { redirect } from 'next/navigation';
import { PasswordResetForm } from '@kit/auth/password-reset';
import { UpdatePasswordForm } from '@kit/auth/password-reset';
import { AuthLayoutShell } from '@kit/auth/shared';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
@@ -18,7 +18,7 @@ export const generateMetadata = async () => {
};
};
async function PasswordResetPage() {
async function UpdatePasswordPage() {
const client = getSupabaseServerComponentClient();
const auth = await requireUser(client);
@@ -29,9 +29,9 @@ async function PasswordResetPage() {
return (
<AuthLayoutShell Logo={AppLogo}>
<PasswordResetForm redirectTo={pathsConfig.app.home} />
<UpdatePasswordForm redirectTo={pathsConfig.app.home} />
</AuthLayoutShell>
);
}
export default withI18n(PasswordResetPage);
export default withI18n(UpdatePasswordPage);

View File

@@ -1,3 +1,5 @@
import { cache } from 'react';
import { cookies, headers } from 'next/headers';
import {
@@ -21,7 +23,7 @@ import { i18nResolver } from './i18n.resolver';
*
* Initialize the i18n instance for every RSC server request (eg. each page/layout)
*/
export function createI18nServerInstance() {
function createInstance() {
const acceptLanguage = headers().get('accept-language');
const cookie = cookies().get(I18N_COOKIE_NAME)?.value;
@@ -42,3 +44,5 @@ export function createI18nServerInstance() {
return initializeServerI18n(settings, i18nResolver);
}
export const createI18nServerInstance = cache(createInstance);

View File

@@ -28,7 +28,7 @@ import { Trans } from '@kit/ui/trans';
import { PasswordResetSchema } from '../schemas/password-reset.schema';
export function PasswordResetForm(params: { redirectTo: string }) {
export function UpdatePasswordForm(params: { redirectTo: string }) {
const updateUser = useUpdateUser();
const form = useForm<z.infer<typeof PasswordResetSchema>>({

View File

@@ -1,2 +1,2 @@
export * from './components/password-reset-request-container';
export * from './components/password-reset-form';
export * from './components/update-password-form';