import { ResponseDataEntity, smaproFetch, appHomeFetch } from './index';

export enum ServiceTypeParams {
  wechatPublicV = 1,
  wechatAppV = 2,
  aliPublicV = 3,
  aliAppV = 4,
}

export type ServiceParams = {
  areaId: number;
  type: ServiceTypeParams;
};
export type Service = {
  serviceId: number;
  serviceName: string;
};

export const fetchAreaService = (
  data: ServiceParams,
): Promise<ResponseDataEntity<Service[]>> =>
  smaproFetch({
    url: `/smpro/areaServiceConfigs/${data.areaId}/${data.type}`,
  });

export enum PublishClient {
  android = '1',
  ios = '2',
  wx = '3',
}
type NoticeParams = {
  customerId: number;
  publishClient: PublishClient;
};
enum NoticeState {
  published = 1,
  unpublished = 0,
}
export type AppHomeNoticeAppVo = {
  content: string; // 内容
  createAt: string; // 创建时间
  id: number; // 主键ID
  noticeCode: string; // 公告编码
  noticeImgs: string; // 公告图片
  noticeTitle: string; // 公告名称
  noticeType: string; // 强弹类型 1是 2否
  operateId: number; // 运营商ID
  operator: string; // 操作人
  publishClient: PublishClient; // 发布端
  sortId: number; // 排序号
  state: NoticeState; // 状态 1已发布 0未发布
  updateAt: string; // 更新时间
  whetherClicked: boolean; // 是否点击false为否true为是
};
export const fetchLastNotice = (
  entity: NoticeParams,
): Promise<ResponseDataEntity<AppHomeNoticeAppVo>> =>
  appHomeFetch({
    url: '/app/home/module/newest/notice',
    data: entity,
  });

export const fetchNoticesData = (
  entity: NoticeParams,
): Promise<ResponseDataEntity<AppHomeNoticeAppVo[]>> =>
  appHomeFetch({
    url: '/app/home/module/notice',
    data: entity,
  });
