// eslint-disable-next-line @typescript-eslint/no-explicit-any
const wrapperData = (data: any, code: number = 200, message: string = 'success') => {
  if (code === 200) {
    return data;
  }
  return {
    data,
    code,
    message,
  };
};

let jobId = 0;
const getJobData = (size: number) =>
  new Array(size).fill(1).map(() => ({
    id: `${jobId++}`,
    title: '滨江品牌淑女装兼职主播滨江品牌淑女装兼职主播滨江品牌淑女装兼职主播',
    tags: ['女装', '抖音', '快手', '视频号', '直播 4-5h'],
    employType: 'ALL',
    salary: '时薪 200-300',
    jobDescription: 'TOP级账号！5年直播团队体系成熟！',
    publisher: '杭州主播群3-甲子',
    publisherAvatar: '',
    jobLocation: {
      latitude: 39.961,
      longitude: 116.4551,
      cityCode: '430100',
      countyCode: '430121',
      address: '朝阳区望京街道',
    },
  }));

const JOB_DETAIL_DATA = {
  id: `abcs`,
  title: '滨江品牌淑女装兼职主播滨江品牌淑女装兼职主播滨江品牌淑女装兼职主播',
  tags: ['女装', '抖音', '快手', '视频号', '直播 4-5h'],
  employType: 'ALL',
  salary: '时薪 200-300',
  jobDescription: 'TOP级账号！5年直播团队体系成熟！',
  publisher: '杭州主播群3-甲子',
  publisherAvatar: '',
  jobLocation: {
    latitude: 39.961,
    longitude: 116.4551,
    cityCode: '430100',
    countyCode: '430121',
    address: '朝阳区望京街道',
  },
  created: 1719122520631,
  updated: 1719122520631,
  imGroupId: '12345',
  imGroupNick: '服装设计交流群',
  isFollow: false,
  sourceText: `可兼职可全职\n账号：FAIRWHALE时尚旗旗舰店\nTOP级账号!5年直播团队体系成熟!有成熟晋升机制!中少淑穿版好经验不足也可以报名!\n各路女装大神可以来无责分红机制！公司背景强大!资金不是问题!!\n时薪:3-800/H(能给),薪资:2W-8W+1-3%提成\n要求:
1.身高160-168。亲和力强，站播，貌美口齿清晰
2.会控场能带动直播间气氛会拉流量会玩免费流
3.中少淑穿版效果要好
4.场均20-50w的都可以报名，都有机会晋升大号
`,
};

let groupId = 0;
const getGroupList = (size: number) =>
  new Array(size).fill(1).map(() => ({
    id: `${groupId++}`,
    imGroupId: '1',
    imGroupNick: '广州主播主播🍒经纪群🍒经纪群经纪群',
    joinedTime: 1719119060767,
    allJobs: Math.floor(Math.random() * 1000),
    groupAvatar: 'https://neighbourhood.cn/p_d.png',
  }));

const getJobListData = (emptyList: boolean = false) => {
  if (emptyList) {
    return {
      page: 1,
      pageSize: 10,
      hasMore: false,
      jobResults: [],
    };
  }
  return {
    page: 1,
    pageSize: 10,
    hasMore: true,
    jobResults: getJobData(10),
  };
};

const getUserJobListData = (emptyList: boolean = false) => {
  if (emptyList) {
    return {
      page: 1,
      pageSize: 10,
      hasMore: false,
      data: [],
    };
  }
  return {
    page: 1,
    pageSize: 10,
    hasMore: true,
    data: {
      '2024-07-23': getJobData(10),
      '2024-07-22': getJobData(10),
      '2024-07-18': getJobData(10),
    },
  };
};

export const getGroupListData = (emptyList: boolean = false) => {
  if (emptyList) {
    return {
      allGroups: [],
      myJoinedGroups: [],
      myCreatedGroups: [],
      myFollowedGroups: [],
    };
  }
  return {
    allGroups: getGroupList(10),
    myJoinedGroups: getGroupList(10),
    myCreatedGroups: getGroupList(10),
    myFollowedGroups: getGroupList(10),
  };
};

const getProductListData = (emptyList: boolean = false) => {
  if (emptyList) {
    return [];
  }
  return [
    {
      productId: 'job',
      balance: 3,
      created: 1719109060767,
      updated: 1719109060767,
    },
    {
      productId: 'group',
      balance: 2,
      created: 1719109060767,
      updated: 1719109060767,
    },
  ];
};

const mockData = {
  'POST /api/user/login': wrapperData({
    token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
    expires: 3600,
  }),
  'POST /api/location/get': wrapperData({
    provinceCode: '430000',
    provinceDesc: '湖南省',
    cityCode: '430100',
    cityDesc: '长沙市',
  }),
  'POST /api/user/get': wrapperData({
    userId: 'abc',
    nickname: '微信用户9627',
    avatarUrl: '',
    isDefaultAvatar: true,
    isDefaultNickname: true,
    isBindPhone: false,
    // isBindPhone: true,
  }),
  'POST /api/user/setPhone': wrapperData({}),
  'POST /api/userGroup/follow': wrapperData({}),
  'POST /api/userGroup/list': wrapperData(getGroupListData(false)),
  'POST /api/job/search': wrapperData(getJobListData(false)),
  'POST /api/job/searchMyJobs': wrapperData(getJobListData(true)),
  'POST /api/job/get': wrapperData(JOB_DETAIL_DATA),
  'POST /api/job/user/searchMyDeclared': wrapperData(getUserJobListData(false)),
  'POST /api/product/listMyProduct': wrapperData(getProductListData(false)),
  'POST /api/product/getMyProductDetail': wrapperData({ balance: 2 }),
  'POST /api/product/getProductUseRecord': wrapperData(false),
  // 'POST /api/product/getProductUseRecord': wrapperData({}),
  // 'POST /api/product/use': wrapperData({}),
  // 'POST /api/product/getProductUseRecord': wrapperData({
  //   declarationTypeResult: {
  //     type: 0,
  //     publisherAcctNo: 'yeruth',
  //   },
  // }),
  'POST /api/product/use': wrapperData({
    declarationTypeResult: {
      type: 0,
      publisherAcctNo: 'yeruth',
    },
  }),
};

export default mockData;
