You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1104 lines
56 KiB
1104 lines
56 KiB
import React, { useState, useMemo } from 'react'
|
|
import { useNavigate } from 'react-router-dom'
|
|
import { Input } from '@/components/ui/input'
|
|
import { Textarea } from '@/components/ui/textarea'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Badge } from '@/components/ui/badge'
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
} from '@/components/ui/dialog'
|
|
import DeleteConfirmDialog from '@/components/shared/DeleteConfirmDialog'
|
|
import {
|
|
ServiceTranslation,
|
|
SERVICE_LANGUAGES,
|
|
type ServiceLanguageCode,
|
|
} from '@/components/shared/ServiceTranslation'
|
|
import { Ic } from '@/icons'
|
|
import { toFa, cn } from '@/lib/utils'
|
|
import { useTranslation } from '@/i18n'
|
|
import { Switch } from '@/components/ui/switch'
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from '@/components/ui/select'
|
|
import type { CustomTripDestinationItem, CustomTripTransportRelationItem } from '../types'
|
|
import { useHotelsCatalogStore, doesHotelMatchDestination } from '@/stores/hotels-catalog'
|
|
|
|
interface CustomTripDestinationsTabProps {
|
|
destinations: CustomTripDestinationItem[]
|
|
relations?: CustomTripTransportRelationItem[]
|
|
onAddDestination: (dest: CustomTripDestinationItem) => void
|
|
onUpdateDestination?: (dest: CustomTripDestinationItem) => void
|
|
onDeleteDestination?: (id: string | number) => void
|
|
onNavigateToTransports?: (destCityName: string) => void
|
|
onNavigateToHotels?: (destCityName: string) => void
|
|
}
|
|
|
|
const PRESET_DEST_COUNTRIES = [
|
|
{ name: 'عراق', flag: '🇮🇶' },
|
|
{ name: 'عربستان سعودی', flag: '🇸🇦' },
|
|
{ name: 'ایران', flag: '🇮🇷' },
|
|
]
|
|
|
|
export interface PresetDestinationCity {
|
|
id: string
|
|
country: string
|
|
names: Record<ServiceLanguageCode, string>
|
|
holyPlaces: Record<ServiceLanguageCode, string>
|
|
description: Record<ServiceLanguageCode, string>
|
|
}
|
|
|
|
export const OFFICIAL_PRESET_CITIES: PresetDestinationCity[] = [
|
|
// ۱. مقاصد زیارتی عراق
|
|
{
|
|
id: 'karbala',
|
|
country: 'عراق',
|
|
names: {
|
|
ar: 'كربلاء المقدسة',
|
|
fa: 'کربلای معلی',
|
|
en: 'Karbala',
|
|
ru: 'Кербела',
|
|
id: 'Karbala',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'العتبة الحسينية المقدسة، العتبة العباسية المقدسة، ما بين الحرمين الشريفين، التل الزينبي، المخيم الحسيني',
|
|
fa: 'حرم مطهر امام حسین (ع)، حرم مطهر حضرت ابوالفضل العباس (ع)، بینالحرمین شریف، تل زینبیه، خیمهگاه حسینی',
|
|
en: 'Imam Husayn Holy Shrine, Al-Abbas Holy Shrine, Bain al-Haramain, Al-Tal Al-Zaynabi, Al-Mukhayyam Al-Hussaini',
|
|
ru: 'Святыня Имама Хусейна (мир ему), Святыня Хазрата Абульфазла аль-Аббаса (мир ему), Бейн аль-Харамейн, Телль аз-Зейнабия',
|
|
id: 'Makam Suci Imam Hussain (AS), Makam Suci Hazrat Abbas (AS), Bainal Haramain, Al-Tall Al-Zainabi',
|
|
},
|
|
description: {
|
|
ar: 'كربلاء المقدسة قبلة عشاق أهل البيت (ع) وعاصمة النهضة الحسينية، تضم المرقدين المنورين للإمام الحسين (ع) وأخيه أبي الفضل العباس (ع).',
|
|
fa: 'کربلای معلی قبلهگاه عاشقان اهلبیت (ع) و پایتخت معنوی نهضت حسینی است. زیارت بارگاه منور سیدالشهدا (ع) و قمر بنیهاشم (ع).',
|
|
en: 'Karbala is the holy sanctuary of lovers of Ahlulbayt (AS) and the capital of the Hussaini movement.',
|
|
ru: 'Кербела — священная обитель почитателей Ахль аль-Бейт (мир им) и духовный центр хусейновского движения.',
|
|
id: 'Karbala adalah tempat suci para pecinta Ahlulbait (AS) dan pusat gerakan Husaini.',
|
|
},
|
|
},
|
|
{
|
|
id: 'najaf',
|
|
country: 'عراق',
|
|
names: {
|
|
ar: 'النجف الأشرف',
|
|
fa: 'نجف اشرف',
|
|
en: 'Najaf',
|
|
ru: 'Эн-Наджаф',
|
|
id: 'Najaf',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'العتبة العلوية المقدسة، مقبرة وادي السلام، مسجد الكوفة المعظم، مسجد السهلة',
|
|
fa: 'حرم مطهر حضرت امیرالمؤمنین علی (ع)، قبرستان وادیالسلام، مسجد جامع کوفه، مسجد سهله',
|
|
en: 'Imam Ali Holy Shrine, Wadi-us-Salaam Cemetery, Great Mosque of Kufa, Al-Sahla Mosque',
|
|
ru: 'Святыня Имама Али (мир ему), Кладбище Вади ас-Салам, Мечеть Куфы, Мечеть ас-Сахла',
|
|
id: 'Makam Suci Imam Ali (AS), Pemakaman Wadi-us-Salam, Masjid Kufah, Masjid As-Sahla',
|
|
},
|
|
description: {
|
|
ar: 'النجف الأشرف، مهد العلم والحكمة ومرقد أمير المؤمنين علي بن أبي طالب (ع).',
|
|
fa: 'نجف اشرف، مهد علم و حکمت و مدفن مطهر مولای متقیان امیرالمؤمنین علی (ع) است.',
|
|
en: 'Najaf, the city of wisdom and the resting place of Commander of the Faithful Imam Ali (AS).',
|
|
ru: 'Эн-Наджаф — колыбель мудрости и место упокоения Имама Али (мир ему).',
|
|
id: 'Najaf adalah kota hikmah dan tempat suci peristirahatan Imam Ali (AS).',
|
|
},
|
|
},
|
|
{
|
|
id: 'kadhimiya',
|
|
country: 'عراق',
|
|
names: {
|
|
ar: 'الكاظمية المقدسة',
|
|
fa: 'کاظمین مقدسه',
|
|
en: 'Kadhimiya',
|
|
ru: 'Казимия',
|
|
id: 'Kadhimiya',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'العتبة الكاظمية المقدسة، مرقد الشيخ المفيد، مرقد المحقق الطوسي، المسجد الصفوي',
|
|
fa: 'حرم مطهر امامین جوادین (ع)، مرقد شریف شیخ مفید، مرقد خواجه نصیرالدین طوسی، مسجد صفوی',
|
|
en: 'Al-Kadhimiya Holy Shrine, Tomb of Sheikh al-Mufid, Tomb of Khwaja Nasir al-Din al-Tusi, Safavid Mosque',
|
|
ru: 'Святыня Аль-Казимия (мир им), Гробница Шейха аль-Муфида, Мечеть Сефевидов',
|
|
id: 'Makam Suci Al-Kadhimiya, Makam Syekh al-Mufid, Makam Khwaja Nasiruddin ath-Thusi',
|
|
},
|
|
description: {
|
|
ar: 'الكاظمية المقدسة في بغداد تحتضن المرقدين الطاهرين للإمامين الكاظم والجواد (عليهما السلام).',
|
|
fa: 'کاظمین در جوار بغداد، میزبان مضجع شریف و مطهر امام موسی کاظم (ع) و امام محمد تقی جوادالائمه (ع) است.',
|
|
en: 'Kadhimiya in Baghdad is home to the blessed holy shrines of Imam Musa al-Kadhim and Imam Muhammad al-Jawad (AS).',
|
|
ru: 'Казимия в Багдаде хранит священные гробницы Имама Мусы аль-Казима и Имама Мухаммада аль-Джавада (мир им).',
|
|
id: 'Kadhimiya di Baghdad menaungi makam suci Imam Musa al-Kadzim dan Imam Muhammad al-Jawad (AS).',
|
|
},
|
|
},
|
|
{
|
|
id: 'samarra',
|
|
country: 'عراق',
|
|
names: {
|
|
ar: 'سامراء المقدسة',
|
|
fa: 'سامرا',
|
|
en: 'Samarra',
|
|
ru: 'Самарра',
|
|
id: 'Samarra',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'العتبة العسكرية المقدسة، سرداب الغيبة الشريف، مرقد السيدة نرجس والسيدة حكيمة',
|
|
fa: 'حرم مطهر امامین عسکریین (ع)، سرداب مقدس غیبت، مزار نرجس خاتون (س) و حکیمه خاتون (س)',
|
|
en: 'Al-Askari Holy Shrine, Holy Cellar of Occultation (Sardab), Tomb of Lady Narjis and Lady Hakimah',
|
|
ru: 'Святыня Аль-Аскари в Самарре, Священный Сердаб сокрытия, Гробницы Нарджис и Хакимы',
|
|
id: 'Makam Suci Al-Askari di Samarra, Sardab Gaib Suci, Makam Sayyidah Narjis dan Sayyidah Hakimah',
|
|
},
|
|
description: {
|
|
ar: 'سامراء المقدسة تحتضن مرقدي الإمامين علي الهادي والحسن العسكري (عليهما السلام) وسرداب الغيبة المبارك.',
|
|
fa: 'سامرا مدفن مطهر امام علیالنقی الهادی (ع) و امام حسن عسکری (ع) و محل سرداب مقدس غیبت حضرت ولیعصر (عج) است.',
|
|
en: 'Samarra is home to the holy shrines of Imam Ali al-Hadi and Imam Hasan al-Askari (AS), and the holy cellar of occultation.',
|
|
ru: 'Самарра — священное место упокоения Имама Али аль-Хади и Имама Хасана аль-Аскари (мир им) и место священного Сердаба.',
|
|
id: 'Samarra adalah makam suci Imam Ali al-Hadi dan Imam Hasan al-Askari (AS) serta tempat Sardab Gaib.',
|
|
},
|
|
},
|
|
|
|
// ۲. مقاصد زیارتی عربستان سعودی
|
|
{
|
|
id: 'makkah',
|
|
country: 'عربستان سعودی',
|
|
names: {
|
|
ar: 'مكة المكرمة',
|
|
fa: 'مکه مکرمه',
|
|
en: 'Makkah',
|
|
ru: 'Мекка',
|
|
id: 'Makkah',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'المسجد الحرام، الكعبة المشرفة، مقام إبراهيم (ع)، الصفا والمروة، جبل النور وغار حراء، مشاعر منى وعرفات',
|
|
fa: 'مسجد الحرام، کعبه مشرفه، مقام ابراهیم (ع)، صفا و مروه، جبلالنور و غار حرا، منا و عرفات',
|
|
en: 'Masjid al-Haram, Holy Kaaba, Maqam Ibrahim, Safa and Marwah, Mount Noor and Hira Cave, Mina and Arafat',
|
|
ru: 'Масджид аль-Харам, Священная Кааба, Макам Ибрахима, Сафа и Марва, Пещера Хира, Мина и Арафат',
|
|
id: "Masjidil Haram, Ka'bah Suci, Maqam Ibrahim, Shafa dan Marwah, Gua Hira, Mina dan Arafah",
|
|
},
|
|
description: {
|
|
ar: 'مكة المكرمة، أقدس بقاع الأرض، مهبط الوحي وقبلة المسلمين في شتى بقاع العالم.',
|
|
fa: 'مکه مکرمه، مقدسترین نقطه کره زمین، زادگاه نبی اکرم (ص) و قبلهگاه تمامی مسلمانان جهان است.',
|
|
en: 'Makkah, the holiest city in Islam, birthplace of Prophet Muhammad (PBUH) and direction of prayer for all Muslims.',
|
|
ru: 'Мекка — священнейший город ислама, место ниспослания откровения и кибла всех мусульман.',
|
|
id: 'Makkah adalah kota paling suci dalam Islam, tempat turunnya wahyu dan kiblat umat Islam sedunia.',
|
|
},
|
|
},
|
|
{
|
|
id: 'madinah',
|
|
country: 'عربستان سعودی',
|
|
names: {
|
|
ar: 'المدينة المنورة',
|
|
fa: 'مدینه منوره',
|
|
en: 'Madinah',
|
|
ru: 'Медина',
|
|
id: 'Madinah',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'المسجد النبوي الشريف، الروضة الشريفة، مقبرة البقيع الغرقد، مسجد قباء، جبل أحد ومقبرة الشهداء',
|
|
fa: 'مسجد النبی (ص)، روضه شریفه نبوی، قبرستان بقیع و مزار ائمه بقیع (ع)، مسجد قبا، کوه احد',
|
|
en: "Prophet's Mosque (Al-Masjid an-Nabawi), Rawdah ash-Sharifah, Baqi Cemetery, Quba Mosque, Mount Uhud",
|
|
ru: 'Мечеть Пророка (мир ему), Эр-Рауда, Кладбище аль-Баки, Мечеть Куба, Гора Ухуд',
|
|
id: 'Masjid Nabawi, Raudhah Syarifah, Pemakaman Baqi, Masjid Quba, Gunung Uhud',
|
|
},
|
|
description: {
|
|
ar: 'المدينة المنورة، طيبة الطيبة، مرقد النبي الأعظم (ص) ومثوى أئمة البقيع الأطهار (ع).',
|
|
fa: 'مدینه منوره یا یثرب النبی، شهر آرامش و نور، آرامگاه ابدی رسول گرامی اسلام (ص) و مدفن مطهر ائمه بقیع (ع) است.',
|
|
en: 'Madinah, the luminous city of Prophet Muhammad (PBUH) and the blessed resting place of Baqi Imams (AS).',
|
|
ru: 'Медина — лучезарный город Пророка (мир ему) и благословенное место упокоения имамов Баки (мир им).',
|
|
id: 'Madinah adalah kota bercahaya Nabi Muhammad (SAW) dan tempat peristirahatan para Imam Baqi (AS).',
|
|
},
|
|
},
|
|
|
|
// ۳. مقاصد زیارتی ایران
|
|
{
|
|
id: 'mashhad',
|
|
country: 'ایران',
|
|
names: {
|
|
ar: 'مشهد المقدسة',
|
|
fa: 'مشهد مقدس',
|
|
en: 'Mashhad',
|
|
ru: 'Мешхед',
|
|
id: 'Mashhad',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'العتبة الرضوية المقدسة، صحن الثورة، جامع جوهرشاد، متاحف الروضة الرضوية',
|
|
fa: 'حرم مطهر امام رضا (ع)، صحن انقلاب، صحن آزادی، مسجد گوهرشاد، موزه آستان قدس رضوی',
|
|
en: 'Imam Reza Holy Shrine, Inqilab Courtyard, Goharshad Mosque, Astan Quds Museums',
|
|
ru: 'Святыня Имама Резы (мир ему), Двор Инкилаб, Мечеть Гохаршад, Музеи Астан Кудс',
|
|
id: 'Makam Suci Imam Ridha (AS), Halaman Inqilab, Masjid Goharshad, Museum Astan Quds',
|
|
},
|
|
description: {
|
|
ar: 'مشهد المقدسة، العاصمة الروحية ومرقد الإمام علي بن موسى الرضا (ع).',
|
|
fa: 'مشهد الرضا پایتخت معنوی ایران و بارگاه ملکوتی حضرت علی بن موسی الرضا (ع) است.',
|
|
en: 'Mashhad, spiritual capital of Iran and the holy shrine of Imam Ali ibn Musa al-Reza (AS).',
|
|
ru: 'Мешхед — духовная столица Ирана и священная обитель Имама Али ибн Мусы ар-Риды (мир ему).',
|
|
id: 'Mashhad adalah ibu kota spiritual Iran dan makam suci Imam Ali bin Musa ar-Ridha (AS).',
|
|
},
|
|
},
|
|
{
|
|
id: 'qom',
|
|
country: 'ایران',
|
|
names: {
|
|
ar: 'قم المقدسة',
|
|
fa: 'قم مقدسه',
|
|
en: 'Qom',
|
|
ru: 'Кум',
|
|
id: 'Qom',
|
|
},
|
|
holyPlaces: {
|
|
ar: 'حرم السيدة فاطمة المعصومة (ع)، مسجد جمكران المعظم، متاحف العتبة المعصومية، جبل الخضر',
|
|
fa: 'حرم مطهر حضرت فاطمه معصومه (س)، مسجد مقدس جمکران، موزه آستانه مقدسه، کوه خضر نبی',
|
|
en: 'Holy Shrine of Lady Fatima Masuma (SA), Jamkaran Mosque, Shrine Museum, Mount Khidr',
|
|
ru: 'Святыня Хазрата Фатимы Масумы (мир ей), Мечеть Джамкаран, Музей святыни',
|
|
id: "Makam Suci Sayyidah Fatimah Ma'shumah (SA), Masjid Jamkaran, Museum Suci",
|
|
},
|
|
description: {
|
|
ar: 'قم المقدسة، مرقد كريمة أهل البيت السيدة فاطمة المعصومة (ع) ومنطلق الحوزات العلمية ومسجد جمكران.',
|
|
fa: 'قم مقدسه، حرم مطهر کریمه اهلبیت حضرت فاطمه معصومه (س) و پایگاه حوزههای علمیه و مسجد جمکران است.',
|
|
en: 'Qom, sanctuary of Lady Fatima Masuma (SA) and center of Islamic scholarship and Jamkaran Mosque.',
|
|
ru: 'Кум — священная обитель Хазрата Фатимы Масумы (мир ей) и центр духовного просвещения.',
|
|
id: "Qom adalah tempat suci Sayyidah Fatimah Ma'shumah (SA) dan pusat keilmuan Islam.",
|
|
},
|
|
},
|
|
]
|
|
|
|
export function CustomTripDestinationsTab({
|
|
destinations,
|
|
relations,
|
|
onAddDestination,
|
|
onUpdateDestination,
|
|
onDeleteDestination,
|
|
onNavigateToTransports,
|
|
onNavigateToHotels,
|
|
}: CustomTripDestinationsTabProps) {
|
|
const { t } = useTranslation()
|
|
const navigate = useNavigate()
|
|
const [search, setSearch] = useState('')
|
|
const [selectedCountry, setSelectedCountry] = useState<string>('all')
|
|
const sharedHotels = useHotelsCatalogStore((s) => s.hotels)
|
|
const isHotelsLoaded = useHotelsCatalogStore((s) => s.isLoaded)
|
|
|
|
const getHotelCount = (item: CustomTripDestinationItem) => {
|
|
if (isHotelsLoaded) {
|
|
return sharedHotels.filter((h) => doesHotelMatchDestination(h, item)).length
|
|
}
|
|
return item.hotelsCount || 0
|
|
}
|
|
|
|
const getTransportCount = (item: CustomTripDestinationItem) => {
|
|
if (item.transportsCount !== undefined) return item.transportsCount
|
|
if (relations && relations.length > 0) {
|
|
const dName = (item.name || '').trim()
|
|
return relations.filter(
|
|
(r) =>
|
|
r.toCity.trim() === dName ||
|
|
dName.includes(r.toCity.trim()) ||
|
|
r.toCity.trim().includes(dName)
|
|
).length
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// Modals state
|
|
const [isFormOpen, setIsFormOpen] = useState(false)
|
|
const [editingItem, setEditingItem] = useState<CustomTripDestinationItem | null>(null)
|
|
const [itemToDelete, setItemToDelete] = useState<CustomTripDestinationItem | null>(null)
|
|
const [validationError, setValidationError] = useState<string | null>(null)
|
|
|
|
// Multi-language form state
|
|
const [activeLangTab, setActiveLangTab] = useState<ServiceLanguageCode>('ar')
|
|
const [names, setNames] = useState<Record<ServiceLanguageCode, string>>({
|
|
ar: '',
|
|
fa: '',
|
|
en: '',
|
|
ru: '',
|
|
id: '',
|
|
})
|
|
const [holyPlacesMap, setHolyPlacesMap] = useState<Record<ServiceLanguageCode, string>>({
|
|
ar: '',
|
|
fa: '',
|
|
en: '',
|
|
ru: '',
|
|
id: '',
|
|
})
|
|
const [descriptionsMap, setDescriptionsMap] = useState<Record<ServiceLanguageCode, string>>({
|
|
ar: '',
|
|
fa: '',
|
|
en: '',
|
|
ru: '',
|
|
id: '',
|
|
})
|
|
const [formCountry, setFormCountry] = useState('عراق')
|
|
const [formFlag, setFormFlag] = useState('🇮🇶')
|
|
const [selectedCityPresetId, setSelectedCityPresetId] = useState<string>('')
|
|
const [formIsActive, setFormIsActive] = useState(true)
|
|
const [formImage, setFormImage] = useState<string>('')
|
|
const [formBlogSlug, setFormBlogSlug] = useState<string>('')
|
|
const [formJourneysCount, setFormJourneysCount] = useState<number>(10)
|
|
|
|
const currentLang =
|
|
SERVICE_LANGUAGES.find((l) => l.code === activeLangTab) || SERVICE_LANGUAGES[0]
|
|
|
|
const availableCitiesForCountry = useMemo(() => {
|
|
return OFFICIAL_PRESET_CITIES.filter((c) => c.country === formCountry)
|
|
}, [formCountry])
|
|
|
|
const countries = useMemo(() => {
|
|
return Array.from(new Set(destinations.map((d) => d.country)))
|
|
}, [destinations])
|
|
|
|
const filtered = useMemo(() => {
|
|
return destinations.filter((d) => {
|
|
const matchCountry = selectedCountry === 'all' || d.country === selectedCountry
|
|
const term = search.trim().toLowerCase()
|
|
const matchSearch =
|
|
!term ||
|
|
d.name.toLowerCase().includes(term) ||
|
|
(d.nameEn && d.nameEn.toLowerCase().includes(term)) ||
|
|
d.country.toLowerCase().includes(term) ||
|
|
(d.description && d.description.toLowerCase().includes(term))
|
|
return matchCountry && matchSearch
|
|
})
|
|
}, [destinations, selectedCountry, search])
|
|
|
|
const handleOpenAdd = () => {
|
|
setEditingItem(null)
|
|
setActiveLangTab('ar')
|
|
setNames({ ar: '', fa: '', en: '', ru: '', id: '' })
|
|
setHolyPlacesMap({ ar: '', fa: '', en: '', ru: '', id: '' })
|
|
setDescriptionsMap({ ar: '', fa: '', en: '', ru: '', id: '' })
|
|
setFormCountry('عراق')
|
|
setFormFlag('🇮🇶')
|
|
setSelectedCityPresetId('')
|
|
setFormIsActive(true)
|
|
setFormImage('')
|
|
setFormBlogSlug('')
|
|
setFormJourneysCount(10)
|
|
setValidationError(null)
|
|
setIsFormOpen(true)
|
|
}
|
|
|
|
const handleOpenEdit = (item: CustomTripDestinationItem) => {
|
|
setEditingItem(item)
|
|
setActiveLangTab('ar')
|
|
const initialNames: Record<ServiceLanguageCode, string> = { ar: '', fa: '', en: '', ru: '', id: '' }
|
|
const initialHoly: Record<ServiceLanguageCode, string> = { ar: '', fa: '', en: '', ru: '', id: '' }
|
|
const initialDesc: Record<ServiceLanguageCode, string> = { ar: '', fa: '', en: '', ru: '', id: '' }
|
|
|
|
if (item.translations) {
|
|
for (const lang of ['ar', 'fa', 'en', 'ru', 'id'] as ServiceLanguageCode[]) {
|
|
if (item.translations[lang]?.name) initialNames[lang] = item.translations[lang].name!
|
|
if (item.translations[lang]?.description) initialDesc[lang] = item.translations[lang].description!
|
|
if (item.translations[lang]?.holyPlaces) initialHoly[lang] = item.translations[lang].holyPlaces!.join('، ')
|
|
}
|
|
}
|
|
// Fallbacks from existing legacy fields
|
|
if (!initialNames.fa) initialNames.fa = item.name || ''
|
|
if (!initialNames.ar) initialNames.ar = item.name || ''
|
|
if (!initialNames.en && item.nameEn) initialNames.en = item.nameEn
|
|
if (!initialDesc.fa && item.description) initialDesc.fa = item.description
|
|
if (!initialDesc.ar && item.description) initialDesc.ar = item.description
|
|
if (!initialHoly.fa && item.holyPlaces?.length) initialHoly.fa = item.holyPlaces.join('، ')
|
|
if (!initialHoly.ar && item.holyPlaces?.length) initialHoly.ar = item.holyPlaces.join('، ')
|
|
|
|
setNames(initialNames)
|
|
setHolyPlacesMap(initialHoly)
|
|
setDescriptionsMap(initialDesc)
|
|
setFormCountry(item.country)
|
|
setFormFlag(item.flag || '📍')
|
|
setFormImage(item.image || '')
|
|
setFormBlogSlug(item.blogSlug || item.blog_slug || '')
|
|
setFormJourneysCount(item.journeysCount ?? item.journeys_count ?? 10)
|
|
|
|
// Find if item corresponds to an official preset city
|
|
const matched = OFFICIAL_PRESET_CITIES.find(
|
|
(c) =>
|
|
c.id === item.id ||
|
|
c.names.fa === item.name ||
|
|
c.names.ar === item.name ||
|
|
(item.nameEn && c.names.en.toLowerCase() === item.nameEn.toLowerCase())
|
|
)
|
|
setSelectedCityPresetId(matched ? matched.id : 'custom')
|
|
|
|
setFormIsActive(item.isActive)
|
|
setValidationError(null)
|
|
setIsFormOpen(true)
|
|
}
|
|
|
|
const handleCountryChange = (cName: string) => {
|
|
setFormCountry(cName)
|
|
const preset = PRESET_DEST_COUNTRIES.find((p) => p.name === cName)
|
|
if (preset) {
|
|
setFormFlag(preset.flag)
|
|
}
|
|
setSelectedCityPresetId('')
|
|
}
|
|
|
|
const handlePresetCityChange = (cityId: string) => {
|
|
setSelectedCityPresetId(cityId)
|
|
if (!cityId || cityId === 'custom') return
|
|
|
|
const presetCity = OFFICIAL_PRESET_CITIES.find((c) => c.id === cityId)
|
|
if (presetCity) {
|
|
setNames({ ...presetCity.names })
|
|
setHolyPlacesMap({ ...presetCity.holyPlaces })
|
|
setDescriptionsMap({ ...presetCity.description })
|
|
setValidationError(null)
|
|
}
|
|
}
|
|
|
|
const handleSaveForm = (e?: React.FormEvent) => {
|
|
if (e) e.preventDefault()
|
|
|
|
const primaryName =
|
|
names[activeLangTab].trim() ||
|
|
names.fa.trim() ||
|
|
names.ar.trim() ||
|
|
names.en.trim() ||
|
|
names.ru.trim() ||
|
|
names.id.trim()
|
|
|
|
if (!primaryName) {
|
|
setValidationError('لطفاً نام شهر مقصد را وارد نمایید.')
|
|
return
|
|
}
|
|
|
|
const translationsRecord: Record<string, { name?: string; description?: string; holyPlaces?: string[] }> = {}
|
|
for (const lang of ['ar', 'fa', 'en', 'ru', 'id'] as ServiceLanguageCode[]) {
|
|
const n = names[lang]?.trim()
|
|
const d = descriptionsMap[lang]?.trim()
|
|
const hStr = holyPlacesMap[lang]?.trim()
|
|
const hArr = hStr ? hStr.split(/[،,]/).map((s) => s.trim()).filter(Boolean) : undefined
|
|
if (n || d || (hArr && hArr.length)) {
|
|
translationsRecord[lang] = {
|
|
name: n || undefined,
|
|
description: d || undefined,
|
|
holyPlaces: hArr,
|
|
}
|
|
}
|
|
}
|
|
|
|
const holyPlacesArray = (holyPlacesMap.fa || holyPlacesMap.ar || holyPlacesMap[activeLangTab] || '')
|
|
.split(/[،,]/)
|
|
.map((s) => s.trim())
|
|
.filter(Boolean)
|
|
|
|
if (editingItem && onUpdateDestination) {
|
|
const updated: CustomTripDestinationItem = {
|
|
...editingItem,
|
|
name: primaryName,
|
|
nameEn: names.en.trim() || undefined,
|
|
country: formCountry.trim(),
|
|
flag: formFlag,
|
|
image: formImage.trim() || undefined,
|
|
blogSlug: formBlogSlug.trim() || undefined,
|
|
journeysCount: Number(formJourneysCount) || 10,
|
|
description: descriptionsMap.fa.trim() || descriptionsMap.ar.trim() || undefined,
|
|
holyPlaces: holyPlacesArray.length ? holyPlacesArray : undefined,
|
|
isActive: formIsActive,
|
|
translations: translationsRecord,
|
|
}
|
|
onUpdateDestination(updated)
|
|
} else {
|
|
const newDest: CustomTripDestinationItem = {
|
|
id: selectedCityPresetId && selectedCityPresetId !== 'custom' ? selectedCityPresetId : `dest_${Date.now()}`,
|
|
name: primaryName,
|
|
nameEn: names.en.trim() || undefined,
|
|
country: formCountry.trim() || 'عراق',
|
|
flag: formFlag,
|
|
image: formImage.trim() || undefined,
|
|
blogSlug: formBlogSlug.trim() || undefined,
|
|
journeysCount: Number(formJourneysCount) || 10,
|
|
description: descriptionsMap.fa.trim() || descriptionsMap.ar.trim() || undefined,
|
|
holyPlaces: holyPlacesArray.length ? holyPlacesArray : undefined,
|
|
hotelsCount: 0,
|
|
isActive: formIsActive,
|
|
translations: translationsRecord,
|
|
}
|
|
onAddDestination(newDest)
|
|
}
|
|
setIsFormOpen(false)
|
|
}
|
|
|
|
const handleConfirmDelete = () => {
|
|
if (itemToDelete && onDeleteDestination) {
|
|
onDeleteDestination(itemToDelete.id)
|
|
}
|
|
setItemToDelete(null)
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
{/* KPI Stats */}
|
|
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
|
<div className="p-3.5 rounded-2xl bg-card border border-border/70 shadow-xs">
|
|
<span className="text-[11px] text-muted-foreground font-medium block">
|
|
{t('customTrip.allDestinationsCount')}
|
|
</span>
|
|
<div className="mt-1 flex items-baseline gap-1.5">
|
|
<span className="text-xl font-black font-mono text-foreground">{toFa(destinations.length)}</span>
|
|
<span className="text-xs text-muted-foreground">{t('customTrip.destCities')}</span>
|
|
</div>
|
|
</div>
|
|
<div className="p-3.5 rounded-2xl bg-card border border-border/70 shadow-xs">
|
|
<span className="text-[11px] text-muted-foreground font-medium block">
|
|
{t('customTrip.destinationsIraq')}
|
|
</span>
|
|
<div className="mt-1 flex items-baseline gap-1.5">
|
|
<span className="text-xl font-black font-mono text-emerald-600 dark:text-emerald-400">
|
|
{toFa(destinations.filter((d) => d.country === 'عراق').length)}
|
|
</span>
|
|
<span className="text-xs text-muted-foreground">{t('customTrip.destCities')}</span>
|
|
</div>
|
|
</div>
|
|
<div className="p-3.5 rounded-2xl bg-card border border-border/70 shadow-xs">
|
|
<span className="text-[11px] text-muted-foreground font-medium block">
|
|
{t('customTrip.destinationsIran')}
|
|
</span>
|
|
<div className="mt-1 flex items-baseline gap-1.5">
|
|
<span className="text-xl font-black font-mono text-blue-600 dark:text-blue-400">
|
|
{toFa(destinations.filter((d) => d.country === 'ایران').length)}
|
|
</span>
|
|
<span className="text-xs text-muted-foreground">{t('customTrip.destCities')}</span>
|
|
</div>
|
|
</div>
|
|
<div className="p-3.5 rounded-2xl bg-card border border-border/70 shadow-xs">
|
|
<span className="text-[11px] text-muted-foreground font-medium block">
|
|
{t('customTrip.destinationsSaudi')}
|
|
</span>
|
|
<div className="mt-1 flex items-baseline gap-1.5">
|
|
<span className="text-xl font-black font-mono text-amber-600 dark:text-amber-400">
|
|
{toFa(destinations.filter((d) => d.country === 'عربستان سعودی').length)}
|
|
</span>
|
|
<span className="text-xs text-muted-foreground">{t('customTrip.destCities')}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Filter and Action Bar */}
|
|
<div className="flex flex-col gap-3 bg-card p-3 rounded-2xl border border-border/70 shadow-xs">
|
|
<div className="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
|
|
<div className="relative flex-1">
|
|
<Ic name="search" className="absolute top-1/2 -translate-y-1/2 start-3 size-4 text-muted-foreground" />
|
|
<Input
|
|
value={search}
|
|
onChange={(e) => setSearch(e.target.value)}
|
|
placeholder="جستجوی شهر مقصد زیارتی، اماکن مقدسه یا کشور..."
|
|
className="ps-9 h-10 rounded-xl bg-background border-border/60 text-xs sm:text-sm"
|
|
/>
|
|
</div>
|
|
|
|
<Button
|
|
onClick={handleOpenAdd}
|
|
className="rounded-xl h-10 gap-1.5 font-bold text-xs sm:text-sm shrink-0"
|
|
>
|
|
<Ic name="plus" className="size-4" />
|
|
{t('customTrip.addDestination')}
|
|
</Button>
|
|
</div>
|
|
|
|
{/* Country filter chips */}
|
|
<div className="flex flex-wrap items-center gap-x-1.5 gap-y-2 pt-1 pb-0.5">
|
|
<span className="text-xs text-muted-foreground font-medium shrink-0 ps-1">
|
|
{t('customTrip.filterByCountry')}:
|
|
</span>
|
|
<button
|
|
onClick={() => setSelectedCountry('all')}
|
|
className={`px-3 py-1 rounded-xl text-xs font-semibold whitespace-nowrap transition-colors ${
|
|
selectedCountry === 'all'
|
|
? 'bg-primary text-white shadow-xs'
|
|
: 'bg-muted/70 text-muted-foreground hover:bg-muted hover:text-foreground'
|
|
}`}
|
|
>
|
|
{t('customTrip.allDestinations')} ({toFa(destinations.length)})
|
|
</button>
|
|
{countries.map((c) => {
|
|
const count = destinations.filter((d) => d.country === c).length
|
|
const preset = PRESET_DEST_COUNTRIES.find((p) => p.name === c)
|
|
return (
|
|
<button
|
|
key={c}
|
|
onClick={() => setSelectedCountry(c)}
|
|
className={`flex items-center gap-1 px-3 py-1 rounded-xl text-xs font-semibold whitespace-nowrap transition-colors ${
|
|
selectedCountry === c
|
|
? 'bg-primary text-white shadow-xs'
|
|
: 'bg-muted/70 text-muted-foreground hover:bg-muted hover:text-foreground'
|
|
}`}
|
|
>
|
|
<span>{preset?.flag || '📍'}</span>
|
|
<span>{c}</span>
|
|
<span className="opacity-75 font-mono text-[10px]">({toFa(count)})</span>
|
|
</button>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Destinations Table */}
|
|
<div className="overflow-hidden rounded-2xl border border-border/70 bg-card shadow-xs">
|
|
<div className="overflow-x-auto">
|
|
<table className="w-full text-xs sm:text-sm text-start">
|
|
<thead className="bg-muted/40 text-muted-foreground border-b border-border/60 font-medium">
|
|
<tr>
|
|
<th className="px-4 py-3.5 text-start">ردیف</th>
|
|
<th className="px-4 py-3.5 text-start">{t('customTrip.destinationCityName')}</th>
|
|
<th className="px-4 py-3.5 text-start">{t('customTrip.country')}</th>
|
|
<th className="px-4 py-3.5 text-center">هتلهای مقصد</th>
|
|
<th className="px-4 py-3.5 text-center">مسیرهای متصل</th>
|
|
<th className="px-4 py-3.5 text-center">وضعیت</th>
|
|
<th className="px-4 py-3.5 text-center">{t('customTrip.actions')}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody className="divide-y divide-border/50">
|
|
{filtered.length === 0 ? (
|
|
<tr>
|
|
<td colSpan={7} className="px-4 py-8 text-center text-xs text-muted-foreground">
|
|
مقصدی با این مشخصات یافت نشد.
|
|
</td>
|
|
</tr>
|
|
) : (
|
|
filtered.map((item, idx) => (
|
|
<tr
|
|
key={item.id}
|
|
onClick={() => navigate(`/custom-trip/destinations/${item.id}`)}
|
|
className="hover:bg-muted/40 transition-colors cursor-pointer group"
|
|
title="برای مشاهده جزئیات و مدیریت این مقصد کلیک کنید"
|
|
>
|
|
<td className="px-4 py-3.5 font-mono text-muted-foreground">{toFa(idx + 1)}</td>
|
|
<td className="px-4 py-3.5 font-bold text-foreground">
|
|
<div className="flex items-center gap-3">
|
|
{item.image ? (
|
|
<div className="size-11 rounded-xl overflow-hidden shrink-0 border border-border/70 bg-muted/40 shadow-2xs">
|
|
<img
|
|
src={item.image}
|
|
alt={item.name}
|
|
className="size-full object-cover group-hover:scale-105 transition-transform duration-300"
|
|
onError={(e) => {
|
|
(e.currentTarget as HTMLElement).style.display = 'none'
|
|
}}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<span className="text-xl select-none">{item.flag || '📍'}</span>
|
|
)}
|
|
<div>
|
|
<div className="group-hover:text-primary transition-colors flex items-center gap-1.5 font-bold text-sm">
|
|
<span>{item.name}</span>
|
|
<Ic name="arrowLeft" className="size-3 opacity-0 group-hover:opacity-100 transition-opacity text-primary" />
|
|
</div>
|
|
{item.nameEn && (
|
|
<span className="text-[11px] font-normal text-muted-foreground font-mono">
|
|
{item.nameEn}
|
|
</span>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td className="px-4 py-3.5 font-medium text-foreground">
|
|
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-muted/60 text-xs font-semibold">
|
|
<span>{item.flag || '📍'}</span>
|
|
<span>{item.country}</span>
|
|
</span>
|
|
</td>
|
|
<td className="px-4 py-3.5 text-center">
|
|
<span
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
navigate(`/custom-trip/destinations/${item.id}?tab=hotels`)
|
|
}}
|
|
className="inline-flex items-center gap-1 px-2.5 py-1 rounded-xl bg-card border border-border/70 text-xs font-semibold text-foreground hover:border-primary/50 transition-colors cursor-pointer"
|
|
title="مشاهده و مدیریت هتلهای این مقصد"
|
|
>
|
|
<Ic name="bed" className="size-3.5 text-primary" />
|
|
<span className="font-mono">{toFa(getHotelCount(item))}</span>
|
|
<span className="text-[11px] text-muted-foreground">هتل</span>
|
|
</span>
|
|
</td>
|
|
<td className="px-4 py-3.5 text-center">
|
|
<span className="inline-flex items-center gap-1 px-2.5 py-1 rounded-xl bg-card border border-border/70 text-xs font-semibold text-foreground">
|
|
<Ic name="route" className="size-3.5 text-primary" />
|
|
<span className="font-mono">{toFa(getTransportCount(item))}</span>
|
|
<span className="text-[11px] text-muted-foreground">مسیر</span>
|
|
</span>
|
|
</td>
|
|
<td className="px-4 py-3.5 text-center">
|
|
<button
|
|
type="button"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
if (onUpdateDestination) {
|
|
onUpdateDestination({ ...item, isActive: !item.isActive })
|
|
}
|
|
}}
|
|
className={`inline-flex items-center gap-1.5 text-xs font-semibold px-2.5 py-1 rounded-full transition-all cursor-pointer ${
|
|
item.isActive
|
|
? 'bg-emerald-500/10 text-emerald-600 hover:bg-emerald-500/20'
|
|
: 'bg-muted text-muted-foreground hover:bg-muted/80'
|
|
}`}
|
|
title="تغییر وضعیت فعال/غیرفعال"
|
|
>
|
|
<span
|
|
className={`size-1.5 rounded-full ${
|
|
item.isActive ? 'bg-emerald-500 animate-pulse' : 'bg-muted-foreground'
|
|
}`}
|
|
/>
|
|
<span>{item.isActive ? t('customTrip.active') : t('customTrip.inactive')}</span>
|
|
</button>
|
|
</td>
|
|
<td className="px-4 py-3.5 text-center">
|
|
<div className="flex items-center justify-center gap-1">
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
handleOpenEdit(item)
|
|
}}
|
|
className="size-8 p-0 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground cursor-pointer"
|
|
title="ویرایش مشخصات در پاپآپ"
|
|
>
|
|
<Ic name="pencil" className="size-3.5" />
|
|
</Button>
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
navigate(`/custom-trip/destinations/${item.id}`)
|
|
}}
|
|
className="size-8 p-0 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground cursor-pointer"
|
|
title="مشاهده و مدیریت هتلها و مسیرها"
|
|
>
|
|
<Ic name="eye" className="size-3.5" />
|
|
</Button>
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
type="button"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
setItemToDelete(item)
|
|
}}
|
|
className="size-8 p-0 rounded-lg hover:bg-rose-500/10 text-muted-foreground hover:text-rose-600 cursor-pointer"
|
|
title="حذف مقصد"
|
|
>
|
|
<Ic name="trash" className="size-3.5" />
|
|
</Button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
))
|
|
)}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Add / Edit Destination Modal */}
|
|
<Dialog open={isFormOpen} onOpenChange={setIsFormOpen}>
|
|
<DialogContent className="sm:max-w-xl md:max-w-2xl w-full rounded-2xl bg-card border border-border-soft p-0 max-h-[85vh] flex flex-col overflow-hidden shadow-2xl">
|
|
{/* هدر ثابت مدال */}
|
|
<DialogHeader className="p-6 pb-4 border-b border-border-soft shrink-0 text-start">
|
|
<div className="flex items-center gap-3">
|
|
<div className="size-10 rounded-xl bg-primary/10 text-primary flex items-center justify-center shrink-0">
|
|
<Ic name="map" className="size-5" />
|
|
</div>
|
|
<div>
|
|
<DialogTitle className="text-lg font-bold text-foreground">
|
|
{editingItem ? t('customTrip.editDestination') : t('customTrip.addDestination')}
|
|
</DialogTitle>
|
|
<DialogDescription className="text-xs text-muted-foreground mt-0.5">
|
|
شهر مقصد زیارتی جدیدی را برای انتخاب زائرین تعریف یا مشخصات آن را ویرایش کنید.
|
|
</DialogDescription>
|
|
</div>
|
|
</div>
|
|
</DialogHeader>
|
|
|
|
{/* فرم: بدنه اسکرولشونده و فوتر فیکسشده */}
|
|
<form onSubmit={handleSaveForm} className="flex flex-col flex-1 overflow-hidden min-h-0">
|
|
<div className="flex-1 overflow-y-auto p-6 space-y-5">
|
|
{validationError && (
|
|
<div className="p-3.5 rounded-xl bg-rose-500/10 border border-rose-500/20 text-rose-500 text-xs flex items-center gap-2 font-medium">
|
|
<Ic name="alert" className="size-4 shrink-0" />
|
|
<span>{validationError}</span>
|
|
</div>
|
|
)}
|
|
|
|
{/* تبهای ۵ زبانه با کامپوننت مشترک ServiceTranslation */}
|
|
<div className="space-y-4 rounded-2xl border border-border-soft bg-card/40 p-4">
|
|
<div className="border-b border-border-soft pb-2.5">
|
|
<ServiceTranslation
|
|
activeLang={activeLangTab}
|
|
onLangChange={(lang) => setActiveLangTab(lang)}
|
|
completedLangs={{
|
|
ar: Boolean(names.ar?.trim()),
|
|
fa: Boolean(names.fa?.trim()),
|
|
en: Boolean(names.en?.trim()),
|
|
ru: Boolean(names.ru?.trim()),
|
|
id: Boolean(names.id?.trim()),
|
|
}}
|
|
primaryLang="ar"
|
|
title="اطلاعات متنی و چندزبانه مقصد"
|
|
required
|
|
variant="pills"
|
|
/>
|
|
</div>
|
|
|
|
{/* فیلدهای تنظیمات رسانهای، تصویر و پیوند به راهنمای بلاگ */}
|
|
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3 p-3.5 rounded-xl bg-card border border-border/70 shadow-2xs">
|
|
{/* آدرس یا مسیر تصویر شهر */}
|
|
<div className="space-y-1.5 sm:col-span-2">
|
|
<label className="text-xs font-bold text-foreground flex items-center justify-between">
|
|
<span className="flex items-center gap-1.5">
|
|
<Ic name="image" className="size-3.5 text-muted-foreground" />
|
|
<span>تصویر شهر مقصد (URL یا مسیر فایل)</span>
|
|
</span>
|
|
{formImage && (
|
|
<span className="text-[10px] text-emerald-600 font-medium">دارای تصویر</span>
|
|
)}
|
|
</label>
|
|
<Input
|
|
value={formImage}
|
|
onChange={(e) => setFormImage(e.target.value)}
|
|
dir="ltr"
|
|
placeholder="مثال: /media/destinations/karbala.jpg یا https://..."
|
|
className="h-10 rounded-xl text-xs bg-card border-border/70 font-mono shadow-2xs"
|
|
/>
|
|
</div>
|
|
|
|
{/* تعداد تورها / سفرها */}
|
|
<div className="space-y-1.5">
|
|
<label className="text-xs font-bold text-foreground block">
|
|
تعداد سفرهای فعال:
|
|
</label>
|
|
<Input
|
|
type="number"
|
|
min={0}
|
|
value={formJourneysCount}
|
|
onChange={(e) => setFormJourneysCount(Number(e.target.value) || 0)}
|
|
dir="ltr"
|
|
className="h-10 rounded-xl text-xs bg-card border-border/70 font-mono shadow-2xs"
|
|
/>
|
|
</div>
|
|
|
|
{/* اسلاگ مقاله بلاگ */}
|
|
<div className="space-y-1.5 sm:col-span-3">
|
|
<label className="text-xs font-bold text-foreground block">
|
|
اسلاگ مقاله راهنمای زیارت در بلاگ (اختیاری):
|
|
</label>
|
|
<Input
|
|
value={formBlogSlug}
|
|
onChange={(e) => setFormBlogSlug(e.target.value)}
|
|
dir="ltr"
|
|
placeholder="مثال: ziyarat-rituals-and-prayers-of-karbala"
|
|
className="h-10 rounded-xl text-xs bg-card border-border/70 font-mono shadow-2xs"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
{/* فیلدهای انتخابی کشور و شهر بر اساس کشور انتخابی (پایینتر از تبهای زبان) */}
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3 p-3.5 rounded-xl bg-card border border-border/70 shadow-2xs">
|
|
{/* فیلد انتخابی کشور مقصد */}
|
|
<div className="space-y-1.5">
|
|
<label className="text-xs font-bold text-foreground flex items-center justify-between">
|
|
<span className="flex items-center gap-1.5">
|
|
<span>{t('customTrip.country')}</span>
|
|
<span className="text-rose-500">*</span>
|
|
</span>
|
|
<span className="text-[11px] text-muted-foreground font-normal">
|
|
({formFlag} {formCountry})
|
|
</span>
|
|
</label>
|
|
<Select
|
|
value={formCountry}
|
|
onValueChange={(val) => handleCountryChange(val)}
|
|
>
|
|
<SelectTrigger className="h-10 text-xs rounded-xl bg-card border-border/70 hover:border-border">
|
|
<SelectValue placeholder="انتخاب کشور مقصد..." />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{PRESET_DEST_COUNTRIES.map((c) => (
|
|
<SelectItem key={c.name} value={c.name}>
|
|
<span className="flex items-center gap-2">
|
|
<span className="text-base select-none">{c.flag}</span>
|
|
<span className="font-medium">{c.name}</span>
|
|
</span>
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
|
|
{/* فیلد انتخابی شهر مقصد بر اساس کشور انتخابی */}
|
|
<div className="space-y-1.5">
|
|
<label className="text-xs font-bold text-foreground flex items-center justify-between">
|
|
<span>شهر مقصد (وابسته به {formCountry})</span>
|
|
<span className="text-[11px] text-muted-foreground font-normal">
|
|
{availableCitiesForCountry.length > 0 ? '(مقاصد رسمی فلاتر و دیتابیس)' : ''}
|
|
</span>
|
|
</label>
|
|
<Select
|
|
value={selectedCityPresetId}
|
|
onValueChange={(val) => handlePresetCityChange(val)}
|
|
>
|
|
<SelectTrigger className="h-10 text-xs rounded-xl bg-card border-border/70 hover:border-border">
|
|
<SelectValue placeholder={`انتخاب شهر از مقاصد رسمی ${formCountry}...`} />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{availableCitiesForCountry.map((city) => (
|
|
<SelectItem key={city.id} value={city.id}>
|
|
<span className="flex items-center gap-1.5">
|
|
<span className="font-bold">{city.names.fa}</span>
|
|
<span className="text-muted-foreground text-[11px]">
|
|
({city.names.ar} - {city.names.en})
|
|
</span>
|
|
</span>
|
|
</SelectItem>
|
|
))}
|
|
<SelectItem value="custom">-- شهر سفارشی دیگر... --</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
</div>
|
|
|
|
{/* فیلدهای ترجمهپذیر متناسب با زبان فعال */}
|
|
<div className="space-y-4 pt-1" dir={currentLang.dir}>
|
|
<div className="space-y-1.5">
|
|
<div className="flex items-center justify-between">
|
|
<label className="text-xs font-bold text-foreground flex items-center gap-1.5">
|
|
<span>نام شهر مقصد ({currentLang.name})</span>
|
|
<span className="text-[10px] px-1.5 py-0.5 rounded font-mono font-bold bg-primary/10 text-primary border border-primary/20">
|
|
{currentLang.badge}
|
|
</span>
|
|
<span className="text-rose-500">*</span>
|
|
</label>
|
|
<span className="text-[11px] text-muted-foreground font-mono">
|
|
{currentLang.dir.toUpperCase()}
|
|
</span>
|
|
</div>
|
|
<Input
|
|
value={names[activeLangTab] || ''}
|
|
onChange={(e) =>
|
|
setNames((prev) => ({ ...prev, [activeLangTab]: e.target.value }))
|
|
}
|
|
dir={currentLang.dir}
|
|
placeholder={`مثال: ${
|
|
currentLang.code === 'ar'
|
|
? 'كربلاء المقدسة'
|
|
: currentLang.code === 'fa'
|
|
? 'کربلای معلی'
|
|
: 'Karbala'
|
|
}`}
|
|
className="h-10 rounded-xl text-xs bg-card border-border/70 focus-visible:border-primary focus-visible:ring-1 focus-visible:ring-primary shadow-2xs"
|
|
required={activeLangTab === 'fa' || activeLangTab === 'ar'}
|
|
/>
|
|
</div>
|
|
|
|
<div className="space-y-1.5">
|
|
<label className="text-xs font-bold text-foreground flex items-center gap-1.5">
|
|
<span>اماکن مقدسه و زیارتگاهها ({currentLang.name})</span>
|
|
<span className="text-[11px] text-muted-foreground font-normal">(با ویرگول جدا کنید)</span>
|
|
</label>
|
|
<Input
|
|
value={holyPlacesMap[activeLangTab] || ''}
|
|
onChange={(e) =>
|
|
setHolyPlacesMap((prev) => ({ ...prev, [activeLangTab]: e.target.value }))
|
|
}
|
|
dir={currentLang.dir}
|
|
placeholder={
|
|
currentLang.code === 'ar'
|
|
? 'حرم الإمام الحسين (ع)، حرم أبي الفضل العباس (ع)، التل الزينبي'
|
|
: 'حرم امام حسین (ع)، حرم حضرت عباس (ع)، تل زینبیه'
|
|
}
|
|
className="h-10 rounded-xl text-xs bg-card border-border/70 focus-visible:border-primary focus-visible:ring-1 focus-visible:ring-primary shadow-2xs"
|
|
/>
|
|
</div>
|
|
|
|
<div className="space-y-1.5">
|
|
<label className="text-xs font-bold text-foreground">
|
|
توضیحات و راهنمای مقصد ({currentLang.name})
|
|
</label>
|
|
<Textarea
|
|
value={descriptionsMap[activeLangTab] || ''}
|
|
onChange={(e) =>
|
|
setDescriptionsMap((prev) => ({ ...prev, [activeLangTab]: e.target.value }))
|
|
}
|
|
dir={currentLang.dir}
|
|
rows={3}
|
|
placeholder="توضیحاتی درباره موقعیت شهر، شرایط ورود و آداب زیارت..."
|
|
className="rounded-xl border border-border/70 bg-card text-xs text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-none resize-none shadow-2xs"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* ۳. وضعیت فعال بودن در اپلیکیشن */}
|
|
<div className="flex items-center justify-between p-4 rounded-2xl border border-border/70 bg-card shadow-2xs">
|
|
<div className="space-y-0.5 pe-4">
|
|
<div className="text-xs font-bold text-foreground flex items-center gap-2">
|
|
<span
|
|
className={cn(
|
|
'size-2 rounded-full',
|
|
formIsActive ? 'bg-emerald-500 animate-pulse' : 'bg-muted-foreground'
|
|
)}
|
|
/>
|
|
<span>وضعیت شهر مقصد</span>
|
|
<span
|
|
className={cn(
|
|
'text-[10px] font-semibold px-2 py-0.5 rounded-full',
|
|
formIsActive
|
|
? 'bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20'
|
|
: 'bg-muted text-muted-foreground border border-border-soft'
|
|
)}
|
|
>
|
|
{formIsActive ? 'فعال' : 'غیرفعال'}
|
|
</span>
|
|
</div>
|
|
<p className="text-[11px] text-muted-foreground leading-relaxed">
|
|
در صورت غیرفعال بودن، زائرین امکان انتخاب این شهر را در چت سفر اختصاصی نخواهند داشت.
|
|
</p>
|
|
</div>
|
|
<div className="shrink-0">
|
|
<Switch
|
|
checked={formIsActive}
|
|
onCheckedChange={setFormIsActive}
|
|
aria-label="تغییر وضعیت فعال بودن شهر مقصد"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* فوتر فیکسشده در پایین مدال */}
|
|
<DialogFooter className="p-4 sm:p-5 border-t border-border-soft bg-card/95 backdrop-blur-xs flex items-center justify-end gap-2.5 shrink-0 mt-0">
|
|
<Button
|
|
variant="outline"
|
|
type="button"
|
|
onClick={() => setIsFormOpen(false)}
|
|
className="rounded-xl text-xs h-9 px-4 border-border-soft hover:bg-muted"
|
|
>
|
|
{t('customTrip.cancel')}
|
|
</Button>
|
|
<Button
|
|
type="submit"
|
|
className="rounded-xl text-xs font-bold h-9 px-5 bg-primary text-primary-foreground hover:bg-primary/90 shadow-xs"
|
|
>
|
|
{t('customTrip.saveChanges')}
|
|
</Button>
|
|
</DialogFooter>
|
|
</form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
|
|
{/* Delete Confirmation Modal using shared DeleteConfirmDialog */}
|
|
<DeleteConfirmDialog
|
|
open={!!itemToDelete}
|
|
onOpenChange={(open) => !open && setItemToDelete(null)}
|
|
title={t('customTrip.deleteDestination')}
|
|
description={`آیا از حذف مقصد «${itemToDelete?.name || ''}» (${itemToDelete?.country || ''}) اطمینان دارید؟ این عمل قابل بازگشت نیست.`}
|
|
onConfirm={handleConfirmDelete}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|