Browse Source
feat: add settings and tours features with localization and navigation configuration
master
feat: add settings and tours features with localization and navigation configuration
master
9 changed files with 2076 additions and 617 deletions
-
6src/config/navigation.ts
-
7src/features/settings/SettingsPage.tsx
-
846src/features/settings/components/AboutUsTab.tsx
-
17src/features/settings/services/settings-api.ts
-
52src/features/settings/types.ts
-
1615src/features/tours/components/CreateTourDialog.tsx
-
50src/locales/ar.json
-
50src/locales/en.json
-
50src/locales/fa.json
@ -0,0 +1,846 @@ |
|||
import * as React from 'react' |
|||
import { useTranslation } from '@/i18n' |
|||
import { Card, CardContent } from '@/components/ui/card' |
|||
import { Badge } from '@/components/ui/badge' |
|||
import { Button } from '@/components/ui/button' |
|||
import { Input } from '@/components/ui/input' |
|||
import { Textarea } from '@/components/ui/textarea' |
|||
import { Switch } from '@/components/ui/switch' |
|||
import { |
|||
ServiceTranslation, |
|||
type ServiceLanguageCode, |
|||
} from '@/components/shared/ServiceTranslation' |
|||
import { Shimmer } from '@/components/shared/shimmer_frontend' |
|||
import { Ic } from '@/icons' |
|||
import { toast } from '@/stores/toast' |
|||
import { fetchAboutUsContent, saveAboutUsContent } from '../services/settings-api' |
|||
import type { |
|||
AboutUsLanguageData, |
|||
AboutUsTranslations, |
|||
} from '../types' |
|||
|
|||
const LANG_CODES: ServiceLanguageCode[] = ['fa', 'ar', 'en', 'ru', 'id'] |
|||
|
|||
function createEmptyLangData(): AboutUsLanguageData { |
|||
return { |
|||
badge: '', |
|||
heading: '', |
|||
subheading: '', |
|||
regions: ['', '', ''], |
|||
stats_title: '', |
|||
stats_subtitle: '', |
|||
stats: [ |
|||
{ id: '1', num: '', title: '', desc: '' }, |
|||
{ id: '2', num: '', title: '', desc: '' }, |
|||
{ id: '3', num: '', title: '', desc: '' }, |
|||
{ id: '4', num: '', title: '', desc: '' }, |
|||
], |
|||
pillars_title: '', |
|||
pillars_subtitle: '', |
|||
pillars: [ |
|||
{ id: 'official', icon: 'shield', title: '', desc: '', footer: '' }, |
|||
{ id: 'hospitality', icon: 'building', title: '', desc: '', footer: '' }, |
|||
{ id: 'family-care', icon: 'heart', title: '', desc: '', footer: '' }, |
|||
], |
|||
} |
|||
} |
|||
|
|||
function normalizeLangData(raw?: Partial<AboutUsLanguageData>): AboutUsLanguageData { |
|||
const base = createEmptyLangData() |
|||
if (!raw) return base |
|||
|
|||
const regions = [0, 1, 2].map((i) => raw.regions?.[i] || '') |
|||
const stats = base.stats.map((defStat, i) => ({ |
|||
id: raw.stats?.[i]?.id || defStat.id, |
|||
num: raw.stats?.[i]?.num || '', |
|||
title: raw.stats?.[i]?.title || '', |
|||
desc: raw.stats?.[i]?.desc || '', |
|||
})) |
|||
const pillars = base.pillars.map((defPillar, i) => ({ |
|||
id: raw.pillars?.[i]?.id || defPillar.id, |
|||
icon: raw.pillars?.[i]?.icon || defPillar.icon, |
|||
title: raw.pillars?.[i]?.title || '', |
|||
desc: raw.pillars?.[i]?.desc || '', |
|||
footer: raw.pillars?.[i]?.footer || '', |
|||
})) |
|||
|
|||
return { |
|||
badge: raw.badge || '', |
|||
heading: raw.heading || '', |
|||
subheading: raw.subheading || '', |
|||
regions, |
|||
stats_title: raw.stats_title || '', |
|||
stats_subtitle: raw.stats_subtitle || '', |
|||
stats, |
|||
pillars_title: raw.pillars_title || '', |
|||
pillars_subtitle: raw.pillars_subtitle || '', |
|||
pillars, |
|||
} |
|||
} |
|||
|
|||
export function AboutUsTab() { |
|||
const { t, dir } = useTranslation() |
|||
const [loading, setLoading] = React.useState<boolean>(true) |
|||
const [saving, setSaving] = React.useState<boolean>(false) |
|||
const [mainTab, setMainTab] = React.useState<'structured' | 'html'>('structured') |
|||
const [activeLang, setActiveLang] = React.useState<ServiceLanguageCode>('fa') |
|||
const [htmlView, setHtmlView] = React.useState<'edit' | 'preview'>('edit') |
|||
|
|||
// Structured state
|
|||
const [showStats, setShowStats] = React.useState<boolean>(true) |
|||
const [showPillars, setShowPillars] = React.useState<boolean>(true) |
|||
const [heroImageUrl, setHeroImageUrl] = React.useState<string>('') |
|||
const [heroImageFile, setHeroImageFile] = React.useState<File | null>(null) |
|||
const [heroImagePreview, setHeroImagePreview] = React.useState<string | null>(null) |
|||
const [removeHeroImage, setRemoveHeroImage] = React.useState<boolean>(false) |
|||
const [translations, setTranslations] = React.useState<AboutUsTranslations>(() => ({ |
|||
fa: createEmptyLangData(), |
|||
ar: createEmptyLangData(), |
|||
en: createEmptyLangData(), |
|||
ru: createEmptyLangData(), |
|||
id: createEmptyLangData(), |
|||
})) |
|||
|
|||
// Mobile / Rich HTML state
|
|||
const [content, setContent] = React.useState<string>('') |
|||
|
|||
const loadContent = React.useCallback(async () => { |
|||
setLoading(true) |
|||
try { |
|||
const data = await fetchAboutUsContent() |
|||
setContent(data.custom_html || data.content || '') |
|||
setShowStats(data.show_stats !== false) |
|||
setShowPillars(data.show_pillars !== false) |
|||
setHeroImageUrl(data.hero_image_url || '') |
|||
setHeroImagePreview(data.hero_image || data.hero_image_url || null) |
|||
setHeroImageFile(null) |
|||
setRemoveHeroImage(false) |
|||
|
|||
const nextTrs: AboutUsTranslations = { |
|||
fa: createEmptyLangData(), |
|||
ar: createEmptyLangData(), |
|||
en: createEmptyLangData(), |
|||
ru: createEmptyLangData(), |
|||
id: createEmptyLangData(), |
|||
} |
|||
LANG_CODES.forEach((lc) => { |
|||
nextTrs[lc] = normalizeLangData(data.translations?.[lc]) |
|||
}) |
|||
setTranslations(nextTrs) |
|||
} catch { |
|||
toast.error(t('settings.aboutUsFetchError')) |
|||
} finally { |
|||
setLoading(false) |
|||
} |
|||
}, [t]) |
|||
|
|||
React.useEffect(() => { |
|||
loadContent() |
|||
}, [loadContent]) |
|||
|
|||
const currentLangData = translations[activeLang] || createEmptyLangData() |
|||
const activeFieldDir = activeLang === 'fa' || activeLang === 'ar' ? 'rtl' : 'ltr' |
|||
const completedLangs = React.useMemo( |
|||
() => |
|||
LANG_CODES.filter( |
|||
(lc) => |
|||
Boolean( |
|||
translations[lc]?.heading?.trim() && |
|||
translations[lc]?.subheading?.trim() |
|||
) |
|||
), |
|||
[translations] |
|||
) |
|||
|
|||
const updateCurrentLangField = <K extends keyof AboutUsLanguageData>( |
|||
key: K, |
|||
value: AboutUsLanguageData[K] |
|||
) => { |
|||
setTranslations((prev) => ({ |
|||
...prev, |
|||
[activeLang]: { |
|||
...prev[activeLang], |
|||
[key]: value, |
|||
}, |
|||
})) |
|||
} |
|||
|
|||
const updateRegion = (idx: number, val: string) => { |
|||
const nextRegions = [...currentLangData.regions] |
|||
nextRegions[idx] = val |
|||
updateCurrentLangField('regions', nextRegions) |
|||
} |
|||
|
|||
const updateStat = (idx: number, field: 'num' | 'title' | 'desc', val: string) => { |
|||
const nextStats = currentLangData.stats.map((st, i) => |
|||
i === idx ? { ...st, [field]: val } : st |
|||
) |
|||
updateCurrentLangField('stats', nextStats) |
|||
} |
|||
|
|||
const updatePillar = (idx: number, field: 'title' | 'desc' | 'footer', val: string) => { |
|||
const nextPillars = currentLangData.pillars.map((pl, i) => |
|||
i === idx ? { ...pl, [field]: val } : pl |
|||
) |
|||
updateCurrentLangField('pillars', nextPillars) |
|||
} |
|||
|
|||
const handleHeroFileSelect = (e: React.ChangeEvent<HTMLInputElement>) => { |
|||
const file = e.target.files?.[0] |
|||
if (file) { |
|||
setHeroImageFile(file) |
|||
setRemoveHeroImage(false) |
|||
setHeroImagePreview(URL.createObjectURL(file)) |
|||
} |
|||
} |
|||
|
|||
const handleResetHeroImage = () => { |
|||
setHeroImageFile(null) |
|||
setHeroImageUrl('') |
|||
setHeroImagePreview(null) |
|||
setRemoveHeroImage(true) |
|||
} |
|||
|
|||
const handleAutoSyncHtml = () => { |
|||
const faData = translations.fa || currentLangData |
|||
const parts: string[] = ['<div class="aqila-about-us">'] |
|||
if (faData.heading) parts.push(` <h2>${faData.heading}</h2>`) |
|||
if (faData.subheading) parts.push(` <p>${faData.subheading}</p>`) |
|||
const validRegions = faData.regions.filter((r) => r.trim()) |
|||
if (validRegions.length > 0) { |
|||
parts.push(' <ul>') |
|||
validRegions.forEach((r) => parts.push(` <li>${r}</li>`)) |
|||
parts.push(' </ul>') |
|||
} |
|||
if (faData.pillars_title) parts.push(` <h3>${faData.pillars_title}</h3>`) |
|||
faData.pillars.forEach((p) => { |
|||
if (p.title) { |
|||
parts.push(` <h4>${p.title}</h4>`) |
|||
if (p.desc) parts.push(` <p>${p.desc}</p>`) |
|||
} |
|||
}) |
|||
parts.push('</div>') |
|||
setContent(parts.join('\n')) |
|||
toast.success(t('settings.aboutUsAutoSyncHtmlBtn')) |
|||
} |
|||
|
|||
const handleSave = async () => { |
|||
setSaving(true) |
|||
try { |
|||
let res |
|||
if (heroImageFile) { |
|||
const formData = new FormData() |
|||
formData.append('show_stats', String(showStats)) |
|||
formData.append('show_pillars', String(showPillars)) |
|||
formData.append('hero_image', heroImageFile) |
|||
formData.append('content', content) |
|||
formData.append('translations', JSON.stringify(translations)) |
|||
res = await saveAboutUsContent(formData) |
|||
} else { |
|||
res = await saveAboutUsContent({ |
|||
show_stats: showStats, |
|||
show_pillars: showPillars, |
|||
hero_image_url: heroImageUrl, |
|||
remove_hero_image: removeHeroImage, |
|||
content, |
|||
translations, |
|||
}) |
|||
} |
|||
|
|||
if (res) { |
|||
setHeroImageUrl(res.hero_image_url || '') |
|||
setHeroImagePreview(res.hero_image || res.hero_image_url || null) |
|||
setHeroImageFile(null) |
|||
setRemoveHeroImage(false) |
|||
if (res.custom_html || res.content) { |
|||
setContent(res.custom_html || res.content) |
|||
} |
|||
} |
|||
toast.success(t('settings.aboutUsSaveSuccess')) |
|||
} catch { |
|||
toast.error(t('settings.aboutUsSaveError')) |
|||
} finally { |
|||
setSaving(false) |
|||
} |
|||
} |
|||
|
|||
const insertSnippet = (snippet: string) => { |
|||
setContent((prev) => (prev ? `${prev}\n${snippet}` : snippet)) |
|||
} |
|||
|
|||
if (loading) { |
|||
return ( |
|||
<div className="space-y-6"> |
|||
<Shimmer className="h-28 w-full rounded-2xl" /> |
|||
<Shimmer className="h-14 w-full rounded-2xl" /> |
|||
<Shimmer className="h-96 w-full rounded-2xl" /> |
|||
</div> |
|||
) |
|||
} |
|||
|
|||
return ( |
|||
<div className="space-y-6"> |
|||
{/* ۱. کارت سربرگ و مدیریت تنظیمات درباره ما */} |
|||
<Card className="border border-white/[0.08] bg-[#1e2129] shadow-md"> |
|||
<CardContent className="p-4 sm:p-6"> |
|||
<div className="flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between"> |
|||
<div className="flex items-start gap-4"> |
|||
<div className="flex size-12 shrink-0 items-center justify-center rounded-2xl bg-primary/15 text-primary border border-primary/25 shadow-inner"> |
|||
<Ic name="info" className="size-6" /> |
|||
</div> |
|||
<div className="space-y-1.5"> |
|||
<div className="flex items-center gap-2.5 flex-wrap"> |
|||
<h2 className="text-base sm:text-lg font-black text-white"> |
|||
{t('settings.aboutUsTitle')} |
|||
</h2> |
|||
<Badge variant="outline" className="border-emerald-500/30 bg-emerald-500/10 text-emerald-400 font-bold text-xs"> |
|||
{t('topbar.serverOnline')} |
|||
</Badge> |
|||
<Badge variant="outline" className="border-white/10 bg-white/[0.04] text-slate-300 font-mono text-[11px]"> |
|||
PostgreSQL Live Sync |
|||
</Badge> |
|||
</div> |
|||
<p className="text-xs text-slate-400 leading-relaxed max-w-2xl"> |
|||
{t('settings.aboutUsSubtitle')} |
|||
</p> |
|||
</div> |
|||
</div> |
|||
|
|||
<div className="flex items-center gap-2.5 shrink-0 flex-wrap sm:flex-nowrap"> |
|||
<Button |
|||
type="button" |
|||
variant="outline" |
|||
size="sm" |
|||
onClick={loadContent} |
|||
disabled={loading || saving} |
|||
className="gap-2 rounded-xl text-xs font-bold border-white/15 bg-white/[0.04] hover:bg-white/[0.08] text-slate-100 hover:text-white" |
|||
> |
|||
<Ic name="refresh" className={`size-4 text-primary ${loading ? 'animate-spin' : ''}`} /> |
|||
<span>{t('settings.refreshBtn')}</span> |
|||
</Button> |
|||
|
|||
<Button |
|||
type="button" |
|||
size="sm" |
|||
disabled={saving || loading} |
|||
onClick={handleSave} |
|||
className="gap-2 rounded-xl text-xs font-black bg-gradient-to-r from-[#d09460] to-[#b37745] hover:from-[#dd9e69] hover:to-[#be804c] text-white shadow-md shadow-[#d09460]/20 transition-all active:scale-[0.98]" |
|||
> |
|||
<Ic name="save" className={`size-4 ${saving ? 'animate-spin' : ''}`} /> |
|||
<span>{saving ? t('settings.saving') : t('settings.aboutUsSaveBtn')}</span> |
|||
</Button> |
|||
</div> |
|||
</div> |
|||
</CardContent> |
|||
</Card> |
|||
|
|||
{/* ۲. نوار انتخاب تب (بخشهای ساختاریافته وبسایت ۵ زبانه / متن HTML موبایل) */} |
|||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"> |
|||
<div className="flex items-center gap-1.5 p-1 rounded-xl bg-[#1e2129] border border-white/[0.08] w-fit"> |
|||
<button |
|||
type="button" |
|||
onClick={() => setMainTab('structured')} |
|||
className={`flex items-center gap-2 px-3.5 py-2 rounded-lg text-xs font-bold transition-all ${ |
|||
mainTab === 'structured' |
|||
? 'bg-primary text-white shadow-xs' |
|||
: 'text-slate-400 hover:text-white' |
|||
}`}
|
|||
> |
|||
<Ic name="layers" className="size-4" /> |
|||
<span>{t('settings.aboutUsTabStructured')}</span> |
|||
</button> |
|||
|
|||
<button |
|||
type="button" |
|||
onClick={() => setMainTab('html')} |
|||
className={`flex items-center gap-2 px-3.5 py-2 rounded-lg text-xs font-bold transition-all ${ |
|||
mainTab === 'html' |
|||
? 'bg-primary text-white shadow-xs' |
|||
: 'text-slate-400 hover:text-white' |
|||
}`}
|
|||
> |
|||
<Ic name="fileText" className="size-4" /> |
|||
<span>{t('settings.aboutUsTabHtml')}</span> |
|||
</button> |
|||
</div> |
|||
</div> |
|||
|
|||
{mainTab === 'structured' ? ( |
|||
<div className="space-y-6"> |
|||
{/* انتخابگر ۵ زبان */} |
|||
<Card className="border border-white/[0.08] bg-[#1e2129] shadow-md"> |
|||
<CardContent className="p-4 sm:p-5"> |
|||
<ServiceTranslation |
|||
activeLang={activeLang} |
|||
onLangChange={setActiveLang} |
|||
completedLangs={completedLangs} |
|||
/> |
|||
</CardContent> |
|||
</Card> |
|||
|
|||
{/* بخش ۱: سربرگ و معرفی اصلی (Hero Section) */} |
|||
<Card className="border border-white/[0.08] bg-[#1e2129] shadow-md"> |
|||
<CardContent className="p-4 sm:p-6 space-y-5"> |
|||
<div className="border-b border-white/[0.08] pb-4"> |
|||
<h3 className="text-sm sm:text-base font-bold text-white"> |
|||
{t('settings.aboutUsHeroSectionTitle')} |
|||
</h3> |
|||
<p className="text-xs text-slate-400 mt-1"> |
|||
{t('settings.aboutUsHeroSectionSubtitle')} |
|||
</p> |
|||
</div> |
|||
|
|||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4"> |
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.aboutUsBadgeLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={currentLangData.badge} |
|||
onChange={(e) => updateCurrentLangField('badge', e.target.value)} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs" |
|||
/> |
|||
</div> |
|||
|
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.aboutUsHeadingLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={currentLangData.heading} |
|||
onChange={(e) => updateCurrentLangField('heading', e.target.value)} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs font-bold" |
|||
/> |
|||
</div> |
|||
</div> |
|||
|
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.aboutUsSubheadingLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<Textarea |
|||
rows={3} |
|||
dir={activeFieldDir} |
|||
value={currentLangData.subheading} |
|||
onChange={(e) => updateCurrentLangField('subheading', e.target.value)} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs leading-relaxed" |
|||
/> |
|||
</div> |
|||
|
|||
{/* ۳ برچسب مناطق زیارتی */} |
|||
<div className="space-y-2.5"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.aboutUsRegionsLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<div className="grid grid-cols-1 md:grid-cols-3 gap-3"> |
|||
{[0, 1, 2].map((idx) => ( |
|||
<Input |
|||
key={idx} |
|||
dir={activeFieldDir} |
|||
value={currentLangData.regions[idx] || ''} |
|||
onChange={(e) => updateRegion(idx, e.target.value)} |
|||
placeholder={t('settings.aboutUsRegionPlaceholder')} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs" |
|||
/> |
|||
))} |
|||
</div> |
|||
</div> |
|||
|
|||
{/* تصویر شاخص Hero */} |
|||
<div className="pt-3 border-t border-white/[0.08] space-y-3"> |
|||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2"> |
|||
<div> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.aboutUsHeroImageLabel')} |
|||
</label> |
|||
<p className="text-[11px] text-slate-400 mt-0.5"> |
|||
{t('settings.aboutUsHeroImageHint')} |
|||
</p> |
|||
</div> |
|||
<div className="flex items-center gap-2"> |
|||
<label className="cursor-pointer inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-bold bg-white/[0.06] hover:bg-white/[0.12] border border-white/15 text-slate-200 transition-all"> |
|||
<Ic name="upload" className="size-3.5 text-primary" /> |
|||
<span>{t('settings.aboutUsUploadImageBtn')}</span> |
|||
<input |
|||
type="file" |
|||
accept="image/*" |
|||
onChange={handleHeroFileSelect} |
|||
className="hidden" |
|||
/> |
|||
</label> |
|||
{(heroImagePreview || heroImageUrl) && ( |
|||
<Button |
|||
type="button" |
|||
variant="ghost" |
|||
size="sm" |
|||
onClick={handleResetHeroImage} |
|||
className="h-8 px-2.5 text-xs rounded-xl text-rose-400 hover:text-rose-300 hover:bg-rose-500/10" |
|||
> |
|||
<Ic name="trash" className="size-3.5 me-1" /> |
|||
<span>{t('settings.aboutUsResetImageBtn')}</span> |
|||
</Button> |
|||
)} |
|||
</div> |
|||
</div> |
|||
|
|||
{heroImagePreview && ( |
|||
<div className="flex items-center gap-4 p-3 rounded-xl bg-[#14171f] border border-white/10 w-fit"> |
|||
<img |
|||
src={heroImagePreview} |
|||
alt="Hero Preview" |
|||
className="h-20 w-28 object-cover rounded-lg border border-white/10" |
|||
/> |
|||
<span className="text-xs font-mono text-slate-400 max-w-xs truncate"> |
|||
{heroImageFile ? heroImageFile.name : heroImageUrl} |
|||
</span> |
|||
</div> |
|||
)} |
|||
</div> |
|||
</CardContent> |
|||
</Card> |
|||
|
|||
{/* بخش ۲: آمار و پشتوانه اعتماد زائران (۴ کارت) */} |
|||
<Card className="border border-white/[0.08] bg-[#1e2129] shadow-md"> |
|||
<CardContent className="p-4 sm:p-6 space-y-5"> |
|||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 border-b border-white/[0.08] pb-4"> |
|||
<div> |
|||
<h3 className="text-sm sm:text-base font-bold text-white"> |
|||
{t('settings.aboutUsStatsSectionTitle')} |
|||
</h3> |
|||
<p className="text-xs text-slate-400 mt-1"> |
|||
{t('settings.aboutUsStatsSectionSubtitle')} |
|||
</p> |
|||
</div> |
|||
<div className="flex items-center gap-2.5"> |
|||
<span className="text-xs text-slate-300">{t('settings.aboutUsShowSection')}</span> |
|||
<Switch checked={showStats} onCheckedChange={setShowStats} /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4"> |
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.sectionTitleLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={currentLangData.stats_title} |
|||
onChange={(e) => updateCurrentLangField('stats_title', e.target.value)} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs font-bold" |
|||
/> |
|||
</div> |
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.sectionSubtitleLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={currentLangData.stats_subtitle} |
|||
onChange={(e) => updateCurrentLangField('stats_subtitle', e.target.value)} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs" |
|||
/> |
|||
</div> |
|||
</div> |
|||
|
|||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4"> |
|||
{currentLangData.stats.map((stat, idx) => ( |
|||
<div |
|||
key={stat.id || idx} |
|||
className="p-4 rounded-xl bg-[#14171f] border border-white/[0.08] space-y-3" |
|||
> |
|||
<div className="flex items-center justify-between"> |
|||
<Badge variant="outline" className="border-primary/30 bg-primary/10 text-primary text-xs font-bold"> |
|||
{t('settings.aboutUsStatCardTitle')} {idx + 1} |
|||
</Badge> |
|||
</div> |
|||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3"> |
|||
<div className="space-y-1.5"> |
|||
<label className="text-[11px] text-slate-400 block"> |
|||
{t('settings.aboutUsStatNumLabel')} |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={stat.num} |
|||
onChange={(e) => updateStat(idx, 'num', e.target.value)} |
|||
className="bg-[#1e2129] border-white/10 text-amber-400 font-bold rounded-xl text-xs" |
|||
/> |
|||
</div> |
|||
<div className="space-y-1.5"> |
|||
<label className="text-[11px] text-slate-400 block"> |
|||
{t('settings.aboutUsStatTitleLabel')} |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={stat.title} |
|||
onChange={(e) => updateStat(idx, 'title', e.target.value)} |
|||
className="bg-[#1e2129] border-white/10 text-slate-100 font-semibold rounded-xl text-xs" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div className="space-y-1.5"> |
|||
<label className="text-[11px] text-slate-400 block"> |
|||
{t('settings.aboutUsStatDescLabel')} |
|||
</label> |
|||
<Textarea |
|||
rows={2} |
|||
dir={activeFieldDir} |
|||
value={stat.desc} |
|||
onChange={(e) => updateStat(idx, 'desc', e.target.value)} |
|||
className="bg-[#1e2129] border-white/10 text-slate-200 rounded-xl text-xs leading-relaxed" |
|||
/> |
|||
</div> |
|||
</div> |
|||
))} |
|||
</div> |
|||
</CardContent> |
|||
</Card> |
|||
|
|||
{/* بخش ۳: ارکان اعتماد و تعهدات اجرایی (۳ کارت) */} |
|||
<Card className="border border-white/[0.08] bg-[#1e2129] shadow-md"> |
|||
<CardContent className="p-4 sm:p-6 space-y-5"> |
|||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 border-b border-white/[0.08] pb-4"> |
|||
<div> |
|||
<h3 className="text-sm sm:text-base font-bold text-white"> |
|||
{t('settings.aboutUsPillarsSectionTitle')} |
|||
</h3> |
|||
<p className="text-xs text-slate-400 mt-1"> |
|||
{t('settings.aboutUsPillarsSectionSubtitle')} |
|||
</p> |
|||
</div> |
|||
<div className="flex items-center gap-2.5"> |
|||
<span className="text-xs text-slate-300">{t('settings.aboutUsShowSection')}</span> |
|||
<Switch checked={showPillars} onCheckedChange={setShowPillars} /> |
|||
</div> |
|||
</div> |
|||
|
|||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4"> |
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.sectionTitleLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={currentLangData.pillars_title} |
|||
onChange={(e) => updateCurrentLangField('pillars_title', e.target.value)} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs font-bold" |
|||
/> |
|||
</div> |
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.sectionSubtitleLabel')} ({activeLang.toUpperCase()}) |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={currentLangData.pillars_subtitle} |
|||
onChange={(e) => updateCurrentLangField('pillars_subtitle', e.target.value)} |
|||
className="bg-[#14171f] border-white/10 text-slate-100 rounded-xl text-xs" |
|||
/> |
|||
</div> |
|||
</div> |
|||
|
|||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4"> |
|||
{currentLangData.pillars.map((pillar, idx) => ( |
|||
<div |
|||
key={pillar.id || idx} |
|||
className="p-4 rounded-xl bg-[#14171f] border border-white/[0.08] space-y-3" |
|||
> |
|||
<div className="flex items-center justify-between"> |
|||
<Badge variant="outline" className="border-primary/30 bg-primary/10 text-primary text-xs font-bold"> |
|||
{t('settings.aboutUsPillarCardTitle')} {idx + 1} |
|||
</Badge> |
|||
</div> |
|||
|
|||
<div className="space-y-1.5"> |
|||
<label className="text-[11px] text-slate-400 block"> |
|||
{t('settings.aboutUsPillarTitleLabel')} |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={pillar.title} |
|||
onChange={(e) => updatePillar(idx, 'title', e.target.value)} |
|||
className="bg-[#1e2129] border-white/10 text-slate-100 font-semibold rounded-xl text-xs" |
|||
/> |
|||
</div> |
|||
|
|||
<div className="space-y-1.5"> |
|||
<label className="text-[11px] text-slate-400 block"> |
|||
{t('settings.aboutUsPillarDescLabel')} |
|||
</label> |
|||
<Textarea |
|||
rows={3} |
|||
dir={activeFieldDir} |
|||
value={pillar.desc} |
|||
onChange={(e) => updatePillar(idx, 'desc', e.target.value)} |
|||
className="bg-[#1e2129] border-white/10 text-slate-200 rounded-xl text-xs leading-relaxed" |
|||
/> |
|||
</div> |
|||
|
|||
<div className="space-y-1.5"> |
|||
<label className="text-[11px] text-emerald-400 block"> |
|||
{t('settings.aboutUsPillarFooterLabel')} |
|||
</label> |
|||
<Input |
|||
dir={activeFieldDir} |
|||
value={pillar.footer} |
|||
onChange={(e) => updatePillar(idx, 'footer', e.target.value)} |
|||
className="bg-[#1e2129] border-emerald-500/20 text-emerald-300 rounded-xl text-xs" |
|||
/> |
|||
</div> |
|||
</div> |
|||
))} |
|||
</div> |
|||
</CardContent> |
|||
</Card> |
|||
</div> |
|||
) : ( |
|||
/* تب ۲: ویرایشگر و پیشنمایش HTML اپلیکیشن موبایل */ |
|||
<Card className="border border-white/[0.08] bg-[#1e2129] shadow-md"> |
|||
<CardContent className="p-4 sm:p-6 space-y-4"> |
|||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between border-b border-white/[0.08] pb-4"> |
|||
<div className="flex items-center gap-2 flex-wrap"> |
|||
<div className="flex items-center gap-1.5 p-1 rounded-xl bg-black/20 border border-white/[0.06] w-fit"> |
|||
<button |
|||
type="button" |
|||
onClick={() => setHtmlView('edit')} |
|||
className={`flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-bold transition-all ${ |
|||
htmlView === 'edit' |
|||
? 'bg-primary text-white shadow-xs' |
|||
: 'text-slate-400 hover:text-white' |
|||
}`}
|
|||
> |
|||
<Ic name="pencil" className="size-3.5" /> |
|||
<span>{t('settings.aboutUsEdit')}</span> |
|||
</button> |
|||
|
|||
<button |
|||
type="button" |
|||
onClick={() => setHtmlView('preview')} |
|||
className={`flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-bold transition-all ${ |
|||
htmlView === 'preview' |
|||
? 'bg-primary text-white shadow-xs' |
|||
: 'text-slate-400 hover:text-white' |
|||
}`}
|
|||
> |
|||
<Ic name="eye" className="size-3.5" /> |
|||
<span>{t('settings.aboutUsPreview')}</span> |
|||
</button> |
|||
</div> |
|||
|
|||
<Button |
|||
type="button" |
|||
variant="outline" |
|||
size="sm" |
|||
onClick={handleAutoSyncHtml} |
|||
className="h-8 px-3 text-xs rounded-xl border-primary/30 bg-primary/10 hover:bg-primary/20 text-primary font-bold" |
|||
> |
|||
<Ic name="sparkles" className="size-3.5 me-1.5" /> |
|||
<span>{t('settings.aboutUsAutoSyncHtmlBtn')}</span> |
|||
</Button> |
|||
</div> |
|||
|
|||
{htmlView === 'edit' && ( |
|||
<div className="flex items-center gap-1.5 flex-wrap"> |
|||
<Button |
|||
type="button" |
|||
variant="ghost" |
|||
size="sm" |
|||
onClick={() => insertSnippet('<h2>عنوان بخش جدید</h2>\n<p>متن توضیحات...</p>')} |
|||
className="h-7 px-2 text-[11px] rounded-lg border border-white/10 bg-white/[0.02] hover:bg-white/[0.08] text-slate-300" |
|||
> |
|||
{t('settings.aboutUsInsertHeading2')} |
|||
</Button> |
|||
<Button |
|||
type="button" |
|||
variant="ghost" |
|||
size="sm" |
|||
onClick={() => insertSnippet('<h3>زیرعنوان</h3>\n<p>توضیحات تکمیلی...</p>')} |
|||
className="h-7 px-2 text-[11px] rounded-lg border border-white/10 bg-white/[0.02] hover:bg-white/[0.08] text-slate-300" |
|||
> |
|||
{t('settings.aboutUsInsertHeading3')} |
|||
</Button> |
|||
<Button |
|||
type="button" |
|||
variant="ghost" |
|||
size="sm" |
|||
onClick={() => insertSnippet('<p>پاراگراف جدید برای توضیحات...</p>')} |
|||
className="h-7 px-2 text-[11px] rounded-lg border border-white/10 bg-white/[0.02] hover:bg-white/[0.08] text-slate-300" |
|||
> |
|||
{t('settings.aboutUsInsertParagraph')} |
|||
</Button> |
|||
<Button |
|||
type="button" |
|||
variant="ghost" |
|||
size="sm" |
|||
onClick={() => insertSnippet('<ul>\n <li>مورد اول</li>\n <li>مورد دوم</li>\n</ul>')} |
|||
className="h-7 px-2 text-[11px] rounded-lg border border-white/10 bg-white/[0.02] hover:bg-white/[0.08] text-slate-300" |
|||
> |
|||
{t('settings.aboutUsInsertList')} |
|||
</Button> |
|||
<Button |
|||
type="button" |
|||
variant="ghost" |
|||
size="sm" |
|||
onClick={() => |
|||
insertSnippet( |
|||
'<div class="callout-box bg-primary/10 border-r-4 border-primary p-4 rounded-xl my-4 text-primary">\n <p>نکته مهم و برجسته...</p>\n</div>' |
|||
) |
|||
} |
|||
className="h-7 px-2 text-[11px] rounded-lg border border-white/10 bg-white/[0.02] hover:bg-white/[0.08] text-slate-300" |
|||
> |
|||
{t('settings.aboutUsInsertCallout')} |
|||
</Button> |
|||
</div> |
|||
)} |
|||
</div> |
|||
|
|||
{htmlView === 'edit' ? ( |
|||
<div className="space-y-2"> |
|||
<label className="text-xs font-semibold text-slate-300 block"> |
|||
{t('settings.aboutUsEditorLabel')} |
|||
</label> |
|||
<Textarea |
|||
rows={16} |
|||
value={content} |
|||
onChange={(e) => setContent(e.target.value)} |
|||
placeholder={t('settings.aboutUsEditorPlaceholder')} |
|||
dir={dir} |
|||
className="w-full font-mono text-xs leading-relaxed bg-[#14171f] border-white/10 focus:border-primary text-slate-100 placeholder:text-slate-500 rounded-xl resize-y min-h-[360px]" |
|||
/> |
|||
</div> |
|||
) : ( |
|||
<div className="space-y-3"> |
|||
<div className="rounded-xl border border-white/10 bg-[#14171f] p-6 min-h-[360px]"> |
|||
{content.trim() ? ( |
|||
<div |
|||
className="prose dark:prose-invert max-w-none text-slate-200 text-sm leading-relaxed" |
|||
dangerouslySetInnerHTML={{ __html: content }} |
|||
/> |
|||
) : ( |
|||
<div className="flex flex-col items-center justify-center py-20 text-center text-slate-400 space-y-2"> |
|||
<Ic name="info" className="size-8 opacity-40" /> |
|||
<p className="text-xs">{t('settings.aboutUsEmptyPreview')}</p> |
|||
</div> |
|||
)} |
|||
</div> |
|||
</div> |
|||
)} |
|||
</CardContent> |
|||
</Card> |
|||
)} |
|||
|
|||
{/* ۳. کارت راهنمای اتصال و سینک با کلاینتها */} |
|||
<Card className="border border-white/[0.08] bg-[#1e2129]/60"> |
|||
<CardContent className="p-4 sm:p-5 flex items-center gap-3"> |
|||
<div className="flex size-9 shrink-0 items-center justify-center rounded-xl bg-amber-500/10 text-amber-400 border border-amber-500/20"> |
|||
<Ic name="sparkles" className="size-4.5" /> |
|||
</div> |
|||
<p className="text-xs text-slate-300 leading-relaxed"> |
|||
{t('settings.aboutUsInfoNotice')} |
|||
</p> |
|||
</CardContent> |
|||
</Card> |
|||
</div> |
|||
) |
|||
} |
|||
1615
src/features/tours/components/CreateTourDialog.tsx
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue