import { BaseResponse } from "@/app/[name]/(Main)/types/Types";

export interface ServiceArea {
  type: "Polygon";
  coordinates: number[][][];
}

export interface Score {
  scoreAmount: string;
  scoreCredit: string;
  birthdayScore: string;
  purchaseScore: string;
  referrerScore: string;
  registerScore: string;
  purchaseAmount: string;
  marriageDateScore: string;
}

export interface Restaurant {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  name: string;
  slug: string;
  logo: string | null;
  address: string | null;
  menuColor: string | null;
  latitude: number | null;
  longitude: number | null;
  serviceArea: ServiceArea;
  isActive: boolean;
  establishedYear: number | null;
  phoneNumber: string | null;
  phone?: string | null;
  phones?: string[];
  instagram: string | null;
  telegram: string | null;
  whatsapp: string | null;
  description: string | null;
  seoTitle: string | null;
  seoDescription: string | null;
  tagNames: string[] | null;
  images: string[] | null;
  vat: number;
  domain: string;
  score: Score;
  plan: "base" | "premium";
  enableAiChat?: boolean;
  bgType?: "pattern" | "custom" | "color";
  bgBlur?: number;
  bgOpacity?: number;
  bgOverlay?: string;
  bgUrl?: string;
}

export interface ReviewFood {
  id: string;
  createdAt?: string;
  updatedAt?: string;
  deletedAt?: string | null;
  restaurant?: string;
  category?: string;
  title: string;
  desc?: string | null;
  content?: string[] | string | null;
  price?: number;
  points?: number | null;
  order?: number | null;
  prepareTime?: number | null;
  weekDays?: number[];
  mealTypes?: string[];
  sat?: boolean;
  sun?: boolean;
  mon?: boolean;
  breakfast?: boolean;
  noon?: boolean;
  dinner?: boolean;
  stock?: number;
  stockDefault?: number;
  isActive?: boolean;
  images?: string[];
  inPlaceServe?: boolean;
  pickupServe?: boolean;
  rate?: number;
  score?: number;
  discount?: number;
  isSpecialOffer?: boolean;
}

export interface ReviewUser {
  id: string;
  createdAt?: string;
  updatedAt?: string;
  deletedAt?: string | null;
  firstName: string;
  lastName: string;
  birthDate?: string;
  marriageDate?: string;
  referrer?: string | null;
  isActive?: boolean;
  gender?: boolean;
  wallet?: number;
  points?: number;
  phone?: string;
  avatarUrl?: string | null;
}

export type ReviewStatus = "approved" | "pending" | "rejected";

export interface ReviewAdmin {
  id: string;
  firstName?: string | null;
  lastName?: string | null;
}

export interface Review {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  isBuyer?: boolean;
  order?: string;
  food: ReviewFood;
  user?: ReviewUser | null;
  admin?: ReviewAdmin | null;
  comment: string;
  rating: number;
  positivePoints: string[];
  negativePoints: string[];
  status?: ReviewStatus;
  parent?: string | { id: string } | Review | null;
  /** @deprecated use status */
  isApproved?: boolean;
}

export function isReviewApproved(review: Review): boolean {
  if (review.status) {
    return review.status === "approved";
  }
  return review.isApproved === true;
}

export interface Schedule {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  weekDay: number;
  openTime: string;
  closeTime: string;
  isActive: boolean;
  restId: string;
}

export type AboutResponse = BaseResponse<Restaurant>;
export type ReviewsResponse = BaseResponse<Review[]>;
export type SchedulesResponse = BaseResponse<Schedule[]>;
