58 lines
2 KiB
TypeScript
58 lines
2 KiB
TypeScript
import { Button, Card, Form, Input, Typography, message } from 'antd';
|
||
import { useNavigate } from 'react-router-dom';
|
||
import { authService } from '../../features/auth/authService';
|
||
import { colors } from '../../design/tokens/colors';
|
||
import { spacing } from '../../design/tokens/spacing';
|
||
|
||
const { Title, Paragraph } = Typography;
|
||
|
||
interface LoginFormValues {
|
||
phoneNumber: string;
|
||
}
|
||
|
||
const Login = () => {
|
||
const navigate = useNavigate();
|
||
const [form] = Form.useForm<LoginFormValues>();
|
||
|
||
const onFinish = async (values: LoginFormValues) => {
|
||
try {
|
||
await authService.sendOtp(values.phoneNumber);
|
||
localStorage.setItem('pending_phone_number', values.phoneNumber);
|
||
message.success('کد تایید ارسال شد');
|
||
navigate('/verify-otp');
|
||
} catch {
|
||
message.error('ارسال کد تایید با خطا مواجه شد');
|
||
}
|
||
};
|
||
|
||
return (
|
||
<div style={{ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', background: colors.primaryLight, direction: 'rtl' }}>
|
||
<Card style={{ width: 420, boxShadow: '0 12px 32px rgba(35, 62, 95, 0.12)', border: `1px solid ${colors.primaryLight}` }}>
|
||
<Title level={3} style={{ marginBottom: spacing.sm, color: colors.primary }}>
|
||
ورود به پنل ادمین
|
||
</Title>
|
||
<Paragraph style={{ color: colors.textSecondary }}>
|
||
برای ادامه شماره موبایل خود را وارد کنید.
|
||
</Paragraph>
|
||
|
||
<Form form={form} layout="vertical" onFinish={onFinish}>
|
||
<Form.Item
|
||
label="شماره موبایل"
|
||
name="phoneNumber"
|
||
rules={[{ required: true, message: 'شماره موبایل الزامی است' }]}
|
||
>
|
||
<Input placeholder="09123456789" size="large" />
|
||
</Form.Item>
|
||
|
||
<Form.Item>
|
||
<Button type="primary" htmlType="submit" size="large" block>
|
||
ارسال کد تایید
|
||
</Button>
|
||
</Form.Item>
|
||
</Form>
|
||
</Card>
|
||
</div>
|
||
);
|
||
};
|
||
|
||
export default Login;
|