import { z } from 'zod'

export const portalLoginSchema = z.object({
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
  password: z.string().min(6, '密码至少6位'),
})

export const portalSendCodeSchema = z.object({
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
})

export const portalVerifyCodeSchema = z.object({
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
  code: z.string().length(6, '验证码为6位数字'),
})

export const onboardingSchema = z.object({
  token: z.string().min(1, '缺少 token'),
  name: z.string().min(1, '姓名不能为空'),
  phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
  idCard: z.string().min(15, '身份证号格式不正确').max(18),
  emergencyContact: z.string().optional(),
  emergencyPhone: z.string().optional(),
  address: z.string().optional(),
  bankCard: z.string().optional(),
  bankName: z.string().optional(),
})

export const contractConfirmSchema = z.object({
  token: z.string().min(1, '缺少 token'),
  agreed: z.boolean().refine((v) => v === true, '请勾选确认签署'),
  verifyCode: z.string().length(6, '验证码为6位数字'),
})

export const contractSendCodeSchema = z.object({
  token: z.string().min(1, '缺少 token'),
})
