import { MockMethod } from 'vite-plugin-mock'
import { type TypeDescriptor } from '@cacp/ui'
import mockjs from 'mockjs'

const areaCodes: TypeDescriptor[] = [
  { name: '北京', code: '110000' },
  { name: '天津', code: '120000' },
  { name: '河北', code: '130000' },
  { name: '山西', code: '140000' },
  { name: '内蒙古', code: '150000' },
  { name: '辽宁', code: '210000' },
  { name: '吉林', code: '220000' },
  { name: '黑龙江', code: '230000' },
  { name: '上海', code: '310000' },
  { name: '江苏', code: '320000' },
  { name: '浙江', code: '330000' },
  { name: '安徽', code: '340000' },
  { name: '福建', code: '350000' },
  { name: '江西', code: '360000' },
  { name: '山东', code: '370000' },
  { name: '河南', code: '410000' },
  { name: '湖北', code: '420000' },
  { name: '湖南', code: '430000' },
  { name: '广东', code: '440000' },
  { name: '广西', code: '450000' },
  { name: '海南', code: '460000' },
  { name: '重庆', code: '500000' },
  { name: '四川', code: '510000' },
  { name: '贵州', code: '520000' },
  { name: '云南', code: '530000' },
  { name: '西藏', code: '540000' },
  { name: '陕西', code: '610000' },
  { name: '甘肃', code: '620000' },
  { name: '青海', code: '630000' },
  { name: '宁夏', code: '640000' },
  { name: '新疆', code: '650000' },
  { name: '香港', code: '810000' },
  { name: '澳门', code: '820000' },
  { name: '台湾', code: '850000' }
]
const mockMethodArea: MockMethod[] = [
  {
    url: '/mock/api/areaCodes',
    method: 'get',
    timeout: 1000,
    response: () => {
      return {
        code: '0',
        data: areaCodes,
        message: ''
      }
    }
  }
]
mockjs.Random.extend({
  areacode: function () {
    return this.pick(areaCodes).code
  }
})
export default mockMethodArea
