chore: format project automatically before starting dev server
This commit is contained in:
@@ -44,35 +44,81 @@ export default function AuthModal() {
|
||||
await auth.loginPassword(currentPhone, values.password || '');
|
||||
}
|
||||
} catch (caught) {
|
||||
setError(caught instanceof Error && caught.message === 'INVALID_PHONE' ? copy.invalidPhone : copy.invalidCredentials);
|
||||
setError(
|
||||
caught instanceof Error && caught.message === 'INVALID_PHONE'
|
||||
? copy.invalidPhone
|
||||
: copy.invalidCredentials,
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal open={auth.loginOpen} onCancel={auth.closeLogin} footer={null} centered title={copy.login} destroyOnClose>
|
||||
<Segmented<LoginMode> block value={mode} onChange={value => {setMode(value); setStep('phone'); setError('');}}
|
||||
options={[{label: copy.otpLogin, value: 'otp'}, {label: copy.passwordLogin, value: 'password'}]}/>
|
||||
<Alert className="mt-5" type="info" showIcon message={copy.demoTitle}
|
||||
description={<div><div>{copy.demoOtp}</div><div>{copy.demoPassword}</div></div>}/>
|
||||
{error && <Alert className="mt-4" type="error" showIcon message={error}/>}
|
||||
<Form layout="vertical" className="mt-5" onFinish={submit} initialValues={{phone: '09123456789', code: '12345', password: '123456'}}>
|
||||
<Modal
|
||||
open={auth.loginOpen}
|
||||
onCancel={auth.closeLogin}
|
||||
footer={null}
|
||||
centered
|
||||
title={copy.login}
|
||||
destroyOnClose
|
||||
>
|
||||
<Segmented<LoginMode>
|
||||
block
|
||||
value={mode}
|
||||
onChange={value => {
|
||||
setMode(value);
|
||||
setStep('phone');
|
||||
setError('');
|
||||
}}
|
||||
options={[
|
||||
{label: copy.otpLogin, value: 'otp'},
|
||||
{
|
||||
label: copy.passwordLogin,
|
||||
value: 'password',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Alert
|
||||
className="mt-5"
|
||||
type="info"
|
||||
showIcon
|
||||
message={copy.demoTitle}
|
||||
description={
|
||||
<div>
|
||||
<div>{copy.demoOtp}</div>
|
||||
<div>{copy.demoPassword}</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
{error && <Alert className="mt-4" type="error" showIcon message={error} />}
|
||||
<Form
|
||||
layout="vertical"
|
||||
className="mt-5"
|
||||
onFinish={submit}
|
||||
initialValues={{phone: '09123456789', code: '12345', password: '123456'}}
|
||||
>
|
||||
{(mode === 'password' || step === 'phone') && (
|
||||
<Form.Item name="phone" label={copy.phone} rules={[{required: true, pattern: /^09\d{9}$/, message: copy.invalidPhone}]}>
|
||||
<Input dir="ltr" size="large" maxLength={11} prefix={<MobileOutlined/>}/>
|
||||
<Form.Item
|
||||
name="phone"
|
||||
label={copy.phone}
|
||||
rules={[{required: true, pattern: /^09\d{9}$/, message: copy.invalidPhone}]}
|
||||
>
|
||||
<Input dir="ltr" size="large" maxLength={11} prefix={<MobileOutlined />} />
|
||||
</Form.Item>
|
||||
)}
|
||||
{mode === 'password' && (
|
||||
<Form.Item name="password" label={copy.password} rules={[{required: true}]}>
|
||||
<Input.Password dir="ltr" size="large" prefix={<LockOutlined/>}/>
|
||||
<Input.Password dir="ltr" size="large" prefix={<LockOutlined />} />
|
||||
</Form.Item>
|
||||
)}
|
||||
{mode === 'otp' && step === 'code' && (
|
||||
<>
|
||||
<Typography.Paragraph type="secondary">{copy.phone}: <span dir="ltr">{phone}</span></Typography.Paragraph>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{copy.phone}: <span dir="ltr">{phone}</span>
|
||||
</Typography.Paragraph>
|
||||
<Form.Item name="code" label={copy.otp} rules={[{required: true}]}>
|
||||
<Input dir="ltr" size="large" maxLength={5} prefix={<SafetyCertificateOutlined/>}/>
|
||||
<Input dir="ltr" size="large" maxLength={5} prefix={<SafetyCertificateOutlined />} />
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user