// import {
//   commissionTypes,
//   commissionOptions,
//   commissionExtras,
//   rawCommissions,
// } from "./mockData" // adjust your import paths

import { commissionExtras, commissionOptions, commissionTypes, rawCommissions } from "@/data/mockCommissions"

export type CommissionCard = {
  type: {
    key: string
    name: string
    description: string
  }
  options: {
    key: string
    name: string
    price: number
  }[]
  extras: {
    key: string
    name: string
    description: string
    price?: number
    pricePercent?: number
    priceRange?: string
  }[]
}

export const generateMockCommissions = (): CommissionCard[] => {
  return rawCommissions.map((commission) => {
    const typeKey = Object.entries(commissionTypes).find(
      ([, v]) => v.name === commission.type.name
    )?.[0] ?? "unknown"

    const options = commission.options.map((opt) => {
      const optionKey = Object.entries(commissionOptions).find(
        ([, v]) => v.name === opt.type.name
      )?.[0] ?? "unknown"

      return {
        key: optionKey,
        name: opt.type.name,
        price: opt.price,
      }
    })

    const extras = commission.extras.map((extra) => {
      const extraKey = Object.entries(commissionExtras).find(
        ([, v]) => v.name === extra.type.name
      )?.[0] ?? "unknown"

      return {
        key: extraKey,
        name: extra.type.name,
        description: extra.type.description,
        price: extra.price ?? undefined,
        pricePercent: extra.pricePercent ?? undefined,
        priceRange: extra.priceRange ?? undefined,
      }
    })

    return {
      type: {
        key: typeKey,
        name: commission.type.name,
        description: commission.type.description,
      },
      options,
      extras,
      examples: commission.examples,
    }
  })
}
