export const roles = [
  { id: 1, name: 'admin' },
  { id: 2, name: 'counselor' },
  { id: 3, name: 'missionary' },
  { id: 4, name: 'student' },
  { id: 5, name: 'teacher' },
]

const provinces = [
  { id: 1, name: 'تهران' },
  { id: 2, name: 'اصفهان' },
  { id: 3, name: 'فارس' },
  { id: 4, name: 'خراسان رضوی' },
]
const cities = {
  1: [
    { id: 11, name: 'تهران' },
    { id: 12, name: 'شمیرانات' },
  ],
  2: [{ id: 21, name: 'اصفهان' }],
  3: [{ id: 31, name: 'شیراز' }],
  4: [{ id: 41, name: 'مشهد' }],
}
const provinceById = (id) => provinces.find((p) => p.id === id) || provinces[0]
const cityForProvince = (id) => cities[id]?.[0] || cities[1][0]

const firstNames = [
  'فاطمه',
  'زهرا',
  'مریم',
  'علی',
  'حسین',
  'محمد',
  'سمیه',
  'نرگس',
  'حسن',
  'رضا',
  'مهدی',
  'الهام',
  'پروانه',
  'ساره',
  'مهسا',
]
const lastNames = [
  'رضایی',
  'محمدی',
  'حسینی',
  'احمدی',
  'جعفری',
  'علوی',
  'موسوی',
  'صالحی',
  'فاطمی',
  'کریمی',
  'تقوی',
  'مرادی',
  'هاشمی',
  'بهرامی',
]

const pick = (arr, i) => arr[i % arr.length]

const makeUser = (i, overrides = {}) => {
  const firstName = pick(firstNames, i)
  const lastName = pick(lastNames, i + 3)
  const province = provinceById((i % 4) + 1)
  const city = cityForProvince(province.id)
  const role = roles[(i % 4) + 1]?.name || 'student'
  const id = 100 + i
  const phoneNumber = `0912${String(1_000_000 + i).padStart(7, '0')}`
  return {
    // --- spec (GET /admin/users) ---
    id,
    name: `${firstName} ${lastName}`,
    email: `user${id}@example.com`,
    phone: phoneNumber.replace(/^0/, '+98'),
    roles: [role],
    avatarUrl: '',
    avatarDownloadUrl: '',
    createdAt: new Date(Date.now() - i * 86_400_000).toISOString(),
    birthday: new Date(1990, i % 12, ((i * 3) % 27) + 1).toISOString(),

    // --- ui-only (pending backend) ---
    firstName,
    lastName,
    fullName: `${firstName} ${lastName}`,
    phoneNumber,
    nationalCode: String(1_000_000_000 + i * 7).padStart(10, '0'),
    status: i % 5 === 0 ? 'pending' : i % 3 === 0 ? 'verified' : 'approved',
    roleId: roles.find((r) => r.name === role)?.id,
    address: {
      address: 'آدرس نمونه',
      province,
      city,
    },
    profile: {
      bio: '',
      maritalStatus: i % 2 ? 'single' : 'married',
      gender: i % 2 ? 'female' : 'male',
    },
    ...overrides,
  }
}

export const adminUsers = Array.from({ length: 24 }, (_, i) => makeUser(i))
