style(web): format invitation flows

This commit is contained in:
dadachann
2026-07-26 14:01:20 +08:00
parent e90a1546de
commit d71bd571b1
2 changed files with 69 additions and 56 deletions
+12 -5
View File
@@ -92,7 +92,8 @@ export default function AcceptInvitationPage() {
const [errorMessage, setErrorMessage] = useState('');
const [password, setPassword] = useState('');
const [confirmPassword, setConfirmPassword] = useState('');
const [passwordRegistrationEnabled, setPasswordRegistrationEnabled] = useState(false);
const [passwordRegistrationEnabled, setPasswordRegistrationEnabled] =
useState(false);
useEffect(() => {
const handleHashChange = () => setInvitationHash(window.location.hash);
@@ -109,9 +110,12 @@ export default function AcceptInvitationPage() {
'error',
);
setToken(invitationToken);
backendClient.getAccountInfo().then((info) => {
setPasswordRegistrationEnabled(info.password_login_enabled !== false);
}).catch(() => setPasswordRegistrationEnabled(false));
backendClient
.getAccountInfo()
.then((info) => {
setPasswordRegistrationEnabled(info.password_login_enabled !== false);
})
.catch(() => setPasswordRegistrationEnabled(false));
if (!invitationToken) {
setErrorMessage(t('workspace.invitationMissing'));
setStatus('error');
@@ -398,7 +402,10 @@ export default function AcceptInvitationPage() {
</Button>
</>
) : (
<Button className="w-full" onClick={() => navigate('/login?invitation=1&auto=space')}>
<Button
className="w-full"
onClick={() => navigate('/login?invitation=1&auto=space')}
>
{t('common.loginWithSpace')}
</Button>
)}
+57 -51
View File
@@ -44,7 +44,8 @@ export default function Register() {
const navigate = useNavigate();
const { t } = useTranslation();
const [spaceLoading, setSpaceLoading] = useState(false);
const [passwordRegistrationEnabled, setPasswordRegistrationEnabled] = useState(true);
const [passwordRegistrationEnabled, setPasswordRegistrationEnabled] =
useState(true);
const form = useForm<z.infer<ReturnType<typeof formSchema>>>({
resolver: zodResolver(formSchema(t)),
@@ -58,7 +59,9 @@ export default function Register() {
getIsInitialized();
httpClient
.getAccountInfo()
.then((info) => setPasswordRegistrationEnabled(info.password_login_enabled !== false))
.then((info) =>
setPasswordRegistrationEnabled(info.password_login_enabled !== false),
)
.catch(() => setPasswordRegistrationEnabled(true));
}, []);
@@ -179,57 +182,60 @@ export default function Register() {
{/* Local Account Registration */}
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>{t('common.email')}</FormLabel>
<FormControl>
<div className="relative">
<Mail className="absolute left-3 top-3 h-4 w-4 text-gray-400" />
<Input
placeholder={t('common.enterEmail')}
className="pl-10"
{...field}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="space-y-6"
>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>{t('common.email')}</FormLabel>
<FormControl>
<div className="relative">
<Mail className="absolute left-3 top-3 h-4 w-4 text-gray-400" />
<Input
placeholder={t('common.enterEmail')}
className="pl-10"
{...field}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="password"
render={({ field }) => (
<FormItem>
<FormLabel>{t('common.password')}</FormLabel>
<FormControl>
<div className="relative">
<Lock className="absolute left-3 top-3 h-4 w-4 text-gray-400" />
<Input
type="password"
placeholder={t('common.enterPassword')}
className="pl-10"
{...field}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="password"
render={({ field }) => (
<FormItem>
<FormLabel>{t('common.password')}</FormLabel>
<FormControl>
<div className="relative">
<Lock className="absolute left-3 top-3 h-4 w-4 text-gray-400" />
<Input
type="password"
placeholder={t('common.enterPassword')}
className="pl-10"
{...field}
/>
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button
type="submit"
variant="outline"
className="w-full cursor-pointer"
>
{t('register.registerWithPassword')}
</Button>
<Button
type="submit"
variant="outline"
className="w-full cursor-pointer"
>
{t('register.registerWithPassword')}
</Button>
</form>
</Form>
</>