import { get, post } from '@/utils/request';

// 登录
export const Login = (data: { username: string; password: string; code: string; uuid: string }) => {
  return post<{
    code: number;
    msg: string;
    token: string;
  }>('/login', data, {
    ignoreStorage: true,
    parseResult: false,
  });
};

// 获取验证码
export const ChaptchaImage = () => {
  return get<{
    uuid: string;
    img: string;
  }>('/captchaImage', undefined, {
    ignoreStorage: true,
    parseResult: false,
  });
};

/** ****************中间底部数据接口****************** */
export interface IYasIslandCampaigns {
  annualPassholdersTotal: string;
  clickRate: number;
  date: string;
  delivered: number;
  emailOpenRate: number;
  expired: number;
  id: number;
  mtdCampaigns: number;
  renewed: number;
  syncTraceId: string;
  synchTime: string;
  totalCampaignEmailSent: number;
}

export const GetYasIslandCampaigns = () => {
  return get<IYasIslandCampaigns>('/kpi/guest_experience/Yas_Island_Campaigns');
};

export interface IJourneyTouchPoint {
  date: string;
  experienceProject: string;
  id: null | number;
  syncTraceId: null | number;
  synchTime: null | string;
  value: number;
}
export const GetJourneyTouchPoint = (park_code: string) => {
  return get<IJourneyTouchPoint[]>(`/kpi/guest_experience/Journey_Touch_Point/${park_code}`);
};

export interface IHappinessMeter {
  date: string;
  happinessMeters: number;
  parkCode: string;
  project: string;
  sentiment: string;
}
export const GetHappinessMeters = (park_code: string) => {
  return get<IHappinessMeter[]>(`/kpi/guest_experience/Happiness_Meters/${park_code}`);
};

export interface IQueueTime {
  date: string;
  parkCode: string;
  project: string;
  queueTime: number;
}
export const GetQueueTime = (park_code: string) => {
  return get<IQueueTime[]>(`/kpi/guest_experience/Queue_Time/${park_code}`);
};

export interface IVisitorBreakdownByCountryOfResidence {
  country: 'China';
  dataDate: null;
  id: null;
  parkCode: null;
  percentage: 13.4;
  syncTraceId: null;
  synchTime: null;
  visitorCount: 1100;
}
export const GetVisitorBreakdownByCountryOfResidence = () => {
  return get<IVisitorBreakdownByCountryOfResidence[]>(
    '/kpi/guest_experience/Visitor_Breakdown_By_Country_Of_Residence',
  );
};

export interface ITransport {
  dataDate: string;
  onTimeRate: number;
  onTimeRateChange: number;
  onScheduleRate: number;
  lineCount: number;
  passengers: Array<{
    passengerCount: number;
    busCount: number;
    dataDate: string;
    day: string;
  }>;
}

export const GetTransport = () => {
  return get<ITransport[]>('/kpi/guest_experience/transport');
};

/** ****************左侧面板数据接口****************** */
export interface IRevenueTracking {
  day: string;
  attendanceTotal: number;
  onsiteConciergeRevenue: number;
  revenueGenerated: number;
  attendance: Array<{
    parkCode: string;
    attendance: number;
  }>;
}
export const GetRevenueTracking = () => {
  return get<IRevenueTracking>('/kpi/revenue_attendance/Revenue_Tracking');
};

interface IVisitorItem {
  parkCode: string;
  current: number;
  pre: number;
}
export interface IVisitorSegmentation {
  apVisitors: {
    lists: IVisitorItem[];
    total: number;
  };
  vipVisitors: {
    lists: IVisitorItem[];
    total: number;
  };
}
export const GetVisitorSegmentation = () => {
  return get<IVisitorSegmentation>('/kpi/revenue_attendance/Visitor_Segmentation');
};

export interface IConciergeByDepartment {
  id: number;
  department: string;
  date: string;
  revenueGenerated: number;
  callSla: number;
  callOffered: number;
  callWaiting: number;
  callCapacity: number;
  callOccupancy: number;
  callAbandonment: number;
  callAht: number;
  callCast: number;
  chatbotSla: number;
  chatbotContactsOffered: number;
  chatbotTransfers: number;
  synchTime: string;
  syncTraceId: string;
}
export const GetConciergeByDepartment = (department: string) => {
  return get<IConciergeByDepartment>(`/kpi/concierge/${department}`);
};

/** ****************右侧面板数据接口****************** */
export interface ISocialMeidaAnalysis {
  googleReviews: {
    value: string;
    preValue: number;
    lists: Array<{
      parkCode: string;
      value: number;
    }>;
  };
  tripAdvisor: {
    value: number;
    preValue: number;
    lists: Array<{
      parkCode: string;
      value: number;
    }>;
  };
}
export const GetSocialMeidaAnalysis = () => {
  return get<ISocialMeidaAnalysis>('/kpi/social-media/analysis');
};

export interface IGoogleReviewsPost {
  id: number;
  subject: string;
  content: string;
  contentUrl: string;
  avatarUrl: string;
  likeNum: number;
  commentCount: number;
  reviewDate: string;
  reposts: number;
  parkCode: string;
  synchTime: string;
  syncTraceId: number;
}
export const GetGoogleReviewsPost = () => {
  return get<IGoogleReviewsPost[]>('/kpi/social-media/googleReviewsPost');
};
export interface IDigitalAnalysis {
  id: number;
  appUptime: string;
  downtimeNotification: number;
  currentAppSessions: number;
  mostUsedScreens: string;
  avgTimespend: number;
  appRevenue: number;
  yasAppCsat: number;
  synchTime: string;
  syncTraceId: string;
}
export const GetDigitalAnalysis = () => {
  return get<IDigitalAnalysis>('/kpi/digital/gx');
};

export interface IWordCloud {
  word: string;
  frequency: number;
}
export const GetWordCloud = (type: 'Google' | 'Trip') => {
  return get<IWordCloud[]>(`/kpi/social-media/worldCloud/${type}`);
};
