diff --git a/assets/images/icons8-document-50.png b/assets/images/icons8-document-50.png new file mode 100644 index 0000000..c3283ee Binary files /dev/null and b/assets/images/icons8-document-50.png differ diff --git a/assets/images/icons8-image-50.png b/assets/images/icons8-image-50.png new file mode 100644 index 0000000..74820b4 Binary files /dev/null and b/assets/images/icons8-image-50.png differ diff --git a/assets/images/icons8-video-camera-50.png b/assets/images/icons8-video-camera-50.png new file mode 100644 index 0000000..cbaf7ae Binary files /dev/null and b/assets/images/icons8-video-camera-50.png differ diff --git a/assets/images/icons8-voice-id-50.png b/assets/images/icons8-voice-id-50.png new file mode 100644 index 0000000..610335e Binary files /dev/null and b/assets/images/icons8-voice-id-50.png differ diff --git a/components/Requests/RequestCard.tsx b/components/Requests/RequestCard.tsx index f17ce69..365562d 100644 --- a/components/Requests/RequestCard.tsx +++ b/components/Requests/RequestCard.tsx @@ -72,8 +72,7 @@ const RequestCard: React.FC = ({ item, isSelfRequest }) => { }; return ( - //
- <> + <>
= ({ item, isSelfRequest }) => { = ({ return ( <> - + e.stopPropagation()}> - + e.stopPropagation()}> {isLoading && (
diff --git a/components/Requests/RequestProcess.tsx b/components/Requests/RequestProcess.tsx index 9046537..c6a1ff9 100644 --- a/components/Requests/RequestProcess.tsx +++ b/components/Requests/RequestProcess.tsx @@ -17,6 +17,12 @@ import { useQuery } from "@tanstack/react-query"; import { getReportHistory } from "@/utils/CitizenReport"; import { convertDate, convertFullTime, convertTime } from "@/lib/utils"; import { log } from "console"; +import Image from "next/image"; +import imgdocument from "@/assets/images/icons8-document-50.png"; +import imgimage from "@/assets/images/icons8-image-50.png"; +import imgvideo from "@/assets/images/icons8-video-camera-50.png"; +import imgvoice from "@/assets/images/icons8-voice-id-50.png"; +import axios from "axios"; // Define types for props interface RequestProcessProps { @@ -24,7 +30,9 @@ interface RequestProcessProps { } interface Media { + url: string; url3: string; + mediaType: number; } interface Reason { @@ -49,7 +57,6 @@ const RequestProcess: React.FC = ({ reportId }) => { // Component state const [history, setHistory] = useState([]); const [step, setStep] = useState(); - // const [step, setStep] = useState(); const { data, isLoading, isError, isSuccess, refetch } = useQuery({ queryKey: ["History", reportId], @@ -63,18 +70,33 @@ const RequestProcess: React.FC = ({ reportId }) => { if (data) { setHistory(data?.data); setStep(data?.data?.length); - - // for (let i = 1; i <= data.data.length; i++) { - // // setStep.push(i); - // newArr.push(i); - // } - console.log("History state updated:", data); - console.log("🚀 ~ useEffect ~ data?.data?.length:", data?.data?.length); } - - console.log("🚀 ~ useEffect ~ setStep:", step); }, [data]); + const handleDownload = async (url: string) => { + try { + const response = await axios.get(url, { + responseType: "blob", // دریافت فایل به صورت blob + }); + + const filename = getFilenameFromUrl(url); + const blob = new Blob([response.data], { type: response.data.type }); + const link = document.createElement("a"); + link.href = URL.createObjectURL(blob); + link.download = filename; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } catch (error) { + console.error("Download failed:", error); + } + }; + + const getFilenameFromUrl = (url: string) => { + return url.split("/").pop() || "downloaded-file"; + }; + return (
@@ -84,17 +106,17 @@ const RequestProcess: React.FC = ({ reportId }) => { مشاهده روند بررسی
- + {history.map((history, index, array) => ( <>
    -
  1. - +
  2. + {array.length - index}
    @@ -109,17 +131,77 @@ const RequestProcess: React.FC = ({ reportId }) => { > {history?.reason?.title}
    -
    - -
    + {history?.attachments?.length > 0 && ( +
    +
    + پیوست ها +
    +
    + {history?.attachments?.map((attachment, index) => ( +
    handleDownload(attachment.url)} + key={index} + > + {attachment.mediaType == 0 && ( + picture + )} + + {attachment.mediaType == 1 && ( + picture + )} + + {attachment.mediaType == 2 && ( + picture + )} + + {attachment.mediaType == 3 && ( + picture + )} +
    + ))} +
    +
    + )}
- - {convertTime(history.dateTime)} - - - {convertDate(history.dateTime)} - +
+ + {convertTime(history.dateTime)} + + + {convertDate(history.dateTime)} + +
))} diff --git a/components/Requests/RequestViolations.tsx b/components/Requests/RequestViolations.tsx index 9fe31d2..02618a1 100644 --- a/components/Requests/RequestViolations.tsx +++ b/components/Requests/RequestViolations.tsx @@ -148,6 +148,7 @@ const RequestViolations: React.FC = ({ // 2. Define a submit handler. function onSubmit(values: z.infer) { + // e.stopPropagation(); console.log(values); setViolationType(values.violationTypeId); setViolationDescription(values.description); @@ -163,13 +164,16 @@ const RequestViolations: React.FC = ({ }, }); } + return ( <> {/* */} - + e.stopPropagation()} + />