import { TTask } from "../../types/Tasks/TTasks"; import { Dropdown, MenuProps, Modal, Table, Tabs, Tooltip, message, } from "antd"; import TabPane from "antd/es/tabs/TabPane"; import { role, timeZone } from "../../App"; import { useTaskHistory } from "../../Hooks/Tasks"; import TextArea from "antd/es/input/TextArea"; import { useEffect, useState } from "react"; import { taskController } from "../../API/LayoutApi/tasks"; import { useTeamData } from "../../Hooks/Teams"; import { TTeam } from "../../types/Team/TTeam"; import { EditOutlined } from "@ant-design/icons"; import { TSocket } from "../../types/common/TSocket"; // @ts-ignore import closeIcon from "../../assets/closeIcon.png"; // @ts-ignore import editIcon from "../../assets/editIcon.png"; // @ts-ignore import historyIcon from "../../assets/hisoryIcon.png"; // @ts-ignore import attachmentIcon from "../../assets/attachmentIcon.png"; // @ts-ignore import infoIcon from "../../assets/infoIcon.png"; // @ts-ignore import uploadIcon from "../../assets/uploadIcon.png"; // @ts-ignore import pdficon from "../../assets/pdficon.png"; // @ts-ignore import letssee from "../../assets/letssee.png"; // @ts-ignore import svgicon from "../../assets/svgicon.png"; // @ts-ignore import pngicon from "../../assets/pngicon.png"; // @ts-ignore import jpgicon from "../../assets/jpgicon.png"; // @ts-ignore import jpegicon from "../../assets/jpegicon.png"; // @ts-ignore import xlsicon from "../../assets/xlsicon.png"; // @ts-ignore import docicon from "../../assets/docicon.png"; // @ts-ignore import forwardIcon from "../../assets/forward.png"; // @ts-ignore import driverIcon from "../../assets/drivericon.png"; // @ts-ignore import userIcon from "../../assets/userIcon.png"; const TaskModal = ({ modalOpen, setModalOpen, recordTask, setRecordTask, uploadOpen, setUploadOpen, socketData, }: { recordTask: TTask | undefined; setRecordTask: React.Dispatch>; modalOpen: boolean; setModalOpen: any; uploadOpen: boolean; setUploadOpen: any; socketData: TSocket | undefined; }) => { const moment = require("moment-timezone"); const theme = localStorage.getItem("theme") === "true" ? true : false; const [text, setText] = useState(recordTask?.note); const [pti, setPti] = useState(recordTask?.pti); const [status, setStatus] = useState(recordTask?.status); const [teamName, setTeamName] = useState(recordTask?.assigned_to?.name); const { data, isLoading } = useTaskHistory(recordTask?.id); const handleCancel = () => { setModalOpen(!modalOpen); }; const showUploadModal = () => { setUploadOpen(!uploadOpen); }; function getFileType(fileName: any) { var fileExtension = fileName.split(".").pop()?.toLowerCase(); switch (fileExtension) { case "jpg": return ; case "jpeg": return ; case "png": return ; case "pdf": return ; case "svg": return ; case "xls": return ; default: return ; } } const teamData = useTeamData({}); // const teamData = useCustomerData({name: "", page: 1, page_size: 100}); const teams: MenuProps["items"] = teamData?.data?.map((item, index) => ({ key: item?.id, label: (

{item?.name}

{item?.task_count_percentage}%

), onClick: () => teampatch(item), })); const items: MenuProps["items"] = [ { key: "1", label:

New

, onClick: () => statuspatch("New"), }, { key: "2", label:

Checking

, onClick: () => statuspatch("Checking"), }, { key: "3", label:

Done

, onClick: () => statuspatch("Done"), }, ]; const getImageSource = (source: string) => { switch (source) { case "driver": return driverIcon; case "user": return userIcon; default: return userIcon; } }; const statuspatch = (status: string) => { setStatus(status); taskController.taskPatch({ status: status }, recordTask?.id); }; const teampatch = (item: TTeam) => { setTeamName(item?.name); taskController .taskPatchPatch({ assigned_to_id: item?.id }, recordTask?.id) .then(() => { setModalOpen(false); }); }; const patchTask = () => { taskController.taskPatch({ note: text, pti: pti }, recordTask?.id); setModalOpen(!modalOpen); }; // const nextStatus = (status : string) => { // console.log(); // } useEffect(() => { if (socketData && socketData.task) { if ( socketData.type === "task_update" && socketData.task.id === recordTask?.id ) { setRecordTask(socketData.task); } } }, [socketData]); return (

{recordTask?.customer?.name}

{/* */}
Information } key="1" >

Information

Comapany

{recordTask?.company?.name}

Driver

{recordTask?.customer?.name}

Service

{recordTask?.service?.title}

Team

{teamName}

Assignee

{recordTask?.in_charge?.username}

PTI

{pti === false ? "Do" : "No need"}

Created at

{moment( recordTask?.created_at, "YYYY-MM-DD HH:mm:ss" ).format("DD.MM.YYYY HH:mm")}