export interface ISignupRequest {
  firstName: string;
  lastName: string;
  email: string;
  password: string;
  rankId: string;
}

export interface ISignupResponseData {
  signUpToken: string;
}

export interface IVerifyEmailRequest {
  signUpToken: string;
  code: string;
  type: string;
}

export interface IResendOtpRequest {
  signUpToken: string;
}

export interface ISigninRequest {
  email: string;
  password: string;
}

export interface ISigninResponseData {
  id: number;
  email: string;
  username: string | null;
  countryCode: string | null;
  mobile: string | null;
  status: number;
  createdAt: string;
  updatedAt: string;
  userProfile: IUserProfile;
  userSetting: IUserSetting;
  userAccounts: IUserAccount[];
  userSubscription: IUserSubscription;
  userRoles: IUserRole[];
  token: string;
  refreshToken: string;
  accountId: number;
}

export interface IUserProfile {
  name: string;
  referralCode: string;
  sessionCount: number;
  accuracy: number;
  obesity: number;
  diabetic: number;
  promptionalPoints: number;
  redeemedPromptionalPoints: number;
  referralPoints: number;
  redeemedReferralPoints: number;
  maxDiscount: number;
  presentRankSince: string | null;
  presentCompany: string | null;
  presentCompanySince: string | null;
  aboutMe: string | null;
  areaOfExpertise: string | null;
  followersCount: number;
  followingCount: number;
  socialMediaLinks: ISocialMediaLink[] | null;
  profileImageId: number | null;
  profileImage: IProfileImage | null;
  rank: IRank;
  dob?: string | null;
  nationality?: string | null;
  // Public-profile activity counts (present on GET /user/{id}/profile).
  questionCount?: number;
  answerCount?: number;
  answerCommentCount?: number;
  postCommentCount?: number;
  seaQALikesCount?: number;
}

export interface ISocialMediaLink {
  platform: string;
  url: string;
}

export interface IProfileImage {
  id: number;
  fileName: string;
  uniqueName: string;
  filePath: string;
  cdnUrl?: string;
}

export interface IRank {
  id: number;
  name: string;
  category: string;
}

// Billing region drives which currency the subscription plans are priced in:
// INDIA → INR, OUTSIDE_INDIA → USD. `null` means the user hasn't chosen yet.
export type BillingRegion = "INDIA" | "OUTSIDE_INDIA";

export interface IUserSetting {
  twoFactorAuthentication: boolean;
  temporaryPassword: boolean;
  notificationCount: number;
  selectedTheme: number;
  profileQuestionnaireCompleted: boolean;
  profileDetailedQuestionnaireCompleted: boolean;
  interestSelected: boolean;
  isPremium: boolean;
  securityDeclaration: boolean;
  billingRegion: BillingRegion | null;
}

export interface IUpdateBillingRegionRequest {
  billingRegion: BillingRegion;
}

export interface IUserAccount {
  id: number;
  name: string;
  key: string;
}

export interface IUserSubscription {
  id: number;
  currentPeriodStart: string;
  currentPeriodEnd: string;
  planData: IPlanData;
  status: number;
  giftCardId: number | null;
  autoRenew: boolean;
}

export interface IPlanData {
  autoRenew: number;
  name: string;
  amount: number;
  planId: string | null;
  priceId: string | null;
  currency: string;
  interval: string | null;
  // Billing-cycle snapshot for the subscription (used to render "every month" /
  // "every 6 months"). Optional — not guaranteed on every subscription record.
  duration?: number | null;
  frequency?: string | null;
  description: string;
  descriptionText: string;
  externalPriceId: string | null;
  externalProductId: string | null;
}

export interface IUserRole {
  id: number;
  code: string;
  name: string;
  rolePermissions: any[];
}

export interface IGetProfileResponse {
  id: number;
  accountId: number;
  email: string;
  username: string | null;
  countryCode: string | null;
  mobile: string | null;
  status: number;
  createdAt: string;
  updatedAt: string;
  userProfile: IUserProfile;
  userSetting: IUserSetting;
  userSubscription: IUserSubscription | null;
  userRoles: IUserRole[];
  userAccounts: IUserAccount[];
}

export interface IUpdateProfileRequest {
  profileImageId?: number;
  name?: string;
  email?: string;
  dob?: string | null;
  rankId?: number;
  presentRankSince?: string | null;
  presentCompany?: string | null;
  presentCompanySince?: string | null;
  aboutMe?: string | null;
  areaOfExpertise?: string | null;
  nationality?: string | null;
  socialMediaLinks?: ISocialMediaLink[] | null;
}

export interface IUploadAttachmentResponse {
  id: number;
  filePath: string;
  uniqueName: string;
  fileName: string;
  extension: string;
  type: number;
  status: number;
  size: number;
  createdAt: string;
  updatedAt: string;
  thumbnails: {
    original: string;
    originalWebp: string;
    sizes: Record<string, string>;
    sizesWebp: Record<string, string>;
  };
}

export interface IFollowProfileImage {
  id: number;
  cdnUrl: string;
  fileName: string;
  filePath: string;
  uniqueName: string;
}

export interface IFollowUserProfile {
  name: string;
  followersCount: number;
  followingCount: number;
  rank: { id: number; name: string; category: string | null } | null;
}

// Explore directory (/user/public/list) returns a leaner shape than the follow
// lists: name/profileImage/rank live under userProfile, there's no online
// status, and the follow flag is `isFollowing` rather than `isFollowedByMe`.
export interface IExploreUser {
  id: number;
  email: string;
  isFollowing: boolean;
  followersCount: number;
  followingCount: number;
  userProfile: {
    name: string;
    profileImage: IFollowProfileImage | null;
    rank: { id: number; name: string; category: string | null } | null;
    followersCount: number;
    followingCount: number;
  };
}

export interface IFollowUser {
  id: number;
  onlineStatus: number;
  name: string;
  profileImage: IFollowProfileImage | null;
  isFollowedByMe: boolean;
  userProfile: IFollowUserProfile;
}

export interface IFollowingItem {
  id: number;
  createdAt: string;
  following: IFollowUser;
}

export interface IFollowerItem {
  id: number;
  createdAt: string;
  follower: IFollowUser;
}

export interface IFollowListResponse<T> {
  data: T[];
  page: number;
  perPage: number;
  totalRecords: number;
  totalPages: number;
}

export interface IForgotPasswordRequest {
  email: string;
}

export interface IForgotPasswordResponse {
  resetPasswordToken: string;
}

export interface IResetPasswordRequest {
  resetPasswordToken: string;
  verificationCode: string;
  password: string;
}
