feat(admin): support dual URL link and Media Manager picker for multimedia attachments [TASK-22.1]
This commit is contained in:
1 parent
8505081b2e
commit
c3ca9ccaa2
1 file changed
+64
-27
@@ -97,6 +97,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 [editingProduct, setEditingProduct] = useState<Product | null>(null);
|
||||
const [deleteTargetId, setDeleteTargetId] = useState<string | null>(null);
|
||||
const [activeTab, setActiveTab] = useState('general');
|
||||
@@ -900,36 +901,72 @@ export default function Products() {
|
||||
<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>
|
||||
<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"
|
||||
/>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-bold text-gray-700 block">لینک یا کدفریم ویدیو (Video URL)</label>
|
||||
<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"
|
||||
/>
|
||||
<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>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-bold text-gray-700 block">فایل کاتالوگ / PDF علمی (PDF URL)</label>
|
||||
<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"
|
||||
/>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -955,10 +992,10 @@ export default function Products() {
|
||||
isOpen={isMediaSelectorOpen}
|
||||
onClose={() => setIsMediaSelectorOpen(false)}
|
||||
onSelect={(url) => {
|
||||
setFormData({ ...formData, imageUrl: url });
|
||||
setMediaImageError(false);
|
||||
setFormData({ ...formData, [mediaTargetField]: url });
|
||||
if (mediaTargetField === 'imageUrl') setMediaImageError(false);
|
||||
}}
|
||||
selectedUrl={formData.imageUrl.startsWith('http') ? formData.imageUrl : formData.imageUrl ? `${BASE_DOMAIN}${formData.imageUrl}` : undefined}
|
||||
selectedUrl={formData[mediaTargetField]?.startsWith('http') ? formData[mediaTargetField] : formData[mediaTargetField] ? `${BASE_DOMAIN}${formData[mediaTargetField]}` : undefined}
|
||||
/>
|
||||
|
||||
<ConfirmModal
|
||||
|
||||
Reference in new issue
Block a user