admin-panel-front/src/pages/Login/Login.tsx
2026-08-03 14:46:58 +03:30

59 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { App, Button, Card, Form, Input, Typography } 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 { message } = App.useApp();
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;