'use client'

import React from 'react'
import { Order } from '@/lib/types/order'
import { Country } from '@/lib/types/country'
import { MapPin, Star } from 'lucide-react'

import { Card, CardContent } from '@/components/shadcn/ui/card'
import ReviewForm from '@/components/form/ReviewForm'
import { TourPackageProduct } from '@/lib/types/tour-package'
import Image from 'next/image'

interface TourPackageReviewProps {
  order: Order
  tourPackageProduct: TourPackageProduct
  countries?: Country[]
}

const TourPackageReview: React.FC<TourPackageReviewProps> = ({
  order,
  tourPackageProduct,
  countries = [],
}) => {
  return (
    <div className="flex flex-col items-center w-full max-w-3xl mx-auto p-4 md:p-6">
      {/* Activity Info Summary */}
      <div className="mb-4 mt-8 text-center">
        <h1 className="text-2xl sm:text-3xl md:text-4xl font-semibold mb-2 bg-gradient-to-r from-blue-600 to-teal-500 text-transparent bg-clip-text">
          Share Your Experience
        </h1>
        <p className="text-slate-500 mb-6">
          Your honest feedback helps others make better travel decisions
        </p>
      </div>

      <Card className="w-full mb-8 border-none shadow-lg overflow-hidden">
        <div className="bg-gradient-to-r from-blue-500 to-teal-400 h-2" />
        <CardContent className="p-0">
          <div className="flex flex-col md:flex-row px-4">
            {/* Activity Image */}
            <div className="w-full md:w-2/5 h-48 relative overflow-hidden">
              {tourPackageProduct.featured_image ? (
                <Image
                  src={tourPackageProduct.featured_image?.image}
                  alt={tourPackageProduct.name}
                  className="w-full h-full object-cover"
                  fill
                />
              ) : (
                <div className="w-full h-full bg-gray-200 flex items-center justify-center">
                  <span className="text-gray-400">No image available</span>
                </div>
              )}
              {tourPackageProduct.badge && (
                <div className="absolute top-2 left-2 bg-blue-600 text-white px-3 py-1 rounded-full text-xs font-medium">
                  {tourPackageProduct.badge.name}
                </div>
              )}
            </div>

            {/* Activity Details */}
            <div className="w-full md:w-5/5 p-5">
              <div className="flex font-medium items-center gap-1 text-sm text-gray-600">
                <Star className="h-4 w-4 fill-current text-yellow-400" />
                <span>{tourPackageProduct.rating}</span>
              </div>

              <h3 className="text-xl font-medium mb-2">
                {tourPackageProduct.name}
              </h3>

              <div className="flex items-center text-slate-500 mb-3">
                <MapPin className="w-4 h-4 mr-2" />
                <span className="text-sm">
                  Meeting Point: {tourPackageProduct.meeting_point}
                </span>
              </div>

              {/* Features List */}
              <div className="flex flex-wrap gap-2 mt-3">
                {tourPackageProduct.features
                  ?.slice(0, 3)
                  .map((feature, index) => (
                    <span
                      key={index}
                      className="bg-gray-100 text-blue-800 text-xs px-2 py-1 rounded-md"
                    >
                      {feature.name}
                    </span>
                  ))}
              </div>
            </div>
          </div>
        </CardContent>
      </Card>

      <ReviewForm
        order={order}
        countries={countries}
        productCategory="tour_package"
        productId={tourPackageProduct.id}
      />
    </div>
  )
}

export default TourPackageReview
