"use client"

import { useMyStayStore } from "@/stores/my-stay"

import { IconForFeatureCode } from "@/components/HotelReservation/utils"

import styles from "./packages.module.css"

import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"

export default function Packages() {
  const packages = useMyStayStore(
    (state) =>
      state.bookedRoom.packages?.filter((item) =>
        Object.values(RoomPackageCodeEnum).includes(
          item.code as RoomPackageCodeEnum
        )
      ) || []
  )

  if (!packages.length) {
    return null
  }

  return (
    <div className={styles.packages}>
      {packages.map((item) => (
        <span className={styles.package} key={item.code}>
          <IconForFeatureCode
            featureCode={item.code}
            size={16}
            color="Icon/Interactive/Default"
          />
        </span>
      ))}
    </div>
  )
}
