feat: add dedicated podcast modal player, integrate video modal player in product page, and add media metadata management in admin
Deploy Canina / deploy (push) Successful in 1m50s

This commit is contained in:
parsa aghaei committed 2026-08-18 11:34:04 +03:30
1 parent 27a1517464
commit f9dad098ef
8 files changed
+954 -138

No files matched your search

+288 -71
View File
@@ -41,10 +41,18 @@ export interface Product {
keywords?: string;
canonicalUrl?: string;
slug?: string;
images?: string[];
podcastUrl?: string;
podcastTitle?: string;
podcastDescription?: string;
podcastCover?: string;
videoUrl?: string;
videoTitle?: string;
videoDescription?: string;
videoCover?: string;
pdfUrl?: string;
pdfTitle?: string;
pdfDescription?: string;
pdfCover?: string;
symptoms?: Array<{ symptom: string } | string>;
isPreorder?: boolean;
preorderDeposit?: string | number;
@@ -136,7 +144,7 @@ export default function Products() {
// Modal State
const [isModalOpen, setIsModalOpen] = useState(false);
const [isMediaSelectorOpen, setIsMediaSelectorOpen] = useState(false);
const [mediaTargetField, setMediaTargetField] = useState<'imageUrl' | 'podcastUrl' | 'videoUrl' | 'pdfUrl'>('imageUrl');
const [mediaTargetField, setMediaTargetField] = useState<'imageUrl' | 'podcastUrl' | 'podcastCover' | 'videoUrl' | 'videoCover' | 'pdfUrl' | 'pdfCover' | 'gallery'>('imageUrl');
const [editingProduct, setEditingProduct] = useState<Product | null>(null);
const [deleteTargetId, setDeleteTargetId] = useState<string | null>(null);
const [activeTab, setActiveTab] = useState('general');
@@ -167,8 +175,17 @@ export default function Products() {
slug: '',
images: [] as string[],
podcastUrl: '',
podcastTitle: '',
podcastDescription: '',
podcastCover: '',
videoUrl: '',
videoTitle: '',
videoDescription: '',
videoCover: '',
pdfUrl: '',
pdfTitle: '',
pdfDescription: '',
pdfCover: '',
symptoms: [] as string[],
isPreorder: false,
preorderDeposit: '' as number | string
@@ -254,11 +271,19 @@ export default function Products() {
metaDescription: product.metaDescription || '',
keywords: product.keywords || '',
canonicalUrl: product.canonicalUrl || '',
slug: product.slug || '',
images: Array.isArray(product.images) ? product.images : [],
podcastUrl: product.podcastUrl || '',
podcastTitle: product.podcastTitle || '',
podcastDescription: product.podcastDescription || '',
podcastCover: product.podcastCover || '',
videoUrl: product.videoUrl || '',
videoTitle: product.videoTitle || '',
videoDescription: product.videoDescription || '',
videoCover: product.videoCover || '',
pdfUrl: product.pdfUrl || '',
pdfTitle: product.pdfTitle || '',
pdfDescription: product.pdfDescription || '',
pdfCover: product.pdfCover || '',
symptoms: product.symptoms ? product.symptoms.map((s: { symptom: string } | string) => typeof s === 'string' ? s : s.symptom) : [],
isPreorder: Boolean(product.isPreorder),
preorderDeposit: product.preorderDeposit || ''
@@ -270,7 +295,10 @@ export default function Products() {
buyPrice: '', priceValue: 0, wholesalePrice: '', priceValueMarginPercent: '', wholesaleMarginPercent: '',
priceDisplay: '', unit: '', packageSize: 0, dosageLogic: '', suitableFor: 'سگ و گربه',
imageUrl: '', metaTitle: '', metaDescription: '', keywords: '', canonicalUrl: '', slug: '',
images: [], podcastUrl: '', videoUrl: '', pdfUrl: '',
images: [],
podcastUrl: '', podcastTitle: '', podcastDescription: '', podcastCover: '',
videoUrl: '', videoTitle: '', videoDescription: '', videoCover: '',
pdfUrl: '', pdfTitle: '', pdfDescription: '', pdfCover: '',
symptoms: [], isPreorder: false, preorderDeposit: ''
});
}
@@ -1277,79 +1305,268 @@ export default function Products() {
)}
</div>
{/* Multimedia Attachments (TASK-2.3 & TASK-2.4) */}
<div className="bg-white p-5 rounded-2xl border border-gray-200 shadow-sm space-y-4">
<h4 className="font-bold text-gray-800 text-sm border-b pb-2">پیوست‌های مالتی‌مدیا و مستندات علمی</h4>
{/* Multimedia Attachments */}
<div className="bg-white p-5 rounded-2xl border border-gray-200 shadow-sm space-y-6">
<div>
<h4 className="font-bold text-gray-800 text-sm border-b pb-2">پیوست‌های مالتی‌مدیا و مستندات علمی تخصصی</h4>
<p className="text-[11px] text-gray-500 mt-1">مدیریت فایل‌های صوتی، تصویری و کاتالوگ‌های اختصاصی این محصول همراه با عنوان، توضیحات و کاور اختصاصی.</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="space-y-1.5">
<label className="text-xs font-bold text-gray-700 block">لینک فصلی پادکست (Podcast URL)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.podcastUrl}
onChange={(e) => setFormData({ ...formData, podcastUrl: e.target.value })}
placeholder="https://... MP3 or Soundcloud"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('podcastUrl');
setIsMediaSelectorOpen(true);
}}
className="px-2 py-1 bg-purple-100 text-purple-700 hover:bg-purple-200 rounded-lg text-xs font-bold whitespace-nowrap"
>
انتخاب
</button>
{/* Section 1: Podcast Management Card */}
<div className="bg-purple-50/40 border border-purple-100 rounded-2xl p-4 space-y-3">
<div className="flex items-center justify-between border-b border-purple-100/80 pb-2">
<span className="text-xs font-black text-purple-900 flex items-center gap-1.5">
🎧 تنظیمات پادکست و بررسی صوتی بالینی
</span>
{formData.podcastUrl && (
<span className="text-[10px] bg-purple-200 text-purple-800 font-bold px-2 py-0.5 rounded-full">
فایل صوتی متصل است
</span>
)}
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">لینک یا فایل پادکست (Audio/MP3 URL)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.podcastUrl}
onChange={(e) => setFormData({ ...formData, podcastUrl: e.target.value })}
placeholder="https://... /uploads/audio.mp3"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono bg-white"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('podcastUrl');
setIsMediaSelectorOpen(true);
}}
className="px-2.5 py-1 bg-purple-600 text-white hover:bg-purple-700 rounded-lg text-xs font-bold whitespace-nowrap cursor-pointer"
>
انتخاب فایل
</button>
</div>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">تصویر کاور اختصاصی پادکست (اختیاری)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.podcastCover}
onChange={(e) => setFormData({ ...formData, podcastCover: e.target.value })}
placeholder="در صورت خالی بودن، تصویر اصلی محصول استفاده می‌شود"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono bg-white"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('podcastCover');
setIsMediaSelectorOpen(true);
}}
className="px-2.5 py-1 bg-purple-100 text-purple-700 hover:bg-purple-200 rounded-lg text-xs font-bold whitespace-nowrap cursor-pointer"
>
انتخاب کاور
</button>
</div>
</div>
</div>
<div className="space-y-1.5">
<label className="text-xs font-bold text-gray-700 block">لینک یا کدفریم ویدیو (Video URL)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.videoUrl}
onChange={(e) => setFormData({ ...formData, videoUrl: e.target.value })}
placeholder="https://... MP4 or Aparat/YouTube iframe"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('videoUrl');
setIsMediaSelectorOpen(true);
}}
className="px-2 py-1 bg-purple-100 text-purple-700 hover:bg-purple-200 rounded-lg text-xs font-bold whitespace-nowrap"
>
انتخاب
</button>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">عنوان پادکست</label>
<input
type="text"
value={formData.podcastTitle}
onChange={(e) => setFormData({ ...formData, podcastTitle: e.target.value })}
placeholder="مثلاً: بررسی بالینی اثر مکمل بر سلامت مفاصل سگ‌ها"
className="w-full px-3 py-2 border rounded-xl text-xs bg-white font-medium"
/>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">توضیحات کوتاه پادکست</label>
<textarea
rows={2}
value={formData.podcastDescription}
onChange={(e) => setFormData({ ...formData, podcastDescription: e.target.value })}
placeholder="توضیحات و نکات مطرح شده در پادکست تخصصی..."
className="w-full px-3 py-2 border rounded-xl text-xs bg-white font-medium resize-none"
/>
</div>
</div>
{/* Section 2: Video Management Card */}
<div className="bg-blue-50/40 border border-blue-100 rounded-2xl p-4 space-y-3">
<div className="flex items-center justify-between border-b border-blue-100/80 pb-2">
<span className="text-xs font-black text-blue-900 flex items-center gap-1.5">
🎬 تنظیمات ویدیو و راهنمای مصرف
</span>
{formData.videoUrl && (
<span className="text-[10px] bg-blue-200 text-blue-800 font-bold px-2 py-0.5 rounded-full">
ویدیو متصل است
</span>
)}
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">لینک مستقیم یا کدفریم ویدیو (Video URL / Embed)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.videoUrl}
onChange={(e) => setFormData({ ...formData, videoUrl: e.target.value })}
placeholder="https://... MP4 or Aparat iframe"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono bg-white"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('videoUrl');
setIsMediaSelectorOpen(true);
}}
className="px-2.5 py-1 bg-blue-600 text-white hover:bg-blue-700 rounded-lg text-xs font-bold whitespace-nowrap cursor-pointer"
>
انتخاب فایل
</button>
</div>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">تصویر پوستر / کاور ویدیو (اختیاری)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.videoCover}
onChange={(e) => setFormData({ ...formData, videoCover: e.target.value })}
placeholder="در صورت خالی بودن، تصویر محصول استفاده می‌شود"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono bg-white"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('videoCover');
setIsMediaSelectorOpen(true);
}}
className="px-2.5 py-1 bg-blue-100 text-blue-700 hover:bg-blue-200 rounded-lg text-xs font-bold whitespace-nowrap cursor-pointer"
>
انتخاب کاور
</button>
</div>
</div>
</div>
<div className="space-y-1.5">
<label className="text-xs font-bold text-gray-700 block">فایل کاتالوگ / PDF علمی (PDF URL)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.pdfUrl}
onChange={(e) => setFormData({ ...formData, pdfUrl: e.target.value })}
placeholder="https://... PDF catalog"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('pdfUrl');
setIsMediaSelectorOpen(true);
}}
className="px-2 py-1 bg-purple-100 text-purple-700 hover:bg-purple-200 rounded-lg text-xs font-bold whitespace-nowrap"
>
انتخاب
</button>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">عنوان ویدیو</label>
<input
type="text"
value={formData.videoTitle}
onChange={(e) => setFormData({ ...formData, videoTitle: e.target.value })}
placeholder="مثلاً: راهنمای نحوه خوراندن و دوز مصرف مکمل"
className="w-full px-3 py-2 border rounded-xl text-xs bg-white font-medium"
/>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">توضیحات کوتاه ویدیو</label>
<textarea
rows={2}
value={formData.videoDescription}
onChange={(e) => setFormData({ ...formData, videoDescription: e.target.value })}
placeholder="توضیحات ویدیوی آموزشی و نکات کلیدی..."
className="w-full px-3 py-2 border rounded-xl text-xs bg-white font-medium resize-none"
/>
</div>
</div>
{/* Section 3: PDF / Document Management Card */}
<div className="bg-amber-50/40 border border-amber-100 rounded-2xl p-4 space-y-3">
<div className="flex items-center justify-between border-b border-amber-100/80 pb-2">
<span className="text-xs font-black text-amber-900 flex items-center gap-1.5">
📄 تنظیمات کاتالوگ و مستندات PDF
</span>
{formData.pdfUrl && (
<span className="text-[10px] bg-amber-200 text-amber-800 font-bold px-2 py-0.5 rounded-full">
فایل PDF متصل است
</span>
)}
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">لینک یا فایل کاتالوگ (PDF URL)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.pdfUrl}
onChange={(e) => setFormData({ ...formData, pdfUrl: e.target.value })}
placeholder="https://... /uploads/catalog.pdf"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono bg-white"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('pdfUrl');
setIsMediaSelectorOpen(true);
}}
className="px-2.5 py-1 bg-amber-600 text-white hover:bg-amber-700 rounded-lg text-xs font-bold whitespace-nowrap cursor-pointer"
>
انتخاب فایل
</button>
</div>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">تصویر پیش‌نمایش کاتالوگ (اختیاری)</label>
<div className="flex gap-1.5">
<input
type="text"
value={formData.pdfCover}
onChange={(e) => setFormData({ ...formData, pdfCover: e.target.value })}
placeholder="در صورت خالی بودن، تصویر محصول استفاده می‌شود"
className="w-full px-3 py-2 border rounded-xl text-xs font-mono bg-white"
dir="ltr"
/>
<button
type="button"
onClick={() => {
setMediaTargetField('pdfCover');
setIsMediaSelectorOpen(true);
}}
className="px-2.5 py-1 bg-amber-100 text-amber-800 hover:bg-amber-200 rounded-lg text-xs font-bold whitespace-nowrap cursor-pointer"
>
انتخاب کاور
</button>
</div>
</div>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">عنوان فایل PDF</label>
<input
type="text"
value={formData.pdfTitle}
onChange={(e) => setFormData({ ...formData, pdfTitle: e.target.value })}
placeholder="مثلاً: کاتالوگ جامع مشخصات فنی و مطالعات بالینی"
className="w-full px-3 py-2 border rounded-xl text-xs bg-white font-medium"
/>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-gray-700 block">توضیحات فایل PDF</label>
<textarea
rows={2}
value={formData.pdfDescription}
onChange={(e) => setFormData({ ...formData, pdfDescription: e.target.value })}
placeholder="توضیحات و محتویات کاتالوگ و بروشور رسمی..."
className="w-full px-3 py-2 border rounded-xl text-xs bg-white font-medium resize-none"
/>
</div>
</div>
</div>