fix: show missing tutorial file download, support more video formats

- Render the download button for a tutorial's uploaded file field
  (it was fetched from the API but never displayed).
- Recognize mov/avi/wmv as video (the backend already accepts them as
  uploads) and add a download fallback for any media type the browser
  can't play inline instead of a dead "unknown file type" message.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMLvfLviDB12t4U9UijE4k
This commit is contained in:
2026-09-04 18:02:08 +03:30
parent 8b6c0b07de
commit 1ea325ad47

View File

@@ -13,7 +13,7 @@ const getMediaType = (url: string) => {
if (["jpg", "jpeg", "png", "gif"].includes(extension)) {
return "image";
}
if (["mp4", "webm", "ogg"].includes(extension)) {
if (["mp4", "webm", "ogg", "mov", "avi", "wmv"].includes(extension)) {
return "video";
}
}
@@ -117,6 +117,7 @@ const Learn = ({ activeTutorial }: LearnProps) => {
id: string;
title: string;
medias: string[];
file: string | null;
url_file: string;
}) => (
<div
@@ -141,18 +142,36 @@ const Learn = ({ activeTutorial }: LearnProps) => {
className="w-full h-full object-cover rounded-lg"
/>
) : mediaType === "video" ? (
<div className="w-full h-full flex flex-col gap-2">
<video
src={media}
controls
className="w-full h-full object-cover rounded-lg"
/>
<Button
extra="!py-1 self-center"
onClick={() => saveAs(media)}
>
دانلود ویدیو
</Button>
</div>
) : (
<p>نوع فایل ناشناخته است</p>
<div className="w-full h-full flex flex-col gap-2 justify-center items-center">
<p>نوع فایل قابل نمایش نیست</p>
<Button extra="!py-1" onClick={() => saveAs(media)}>
دانلود فایل
</Button>
</div>
)}
</div>
);
})}
</div>
{i.file && (
<Button extra="!mb-4" onClick={() => saveAs(i.file as string)}>
دانلود فایل آموزش
</Button>
)}
{i.url_file && (
<>
<Button extra="!mb-4" onClick={() => saveAs(i.url_file)}>