(feat) add description field web services in learn components

This commit is contained in:
alij
2024-08-29 00:20:38 +03:30
parent b0c9276e52
commit b61330cf98

View File

@@ -5,6 +5,7 @@ import Alert from "../../../../components/alert/Alert";
import { MdErrorOutline } from "react-icons/md"; import { MdErrorOutline } from "react-icons/md";
import Button from "../../../../components/button"; import Button from "../../../../components/button";
import { saveAs } from "file-saver"; import { saveAs } from "file-saver";
import { Fragment } from "react/jsx-runtime";
const getMediaType = (url: string) => { const getMediaType = (url: string) => {
const extension = url.split(".").pop()?.toLowerCase(); const extension = url.split(".").pop()?.toLowerCase();
@@ -73,16 +74,38 @@ const Learn = ({ activeTutorial }: LearnProps) => {
data?.data?.result?.files.length > 0 && ( data?.data?.result?.files.length > 0 && (
<div className="w-full h-full p-3 mb-3 flex flex-col justify-center items-center gap-2 bg-gray-900 rounded-md shadow-xl"> <div className="w-full h-full p-3 mb-3 flex flex-col justify-center items-center gap-2 bg-gray-900 rounded-md shadow-xl">
{data.data.result.files.map( {data.data.result.files.map(
(file: { id: number; title: string; file: string }) => ( (file: {
<div id: number;
className="w-full h-full flex justify-between gap-4 items-center" title: string;
key={file.id} file: string;
> description: string;
}) => (
<Fragment key={file.id}>
{file?.description ? (
<div className="w-full h-full flex flex-col gap-1 justify-center items-center p-3 border-2 border-secondTheme rounded-md">
<div className="w-full h-full flex justify-between gap-4 items-center">
<p className="text-xs md:text-sm">{file.title}</p> <p className="text-xs md:text-sm">{file.title}</p>
<Button extra="!py-1" onClick={() => saveAs(file.file)}> <Button
extra="!py-1"
onClick={() => saveAs(file.file)}
>
دانلود دانلود
</Button> </Button>
</div> </div>
<p className="w-full h-full text-xs md:text-sm text-gray-300"> <span className="w-auto h-auto px-1 bg-secondTheme text-gray-800 rounded-md">توضیحات</span> : {file?.description}</p>
</div>
) : (
<div className="w-full h-full flex justify-between gap-4 items-center">
<p className="text-xs md:text-sm">{file.title}</p>
<Button
extra="!py-1"
onClick={() => saveAs(file.file)}
>
دانلود
</Button>
</div>
)}
</Fragment>
) )
)} )}
</div> </div>