import { database } from '@/data'
import { axiosInstance } from '@/libs/axios'

export interface Suitable {
  id?: number
  product_name: string
  manufacturer: string
  roof_material: string
  shape: string
  support_roof_tile: string
  support_roof_tile_memo: string
  support_roof_bracket: string
  support_roof_bracket_memo: string
  yg_anchor: string
  yg_anchor_memo: string
  rg_roof_tile_part: string
  rg_roof_tile_part_memo: string
  dido_hunt_support_tile_2: string
  dido_hunt_support_tile_2_memo: string
  takashima_power_base: string
  takashima_power_base_memo: string
  takashima_tile_bracket: string
  takashima_tile_bracket_memo: string
  slate_bracket_4: string
  slate_bracket_4_memo: string
  slate_single_metal_bracket: string
  slate_single_metal_bracket_memo: string
  dido_hunt_short_rack_4: string
  dido_hunt_short_rack_4_memo: string
  takashima_slate_bracket_slate_single: string
  takashima_slate_bracket_slate_single_memo: string
  df_metal_bracket: string
  df_metal_bracket_memo: string
  slate_metal_bracket: string
  slate_metal_bracket_memo: string
  takashima_slate_bracket_metal_roof: string
  takashima_slate_bracket_metal_roof_memo: string
}

export const suitableApi = {
  // getList: async (category?: string, keyword?: string): Promise<Suitable[]> => {
  //   let condition: any = {}
  //   if (category) {
  //     condition['category'] = category
  //   }
  //   if (keyword) {
  //     condition['keyword'] = {
  //       contains: keyword,
  //     }
  //   }
  //   console.log('🚀 ~ getList: ~ condition:', condition)
  //   const response = await axiosInstance(null).get<Suitable[]>('/api/suitable/list', { params: condition })
  //   console.log('🚀 ~ getList: ~ response:', response)
  //   return response.data
  // },
  // getCategory: async (): Promise<Suitable[]> => {
  //   const response = await axiosInstance(null).get<Suitable[]>('/api/suitable/category')
  //   console.log('🚀 ~ getCategory: ~ response:', response)
  //   return response.data
  // },
  // getDetails: async (roofMaterial: string): Promise<Suitable[]> => {
  //   const response = await axiosInstance(null).get<Suitable[]>(`/api/suitable/details?roof-material=${roofMaterial}`)
  //   console.log('🚀 ~ getDetails: ~ response:', response)
  //   return response.data
  // },
  // create: async () => {
  //   const suitableData: Suitable[] = []
  //   database.forEach((item) => {
  //     suitableData.push({
  //       product_name: item[0],
  //       manufacturer: item[1],
  //       roof_material: item[2],
  //       shape: item[3],
  //       support_roof_tile: item[4],
  //       support_roof_tile_memo: item[5],
  //       support_roof_bracket: item[6],
  //       support_roof_bracket_memo: item[7],
  //       yg_anchor: item[8],
  //       yg_anchor_memo: item[9],
  //       rg_roof_tile_part: item[10],
  //       rg_roof_tile_part_memo: item[11],
  //       dido_hunt_support_tile_2: item[12],
  //       dido_hunt_support_tile_2_memo: item[13],
  //       takashima_power_base: item[14],
  //       takashima_power_base_memo: item[15],
  //       takashima_tile_bracket: item[16],
  //       takashima_tile_bracket_memo: item[17],
  //       slate_bracket_4: item[18],
  //       slate_bracket_4_memo: item[19],
  //       slate_single_metal_bracket: item[20],
  //       slate_single_metal_bracket_memo: item[21],
  //       dido_hunt_short_rack_4: item[22],
  //       dido_hunt_short_rack_4_memo: item[23],
  //       takashima_slate_bracket_slate_single: item[24],
  //       takashima_slate_bracket_slate_single_memo: item[25],
  //       df_metal_bracket: item[26],
  //       df_metal_bracket_memo: item[27],
  //       slate_metal_bracket: item[28],
  //       slate_metal_bracket_memo: item[29],
  //       takashima_slate_bracket_metal_roof: item[30],
  //       takashima_slate_bracket_metal_roof_memo: item[31],
  //     })
  //   })
  //   const response = await axiosInstance(null).post<Suitable[]>('/api/suitable', suitableData)
  //   return response.data
  // },
}
