import { useParams, useNavigate } from "react-router-dom"; import { useCustomerOne } from "../../Hooks/Customers"; import { Form, Spin, Watermark, Space, Tabs, Row, Col, Input, Button, Select, } from "antd"; import { customerController } from "../../API/LayoutApi/customers"; import Notfound from "../../Utils/Notfound"; import { role } from "../../App"; import { useState } from "react"; // @ts-ignore import infoIcon from "../../assets/infoIcon.png"; // @ts-ignore import infoIconActive from "../../assets/infoIconActive.png"; // @ts-ignore import zippy from "../../assets/zippyicon.svg"; // @ts-ignore import evo from "../../assets/evoicon.png"; // @ts-ignore import zeelog from "../../assets/zeelogicon.svg"; // @ts-ignore import ontime from "../../assets/ontimeicon.svg"; // @ts-ignore import tt from "../../assets/tticon.svg"; import { useCompanyData } from "../../Hooks/Companies"; const TabPane = Tabs.TabPane; type params = { readonly id: any; }; const CustomerEdit = () => { const { id } = useParams(); const { data, status } = useCustomerOne(id); let navigate = useNavigate(); const onSubmit = async (value: any) => { value.company_id = companyVal; await customerController.customerPatch(value, id); window.location.replace("/#/customers/"); }; const ClickDelete = () => { const shouldDelete = window.confirm( "Are you sure, you want to delete this Driver?" ); if (shouldDelete && id !== undefined) { customerController.deleteCustomerController(id); navigate(-1); } }; const [activeTab, setActiveTab] = useState("1"); const getImageSource = (source: string) => { switch (source) { case "Zippy": return zippy; case "EVO": return evo; case "Ontime": return ontime; case "Zeelog": return zeelog; case "TT": return tt; default: return tt; } }; const [companyName, setCompanyName] = useState(""); const [companyVal, setCompanyVal] = useState(); const { data: companyData } = useCompanyData({ name: companyName, }); return (
{status === "loading" ? ( ) : data ? ( setActiveTab(key)} > Information } key="1" >
{role === "Owner" && ( )}
) : ( )}
); }; export default CustomerEdit;