// src/templates/types.ts

import { HomeImprovementReceiptData } from 'components/sections/dashboard/Home/Documents/Dialog/HomeImprovementReciptDialogContent';
import { OfferData } from 'components/sections/dashboard/Home/Documents/Dialog/OfferDialogContent';
import { SellerDisclousureData } from 'components/sections/dashboard/Home/Documents/Dialog/SellerDisclousureDialogContent';

export interface NavItem {
  title: string;
  path: string;
  icon?: string;
  active: boolean;
  collapsible: boolean;
  sublist?: NavItem[];
}

// A generic "Category" type
export interface GenericCategory {
  id: string; // Unique identifier for the category
  name: string;
  description: string;
  imageUrl?: string; // Optional image for the category card
  // Add any other common category properties here
}

// A generic "Item" type (e.g., a Video, a Vendor)
export interface GenericItem {
  id: number; // Unique identifier for the item
  name: string; // Corresponds to title for video, name for vendor
  description: string; // Corresponds to description for video, short description for vendor
  // Add any other common item properties here
}

// Data structure for the main template
export interface DashboardData<TCategory extends GenericCategory, TItem extends GenericItem> {
  categories: TCategory[];
  items: TItem[]; // All items, will be filtered by category within the template
}

export interface VideoCategory extends GenericCategory {
  totalVideos: number;
  completedVideos: number;
  categoryProgress: number; // Calculated
}

export interface VideoItem extends GenericItem {
  videoUrl: string;
  progress_id: number;
  status: 'completed' | 'in-progress' | 'not-started';
  progress: number; // 0-100 for individual video progress
  category: string; // Link back to category
  categoryId: string; // Link back to category
  duration: number;
}

// src/pages/VendorDashboardPage.tsx

// Specific interfaces for Vendor App
export interface VendorCategory extends GenericCategory {
  numVendors: number; // Example specific stat
  categoryRating?: number; // Example specific stat
}

export interface VendorItem extends GenericItem {
  contactPerson: string;
  phone: string;
  email: string;
  address: string;
  vendorImageUrl: string;
  rating: number;
  servicesOffered: string[];
  serviceAreas: string[];
  categoryId: string; // Link back to category
  latitude: number;
  longitude: number;
}

export interface MessageItem extends GenericItem {
  message: string;
}

export interface ConversationItem extends GenericItem {
  messages: MessageItem[];
}

// API Types
export interface MessagesAPI {
  id: number;
  conversation: number;
  sender: number;
  text: string;
  timestamp: string;
  read: boolean;
}

export interface UserAPI {
  id: number;
  email: string;
  first_name: string;
  last_name: string;
  user_type: 'property_owner' | 'vendor' | 'attorney' | 'real_estate_agent';
  is_active: boolean;
  date_joined: string;
  tos_signed: boolean;
  profile_created: boolean;
  tier: 'basic' | 'premium';
}
export interface PropertyOwnerAPI {
  user: UserAPI;
  phone_number: string;
}

export interface OpenHouseAPI {
  id: number;
  property: number | PropertiesAPI; // It can be an ID or the full object
  start_time: string;
  end_time: string;
  listed_date: string;
}

export interface VendorAPI {
  user: UserAPI;
  business_name: string;
  business_type: 'electrician' | 'carpenter' | 'plumber' | 'inspector' | 'lendor' | 'other';
  phone_number: string;
  address: string;
  city: string;
  state: string;
  zip_code: string;

  // New fields for vendor profile
  description: string; // A brief description of the vendor's business
  website?: string; // Optional: Vendor's website URL
  services: string[]; // List of services offered (e.g., ['Residential Wiring', 'Commercial Lighting'])
  service_areas: string[]; // Areas where the vendor provides service (e.g., ['Chicago', 'Naperville'])
  certifications?: string[]; // Optional: List of certifications or licenses
  average_rating?: number; // Optional: Average rating from reviews
  num_reviews?: number; // Optional: Number of reviews
  profile_picture?: string; // Optional: URL to a profile picture/logo
  latitude: number; // For Google Map
  longitude: number; // For Google Map
  views: number;
}

export interface AttorneyAPI {
  user: UserAPI;
  firm_name: string;
  bar_number: string; // Unique identifier for attorneys
  phone_number: string;
  address: string;
  city: string;
  state: string;
  zip_code: string;
  specialties: string[]; // e.g., ['Real Estate Law', 'Contract Law', 'Litigation']
  years_experience: number;
  website?: string;
  profile_picture?: string;
  bio?: string; // Short biography
  licensed_states: string[]; // States where the attorney is licensed
  latitude: number; // For Google Map
  longitude: number; // For Google Map
}

export interface RealEstateAgentAPI {
  user: UserAPI;
  brokerage_name: string;
  license_number: string; // Real estate license number
  phone_number: string;
  address: string;
  city: string;
  state: string;
  zip_code: string;
  specialties: string[]; // e.g., ['Residential Sales', 'Commercial Leasing', 'First-Time Buyers']
  years_experience: number;
  website?: string;
  profile_picture?: string;
  bio?: string;
  licensed_states: string[]; // States where the agent is licensed
  agent_type: 'buyer_agent' | 'seller_agent' | 'dual_agent' | 'other';
  latitude: number; // For Google Map
  longitude: number; // For Google Map
}

export interface ConverationAPI {
  id: number;
  created_at: string;
  updated_at: string;
  proptery: number;
  messages: MessagesAPI[];
  vendor: VendorAPI;
  property_owner: PropertyOwnerAPI;
}

export interface VideoCategoryAPI {
  id: number;
  name: string;
  description: string;
}

export interface VideoAPI {
  id: number;
  category: VideoCategoryAPI;
  title: string;
  description: string;
  link: string;
  duration: number;
  created_at: string;
  updated_at: string;
}

export interface VideoProgressAPI {
  id: number;
  video: VideoAPI;
  progress: number;
  status: string;
  last_watched: string;
  user: number;
}

export interface PictureAPI {
  id: number;
  image: string;
}

export interface SaleHistoryAPI {
  seq_no: number;
  sale_date: string;
  sale_amount: number;
}

export interface TaxHistoryAPI {
  assessed_value: number;
  assessment_year: number;
  tax_amount: number;
  year: number;
}

export interface SchoolAPI {
  id?: number;
  address: string;
  city: string;
  state: string;
  zip_code: string;
  created_at?: string;
  last_updated?: string;
  latitude: number; // For Google Map
  longitude: number; // For Google Map
  school_type: 'public' | 'other';
  enrollment: number;
  grades: string;
  name: string;
  parent_rating: number;
  rating: number;
}

export interface WalkScoreAPI {
  walk_score: number;
  walk_description: string;
  created_at: string;
  updated_at: string;
  ws_link: string;
  logo_url: string;
  transit_score: number;
  transit_description: string;
  transit_summary: string;
  bike_score: number;
  bike_description: string;
}

export interface PropertiesAPI {
  id: number;
  owner: PropertyOwnerAPI;
  address: string; // full address
  street: string;
  city: string;
  state: string;
  zip_code: string;
  market_value: string;
  loan_amount: string;
  loan_term: number;
  loan_start_date: string;
  created_at: string;
  last_updated: string;
  //

  pictures: PictureAPI[]; // Array of image URLs
  description: string;
  sq_ft: number;
  features: string[]; // e.g., ['Pool', 'Garage', 'Garden']
  num_bedrooms: number;
  num_bathrooms: number;
  latitude?: number; // For Google Map
  longitude?: number; // For Google Map
  realestate_api_id: number;

  // New Fields for Status Card
  property_status: 'active' | 'pending' | 'contingent' | 'sold' | 'off_market';
  listed_price?: string;
  views: number;
  saves: number;
  listed_date?: string;

  // New Fields for other cards
  walk_score?: WalkScoreAPI;
  sale_info?: SaleHistoryAPI[];
  tax_info: TaxHistoryAPI;
  open_houses?: OpenHouseAPI[];
  schools: SchoolAPI[];
  documents?: DocumentAPI[];
}

export interface BidImageAPI {
  id: number;
  image: string;
}

export interface BidResponseAPI {
  id: number;
  bid: number;
  vendor: VendorAPI;
  description: string;
  price: string;
  status: 'draft' | 'submitted' | 'selected';
  created_at: string;
  updated_at: string;
}

export interface BidAPI {
  id: number;
  property: number;
  description: string;
  bid_type: 'electrical' | 'plumbing' | 'carpentry' | 'general_contractor';
  location: 'living_room' | 'basement' | 'kitchen' | 'bathroom' | 'bedroom' | 'outside';
  images: BidImageAPI[];
  responses: BidResponseAPI[];
  created_at: string;
  updated_at: string;
}

export interface DocumentAPI {
  id: number;
  property: number;
  file: string;
  document_type: string;
  description?: string;
  uploaded_by: number; // or a more detailed user object
  shared_with: number[];
  updated_at: string;
  created_at: string;
  sub_document?: SellerDisclousureData | HomeImprovementReceiptData | OfferData;
}

export interface PropertyRequestAPI extends Omit<PropertiesAPI, 'owner' | 'id'> {
  owner: number;
}

export interface OfferAPI {
  id: number;
  user: UserAPI;
  property: PropertiesAPI;
  previous_offer: OfferAPI;
  status: 'draft' | 'submitted' | 'accepted' | 'rejected' | 'countered';
  updated_at: string;
  created_at: string;
  is_active: boolean;
}

// REAL ESTATE API Type Definitions
export interface AutocompleteResponseAPI {
  input: {
    search: string;
  };
  data: AutocompleteDataResponseAPI[];
  totalResults: number;
  returnedResults: number;
  statusCode: number;
  statusMessage: string;
  live: boolean;
  requestExecutionTimeMS: string;
}
export interface AutocompleteDataResponseAPI {
  zip: string;
  address: string;
  city: string;
  searchType: string;
  stateId: string;
  latitude: number;
  county: string;
  fips: string;
  title: string;
  house: string;
  unit?: string;
  countyId: string;
  street: string;
  location: string;
  id: string;
  state: string;
  apn: string;
  longitude: number;
}

export interface PropertyResponseDataMortgageAPI {
  amount: number;
  assumable: boolean;
  book?: string;
  page?: string;
  documentNumber: string;
  deedType: string;
  documentDate: string;
  granteeName: string;
  interestRate: number;
  interestRateType?: string;
  lenderCode: string;
  lenderName: string;
  lenderType: string;
  loanType: string;
  loanTypeCode: string;
  maturityDate: string;
  mortgageId: string;
  position: string;
  recordingDate: string;
  seqNo: number;
  term: number;
  termType: string;
  transactionType?: string;
}

export interface PropertyResponseDataDemographicsAPI {
  fmrEfficiency: string;
  fmrFourBedroom: string;
  fmrOneBedroom: string;
  fmrThreeBedroom: string;
  fmrTwoBedroom: string;
  fmrYear: string;
  hudAreaCode: string;
  hudAreaName: string;
  medianIncome: string;
  suggestedRent: string;
}

export interface PropertyResponseDataSaleAPI {
  book?: string;
  page?: string;
  documentNumber: string;
  armsLength: boolean;
  buyerNames: string;
  documentType: string;
  documentTypeCode: string;
  downPayment: number;
  ltv: number;
  ownerIndividual: boolean;
  priorOwnerIndividual: boolean;
  priorOwnerMonthsOwned: number;
  purchaseMethod: string;
  recordingDate: string;
  saleAmount: number;
  saleDate: string;
  sellerNames: string;
  seqNo: number;
  transactionType: string;
}

export interface PropertyResponseDataLotInfoAPI {}

export interface PropertyResponseDataMortgageHistoryAPI {}

export interface PropertyResponseDataOnwerInfoAPI {
  mailAddress: {
    address: string;
  };
}

export interface PropertyResponseDataPropertyInfoAPI {
  address: {
    address: string;
    carrierRoute: string;
    city: string;
    congressionalDistrict: string;
    county: string;
    fips: string;
    house: string;
    jurisdiction: string;
    label: string;
    preDirection?: string;
    state: string;
    street: string;
    streetType: string;
    unit: string;
    unitType?: string;
    zip: string;
    zip4: string;
  };
  airConditioningType?: string;
  attic: boolean;
  basementFinishedPercent?: number;
  basementSquareFeet: number;
  basementSquareFeetFinished: number;
  basementSquareFeetUnfinished: number;
  basementType: string;
  bathrooms: number;
  bedrooms: number;
  breezeway: boolean;
  buildingSquareFeet: number;
  buildingsCount: number;
  carport: boolean;
  construction?: string;
  deck: boolean;
  deckArea: number;
  featureBalcony: boolean;
  fireplace: boolean;
  fireplaces?: string;
  garageSquareFeet: number;
  garageType: string;
  heatingFuelType: string;
  heatingType: string;
  hoa: boolean;
  interiorStructure?: string;
  latitude: number;
  livingSquareFeet: number;
  longitude: number;
  lotSquareFeet: number;
  parcelAccountNumber?: number;
  parkingSpaces: number;
  partialBathrooms: number;
  patio: boolean;
  patioArea: string;
  plumbingFixturesCount: number;
  pool: boolean;
  poolArea: number;
  porchArea: number;
  porchType: string;
  pricePerSquareFoot: number;
  propertyUse: string;
  propertyUseCode: number;
  roofConstruction?: string;
  roofMaterial?: number;
  roomsCount: number;
  rvParking: boolean;
  safetyFireSprinklers: boolean;
  stories: number;
  taxExemptionHomeownerFlag: boolean;
  unitsCount: number;
  utilitiesSewageUsage?: string;
  utilitiesWaterSource?: string;
  yearBuilt: number;
}

export interface PropertyResponseDataTaxInfoAPI {
  assessedImprovementValue: number;
  assessedLandValue: number;
  assessedValue: number;
  assessmentYear: number;
  estimatedValue?: number;
  marketImprovementValue: number;
  marketLandValue: number;
  marketValue: number;
  propertyId: number;
  taxAmount: string;
  taxDelinquentYear?: number;
  year: number;
}

export interface PropertyResponseDataCompsAPI {
  id: string;
  vacant: boolean;
  absenteeOwner: boolean;
  corporateOwned: boolean;
  outOfStateAbsenteeOwner: boolean;
  inStateAbsenteeOwner: boolean;
  propertyId: string;
  bedrooms: number;
  bathrooms: number;
  yearBuilt: string;
  squareFeet: string;
  estimatedValue: string;
  equityPercent: string;
  lastSaleDate: string;
  lastSaleAmount: string;
  mlsListingDate: string;
  mlsLastStatusDate: string;
  mlsLastSaleDate: string;
  mlsDaysOnMarket: string;
  mlsSoldPrice: number;
  lotSquareFeet: string;
  latitude: number;
  longitude: number;
  openMortgageBalance: string;
  landUse: string;
  propertyType: string;
  propertyUse: string;
  propertyUseCode: string;
  owner1FirstName: string;
  owner1LastName: string;
  owner2FirstName: string;
  owner2LastName: string;
  preForeclosure: boolean;
  cashBuyer: boolean;
  privateLender: boolean;
  lenderName: string;
  address: {
    zip: string;
    city: string;
    county: string;
    state: string;
    street: string;
    address: string;
  };
  mailAddress: {
    zip: string;
    city: string;
    county: string;
    state: string;
    street: string;
    address: string;
  };
}

export interface PropertyResponseDataSchoolAPI {
  city: string;
  enrollment: number;
  grades: string;
  location: string;
  name: string;
  parentRating: number;
  rating: number;
  address: string;
  state: string;
  zip: string;
  type: 'Public' | 'other';
}

export interface PropertResponseDataAPI {
  id: number;
  MFH2to4: boolean;
  MFH5plus: boolean;
  absenteeOwner: boolean;
  adjustableRate: boolean;
  assumable: boolean;
  auction: boolean;
  equity: number;
  bankOwned?: boolean;
  cashBuyer: boolean;
  cashSale: boolean;
  corporateOwned: boolean;
  death: boolean;
  deathTransfer: boolean;
  deedInLieu: boolean;
  equityPercent: number;
  estimatedEquity: number;
  estimatedMortgageBalance: string;
  estimatedMortgagePayment: string;
  estimatedValue: number;
  floodZone: boolean;
  floodZoneDescription: string;
  floodZoneType: string;
  freeClear: boolean;
  highEquity: boolean;
  inStateAbsenteeOwner: boolean;
  inherited: boolean;
  investorBuyer: boolean;
  judgment: boolean;
  lastSaleDate: string;
  lastSalePrice: string;
  lastUpdateDate: string;
  lien: boolean;
  loanTypeCodeFirst: string;
  loanTypeCodeSecond?: string;
  loanTypeCodeThird?: string;
  maturityDateFirst: string;
  mlsActive: boolean;
  mlsCancelled: boolean;
  mlsDaysOnMarket?: number;
  mlsFailed: boolean;
  mlsFailedDate?: string;
  mlsHasPhotos: boolean;
  mlsLastSaleDate?: string;
  mlsLastStatusDate?: string;
  mlsListingDate?: string;
  mlsListingPrice?: number;
  mlsListingPricePerSquareFoot?: number;
  mlsPending: boolean;
  mlsSold: boolean;
  mlsSoldPrice?: number;
  mlsStatus?: string;
  mlsTotalUpdates?: number;
  mlsType?: string;
  mobileHome: boolean;
  noticeType?: string;
  openMortgageBalance: number;
  outOfStateAbsenteeOwner: boolean;
  ownerOccupied: true;
  preForeclosure: boolean;
  privateLender: boolean;
  propertyType: string;
  quitClaim: boolean;
  reapi_loaded_at?: string;
  sheriffsDeed: boolean;
  spousalDeath: boolean;
  taxLien: boolean;
  trusteeSale: boolean;
  vacant: boolean;
  warrantyDeed: boolean;
  auctionInfo: {};
  currentMortgages: PropertyResponseDataMortgageAPI[];
  demographics: PropertyResponseDataDemographicsAPI;
  //foreclosureInfo:
  lastSale: PropertyResponseDataSaleAPI;
  //linkedProperties
  lotInfo: PropertyResponseDataLotInfoAPI;
  //mlsHistory
  //mlsKeywords
  mortgageHistory: PropertyResponseDataMortgageHistoryAPI[];
  //neighborhood
  ownerInfo: PropertyResponseDataOnwerInfoAPI;
  propertyInfo: PropertyResponseDataPropertyInfoAPI;
  saleHistory: PropertyResponseDataSaleAPI[];
  schools: PropertyResponseDataSchoolAPI[];
  taxInfo: PropertyResponseDataTaxInfoAPI;
  comps: PropertyResponseDataCompsAPI[];
}

export interface PropertyResponseAPI {
  input: {
    comps: boolean;
    id: number;
    exact_match: boolean;
  };
  data: PropertResponseDataAPI;
  statusCode: number;
  statusMessage: string;
  live: boolean;
  requestExecutionTimeMS: string;
  propertyLookupExecutionTimeMS: string;
  compsLookupExecutionTimeMS: string;
}

export interface SavedPropertiesAPI {
  id: number;
  user: number;
  property: number;
  created_at: string;
}

export interface FaqApi {
  order: number;
  answer: string;
  question: string;
}

export interface SupportMessageApi {
  id: number;
  text: string;
  user: id;
  user_first_name: string;
  user_last_name: string;
  created_at: string;
  updated_at: string;
}

export interface SupportCaseApi {
  id: number;
  title: string;
  description: string;
  category: string;
  status: string;
  messages: SupportMessageApi[];
  created_at: string;
  updated_at: string;
}
// Walk Score API Type Definitions
