feat(core): support signup set password before goto stripe payment url (#4892)

This commit is contained in:
Joooye_34
2023-11-09 19:58:16 +08:00
committed by GitHub
parent 405167854b
commit af72bf0f69
8 changed files with 143 additions and 53 deletions
@@ -1,8 +1,10 @@
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { Button } from '@toeverything/components/button';
import { useSetAtom } from 'jotai';
import type { FC } from 'react';
import { useCallback, useState } from 'react';
import { pushNotificationAtom } from '../notification-center';
import { AuthPageContainer } from './auth-page-container';
import { SetPassword } from './set-password';
type User = {
@@ -14,18 +16,27 @@ type User = {
export const ChangePasswordPage: FC<{
user: User;
onSetPassword: (password: string) => void;
onSetPassword: (password: string) => Promise<void>;
onOpenAffine: () => void;
}> = ({ user: { email }, onSetPassword: propsOnSetPassword, onOpenAffine }) => {
const t = useAFFiNEI18N();
const [hasSetUp, setHasSetUp] = useState(false);
const pushNotification = useSetAtom(pushNotificationAtom);
const onSetPassword = useCallback(
(passWord: string) => {
propsOnSetPassword(passWord);
setHasSetUp(true);
propsOnSetPassword(passWord)
.then(() => setHasSetUp(true))
.catch(e =>
pushNotification({
title: t['com.affine.auth.password.set-failed'](),
message: String(e),
key: Date.now().toString(),
type: 'error',
})
);
},
[propsOnSetPassword]
[propsOnSetPassword, t, pushNotification]
);
return (