Complate RequestProcess Componnent
parent
aa78a28b5d
commit
541b77630e
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
|
|
@ -72,7 +72,6 @@ const RequestCard: React.FC<RequestCardProps> = ({ item, isSelfRequest }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// <div className="overflow-x-hidden overflow-y-scroll pl-5 scrollbar-thin scrollbar-thumb-yellow scrollbar-track-white">
|
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ const RequestComments: React.FC<RequestCommentsProps> = ({
|
||||||
<DrawerTrigger onClick={(e) => e.stopPropagation()}>
|
<DrawerTrigger onClick={(e) => e.stopPropagation()}>
|
||||||
<FaRegComment className="mx-1 cursor-pointer" />
|
<FaRegComment className="mx-1 cursor-pointer" />
|
||||||
</DrawerTrigger>
|
</DrawerTrigger>
|
||||||
<DrawerContent className=" px-64">
|
<DrawerContent className=" px-64" onClick={(e) => e.stopPropagation()}>
|
||||||
<DrawerHeader className="">
|
<DrawerHeader className="">
|
||||||
{isLoading && (
|
{isLoading && (
|
||||||
<div className="flex justify-center items-center text-center w-full h-full">
|
<div className="flex justify-center items-center text-center w-full h-full">
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,12 @@ import { useQuery } from "@tanstack/react-query";
|
||||||
import { getReportHistory } from "@/utils/CitizenReport";
|
import { getReportHistory } from "@/utils/CitizenReport";
|
||||||
import { convertDate, convertFullTime, convertTime } from "@/lib/utils";
|
import { convertDate, convertFullTime, convertTime } from "@/lib/utils";
|
||||||
import { log } from "console";
|
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
|
// Define types for props
|
||||||
interface RequestProcessProps {
|
interface RequestProcessProps {
|
||||||
|
|
@ -24,7 +30,9 @@ interface RequestProcessProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Media {
|
interface Media {
|
||||||
|
url: string;
|
||||||
url3: string;
|
url3: string;
|
||||||
|
mediaType: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Reason {
|
interface Reason {
|
||||||
|
|
@ -49,7 +57,6 @@ const RequestProcess: React.FC<RequestProcessProps> = ({ reportId }) => {
|
||||||
// Component state
|
// Component state
|
||||||
const [history, setHistory] = useState<History[]>([]);
|
const [history, setHistory] = useState<History[]>([]);
|
||||||
const [step, setStep] = useState<number>();
|
const [step, setStep] = useState<number>();
|
||||||
// const [step, setStep] = useState();
|
|
||||||
|
|
||||||
const { data, isLoading, isError, isSuccess, refetch } = useQuery({
|
const { data, isLoading, isError, isSuccess, refetch } = useQuery({
|
||||||
queryKey: ["History", reportId],
|
queryKey: ["History", reportId],
|
||||||
|
|
@ -63,18 +70,33 @@ const RequestProcess: React.FC<RequestProcessProps> = ({ reportId }) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
setHistory(data?.data);
|
setHistory(data?.data);
|
||||||
setStep(data?.data?.length);
|
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]);
|
}, [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 (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
<Drawer direction="right">
|
<Drawer direction="right">
|
||||||
|
|
@ -84,17 +106,17 @@ const RequestProcess: React.FC<RequestProcessProps> = ({ reportId }) => {
|
||||||
<span>مشاهده روند بررسی</span>
|
<span>مشاهده روند بررسی</span>
|
||||||
</div>
|
</div>
|
||||||
</DrawerTrigger>
|
</DrawerTrigger>
|
||||||
<DrawerContent className=" px-20 w-1/2 h-screen z-[1000] overflow-y-auto scrollbar-thin scrollbar-thumb-yellow scrollbar-track-white">
|
<DrawerContent className=" px-20 w-1/2 h-screen z-[1000] overflow-y-auto scrollbar-thin scrollbar-thumb-blue2 scrollbar-track-white">
|
||||||
<DrawerHeader className="mb-4"></DrawerHeader>
|
<DrawerHeader className="mb-4"></DrawerHeader>
|
||||||
|
|
||||||
{history.map((history, index, array) => (
|
{history.map((history, index, array) => (
|
||||||
<>
|
<>
|
||||||
<ol
|
<ol
|
||||||
key={history.id}
|
key={history.id}
|
||||||
className="relative border-s border-gray-300 dark:border-gray-700 mr-48"
|
className="relative border-s border-gray-300 dark:border-gray-700 mr-36"
|
||||||
>
|
>
|
||||||
<li className="mb-10 ms-6">
|
<li className="mb-10 ms-6 w-full">
|
||||||
<span className="absolute flex items-center justify-center w-8 h-8 bg-blue-100 rounded-full -start-4 ring-8 ring-white bg-blue2 ">
|
<span className="absolute flex items-center justify-center w-8 h-8 bg-blue-100 rounded-full -start-4 ring-2 ring-blue bg-blue2 text-white">
|
||||||
{array.length - index}
|
{array.length - index}
|
||||||
</span>
|
</span>
|
||||||
<div className=" bg-white border-2 border-gray-300 rounded-lg shadow-sm dark:bg-gray-700 dark:border-gray-600 w-full">
|
<div className=" bg-white border-2 border-gray-300 rounded-lg shadow-sm dark:bg-gray-700 dark:border-gray-600 w-full">
|
||||||
|
|
@ -109,17 +131,77 @@ const RequestProcess: React.FC<RequestProcessProps> = ({ reportId }) => {
|
||||||
>
|
>
|
||||||
{history?.reason?.title}
|
{history?.reason?.title}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
{history?.attachments?.length > 0 && (
|
||||||
|
<div className="flex flex-col justify-center items-center">
|
||||||
|
<div className="">
|
||||||
|
<span>پیوست ها</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-row justify-center">
|
||||||
|
{history?.attachments?.map((attachment, index) => (
|
||||||
|
<div
|
||||||
|
className="cursor-pointer"
|
||||||
|
// onClick={URI.download(a.url)}
|
||||||
|
onClick={() => handleDownload(attachment.url)}
|
||||||
|
key={index}
|
||||||
|
>
|
||||||
|
{attachment.mediaType == 0 && (
|
||||||
|
<Image
|
||||||
|
src={imgimage}
|
||||||
|
alt="picture"
|
||||||
|
quality={100}
|
||||||
|
height={1000}
|
||||||
|
width={1000}
|
||||||
|
className="w-20 h-20 object-cover"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{attachment.mediaType == 1 && (
|
||||||
|
<Image
|
||||||
|
src={imgvideo}
|
||||||
|
alt="picture"
|
||||||
|
quality={100}
|
||||||
|
height={100}
|
||||||
|
width={100}
|
||||||
|
className="w-20 h-20 object-cover"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{attachment.mediaType == 2 && (
|
||||||
|
<Image
|
||||||
|
src={imgvoice}
|
||||||
|
alt="picture"
|
||||||
|
quality={100}
|
||||||
|
height={100}
|
||||||
|
width={100}
|
||||||
|
className="w-20 h-20 object-cover"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{attachment.mediaType == 3 && (
|
||||||
|
<Image
|
||||||
|
src={imgdocument}
|
||||||
|
alt="picture"
|
||||||
|
quality={100}
|
||||||
|
height={100}
|
||||||
|
width={100}
|
||||||
|
className="w-20 h-20 object-cover"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<span className="absolute -right-44 top-0 ">
|
<div className="flex flex-col justify-center items-center gap-2 absolute -right-36 top-0 ">
|
||||||
|
<span className="">
|
||||||
{convertTime(history.dateTime)}
|
{convertTime(history.dateTime)}
|
||||||
</span>
|
</span>
|
||||||
<span className="absolute -right-44 top-5 ">
|
<span className=" ">
|
||||||
{convertDate(history.dateTime)}
|
{convertDate(history.dateTime)}
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
</ol>
|
</ol>
|
||||||
</>
|
</>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ const RequestViolations: React.FC<RequestViolationsProps> = ({
|
||||||
|
|
||||||
// 2. Define a submit handler.
|
// 2. Define a submit handler.
|
||||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||||
|
// e.stopPropagation();
|
||||||
console.log(values);
|
console.log(values);
|
||||||
setViolationType(values.violationTypeId);
|
setViolationType(values.violationTypeId);
|
||||||
setViolationDescription(values.description);
|
setViolationDescription(values.description);
|
||||||
|
|
@ -164,12 +165,15 @@ const RequestViolations: React.FC<RequestViolationsProps> = ({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
{/* <Button variant="outline">Share</Button> */}
|
{/* <Button variant="outline">Share</Button> */}
|
||||||
<FaRegFlag className="text-lg mx-1 cursor-pointer" />
|
<FaRegFlag className="text-lg mx-1 cursor-pointer"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
/>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
|
|
||||||
<DialogContent className="sm:max-w-xl">
|
<DialogContent className="sm:max-w-xl">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue