import type { LegacyPageResult } from '#/api/legacy/system';

import { requestClient } from '#/api/request';

const SPECIFIED_GIFT_WEEKLY_RANK_BASE =
  '/go/resident-activity/specified-gift-weekly-rank';
const SIGN_IN_REWARD_BASE = '/go/resident-activity/sign-in-reward';

export async function getResidentInviteConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>('/resident-activity/invite/config', {
    params: { sysOrigin },
  });
}

export async function saveResidentInviteConfig(data: Record<string, any>) {
  return requestClient.post('/resident-activity/invite/config/save', data);
}

export async function pageResidentInviteInviter(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    '/resident-activity/invite/inviter/page',
    { params },
  );
}

export async function pageResidentInviteInvitee(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    '/resident-activity/invite/invitee/page',
    { params },
  );
}

export async function getResidentRegisterRewardConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>('/resident-activity/register-reward/config', {
    params: { sysOrigin },
  });
}

export async function saveResidentRegisterRewardConfig(data: Record<string, any>) {
  return requestClient.post('/resident-activity/register-reward/config/save', data);
}

export async function resetResidentRegisterRewardConfig(sysOrigin: string) {
  return requestClient.post('/resident-activity/register-reward/config/reset', {}, {
    params: { sysOrigin },
  });
}

export async function pageResidentRegisterRewardDailyRecords(
  params: Record<string, any>,
) {
  return requestClient.get<Record<string, any>>(
    '/go/resident-activity/register-reward/daily-record/page',
    { params },
  );
}

export async function getResidentSignInRewardConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${SIGN_IN_REWARD_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveResidentSignInRewardConfig(data: Record<string, any>) {
  return requestClient.post(`${SIGN_IN_REWARD_BASE}/config/save`, data);
}

export async function pageResidentSignInRewardRecords(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(`${SIGN_IN_REWARD_BASE}/record/page`, {
    params,
  });
}

export async function pageSpecifiedGiftWeeklyRankConfigs(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/config/page`,
    { params },
  );
}

export async function getSpecifiedGiftWeeklyRankConfig(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/config`,
    { params },
  );
}

export async function saveSpecifiedGiftWeeklyRankConfig(data: Record<string, any>) {
  return requestClient.post(`${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/config/save`, data);
}

export async function pageSpecifiedGiftWeeklyRankSnapshots(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/snapshot/page`,
    { params },
  );
}

export async function pageSpecifiedGiftWeeklyRankRewardRecords(
  params: Record<string, any>,
) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/reward-record/page`,
    { params },
  );
}

export async function retrySpecifiedGiftWeeklyRankRewardRecord(id: number | string) {
  return requestClient.post<Record<string, any>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/reward-record/retry`,
    { id },
  );
}

export async function getWeekStarConfig(params: Record<string, any>) {
  return getSpecifiedGiftWeeklyRankConfig(params);
}

export async function saveWeekStarConfig(data: Record<string, any>) {
  return saveSpecifiedGiftWeeklyRankConfig(data);
}

export async function pageWeekStarConfigs(params: Record<string, any>) {
  return pageSpecifiedGiftWeeklyRankConfigs(params);
}

export async function pageWeekStarSnapshots(params: Record<string, any>) {
  return pageSpecifiedGiftWeeklyRankSnapshots(params);
}

export async function pageWeekStarRewardRecords(params: Record<string, any>) {
  return pageSpecifiedGiftWeeklyRankRewardRecords(params);
}

export async function retryWeekStarRewardRecord(id: number | string) {
  return retrySpecifiedGiftWeeklyRankRewardRecord(id);
}
