import type { Key } from "react-aria-components"

import type { JobylonFilterKey } from "@/types/enums/jobylonFeed"
import type { JobylonItem } from "@/types/trpc/routers/jobylon"

export interface JobylonFilterItem {
  label: string
  value: Key
}

export interface JobylonFilters
  extends Record<JobylonFilterKey, JobylonFilterItem[]> {
  [JobylonFilterKey.country]: JobylonFilterItem[]
  [JobylonFilterKey.city]: JobylonFilterItem[]
  [JobylonFilterKey.department]: JobylonFilterItem[]
  [JobylonFilterKey.category]: JobylonFilterItem[]
}

export enum ActionType {
  UPDATE_FILTER = "UPDATE_FILTER",
}

interface UpdateFilter {
  payload: {
    filter: JobylonFilterKey
    value: Key
  }
  type: ActionType.UPDATE_FILTER
}

export type Action = UpdateFilter

export interface State {
  allJobs: JobylonItem[]
  jobs: JobylonItem[]
  chosenCountryFilter: Key
  chosenCityFilter: Key
  chosenDepartmentFilter: Key
  chosenCategoryFilter: Key
  countryFilters: JobylonFilterItem[]
  cityFilters: JobylonFilterItem[]
  departmentFilters: JobylonFilterItem[]
  categoryFilters: JobylonFilterItem[]
}

export interface InitState extends Pick<State, "allJobs"> {}
