/** * Included Section Component * Handles: What's included/excluded at trip level */ import React from "react"; import { CheckSquare, Plus, X, AlertCircle } from "lucide-react"; import { TripFormSectionProps } from "../types"; import { SectionHeader } from "../shared/SectionHeader"; import { Button } from "../../ui/button"; import { Input } from "../../ui/input"; import { Card, CardContent } from "../../ui/card"; import { Badge } from "../../ui/badge"; import { __ } from "../../../lib/i18n"; // Custom Textarea component since it doesn't exist in UI const Textarea: React.FC<{ value: string; onChange: (e: any) => void; placeholder?: string; rows?: number; className?: string; }> = ({ value, onChange, placeholder, rows = 3, className = "" }) => ( ); interface TripAmenityItem { title: string; description: string; } interface IncludedSectionProps extends TripFormSectionProps { formData: any; } export const IncludedSection: React.FC = ({ formData, handleFieldChange, }) => { const [newIncludedItem, setNewIncludedItem] = React.useState( { title: "", description: "", }, ); const [newExcludedItem, setNewExcludedItem] = React.useState( { title: "", description: "", }, ); const included_items = formData.included_items || []; const excluded_items = formData.excluded_items || []; const addIncludedItem = () => { if (newIncludedItem.title.trim()) { const updatedItems = [...included_items, { ...newIncludedItem }]; handleFieldChange("included_items", updatedItems); setNewIncludedItem({ title: "", description: "" }); } }; const addExcludedItem = () => { if (newExcludedItem.title.trim()) { const updatedItems = [...excluded_items, { ...newExcludedItem }]; handleFieldChange("excluded_items", updatedItems); setNewExcludedItem({ title: "", description: "" }); } }; const removeIncludedItem = (index: number) => { const updatedItems = included_items.filter( (_: any, i: number) => i !== index, ); handleFieldChange("included_items", updatedItems); }; const removeExcludedItem = (index: number) => { const updatedItems = excluded_items.filter( (_: any, i: number) => i !== index, ); handleFieldChange("excluded_items", updatedItems); }; return ( {/* Included Items */} {__("What's Included", "yatra")} {included_items.length} {__("items", "yatra")} {/* Add New Included Item */} setNewIncludedItem({ ...newIncludedItem, title: e.target.value, }) } className="border-green-300 dark:border-green-700 focus:ring-green-500 focus:border-green-500" /> setNewIncludedItem({ ...newIncludedItem, description: e.target.value, }) } rows={3} className="border-green-300 dark:border-green-700 focus:ring-green-500 focus:border-green-500 resize-none" /> {__("Add Included Item", "yatra")} {/* Existing Included Items */} {included_items.length === 0 ? ( {__("No included items added yet", "yatra")} ) : ( included_items.map((item: any, index: number) => ( {item.title} {item.description && ( {item.description} )} removeIncludedItem(index)} className="text-red-500 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20 opacity-0 group-hover:opacity-100 transition-all duration-200 p-2" > )) )} {/* Excluded Items */} {__("What's Excluded", "yatra")} {excluded_items.length} {__("items", "yatra")} {/* Add New Excluded Item */} setNewExcludedItem({ ...newExcludedItem, title: e.target.value, }) } className="border-red-300 dark:border-red-700 focus:ring-red-500 focus:border-red-500" /> setNewExcludedItem({ ...newExcludedItem, description: e.target.value, }) } rows={3} className="border-red-300 dark:border-red-700 focus:ring-red-500 focus:border-red-500 resize-none" /> {__("Add Excluded Item", "yatra")} {/* Existing Excluded Items */} {excluded_items.length === 0 ? ( {__("No excluded items added yet", "yatra")} ) : ( excluded_items.map((item: any, index: number) => ( {item.title} {item.description && ( {item.description} )} removeExcludedItem(index)} className="text-red-500 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20 opacity-0 group-hover:opacity-100 transition-all duration-200 p-2" > )) )} {/* Help Tips */} {__("Tips for Included/Excluded Items:", "yatra")} {__( "Be specific about what's included (meals, transport, guides, etc.)", "yatra", )} {__( "Clearly mention what's NOT included to avoid confusion", "yatra", )} {__("Include items that affect pricing decisions", "yatra")} {__("Keep descriptions concise but informative", "yatra")} ); };
{__("No included items added yet", "yatra")}
{item.description}
{__("No excluded items added yet", "yatra")}
{__("Tips for Included/Excluded Items:", "yatra")}