diff --git a/.gitignore b/.gitignore index 4d29575..ce85e70 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ npm-debug.log* yarn-debug.log* yarn-error.log* +build.zip diff --git a/build.zip b/build.zip index d636771..68dad35 100644 Binary files a/build.zip and b/build.zip differ diff --git a/src/API/LayoutApi/companies.ts b/src/API/LayoutApi/companies.ts index 85a53bd..1e41658 100644 --- a/src/API/LayoutApi/companies.ts +++ b/src/API/LayoutApi/companies.ts @@ -52,7 +52,7 @@ export const companyController = { return data; }, - async companyOne(Id: number | undefined) { + async companyOne(Id: number | string | undefined) { if (Id) { const { data } = await instance.get(`company/${Id}/`); return data; diff --git a/src/API/LayoutApi/customers.ts b/src/API/LayoutApi/customers.ts index 44e22f4..0efd11b 100644 --- a/src/API/LayoutApi/customers.ts +++ b/src/API/LayoutApi/customers.ts @@ -10,6 +10,7 @@ export type TCustomerGetParams = { for_driver_request?: boolean; is_active?: boolean; }; + export type TCustomerByCompanyGetParams = { name?: string; id?: number; @@ -50,21 +51,20 @@ export const customerController = { } }, - async customerByCompany( - id: number | undefined, - name: string | undefined, - for_driver_request?: boolean - ) { - const params = { name, for_driver_request }; - if (!!name) params.name = name; - if (!!for_driver_request) params.for_driver_request = for_driver_request; - if (id) { - const { data } = await instance.get( - `customers-by-company/${id}/`, - { params } - ); - return data; - } + async customerByCompany(filterObject: TCustomerGetParams, id?: number) { + const params = { ...filterObject }; + + if (!!filterObject.name) params.name = filterObject.name; + if (!!filterObject.for_driver_request) + params.for_driver_request = filterObject.for_driver_request; + if (!!filterObject.page) params.page = filterObject.page; + if (!!filterObject.page_size) params.page_size = filterObject.page_size; + + const { data } = await instance.get>( + `customers-by-company/${id}/`, + { params } + ); + return data; }, async customerPatch(obj: TCustomerPutParams, id: string) { diff --git a/src/API/LayoutApi/tasks.ts b/src/API/LayoutApi/tasks.ts index 8e1e31f..6894236 100644 --- a/src/API/LayoutApi/tasks.ts +++ b/src/API/LayoutApi/tasks.ts @@ -96,6 +96,24 @@ export const taskController = { }; } }, + async taskPatchPatch(obj: TTasksPutParams, task_id: number | undefined) { + try { + const response = await instance.patch( + `task/${task_id}/`, + obj + ); + if (response.status === 202) { + const data = response.data as TMessageResponse; + message.success({ content: data.message }); + } + return { data: response?.data as TTask, status: response?.status }; + } catch (error: any) { + return { + data: error?.response?.data.data, + status: error?.response.status, + }; + } + }, async addTaskController(obj: TTasksPostParams) { const { data } = await instance.post("task/", obj).then((u) => { diff --git a/src/API/LayoutApi/teams.ts b/src/API/LayoutApi/teams.ts index e49f7f2..a76f2ff 100644 --- a/src/API/LayoutApi/teams.ts +++ b/src/API/LayoutApi/teams.ts @@ -2,6 +2,11 @@ import { TTeam } from "../../types/Team/TTeam"; import instance from "../api"; import { message } from "antd"; +export type TTeamGetParams = { + name?: string; + company_id?: string | number; +}; + export type TTeamPutParams = { name?: string; is_active?: boolean; @@ -13,8 +18,15 @@ export type TTeamPostParams = { }; export const teamController = { - async read(name: string) { - const { data } = await instance.get(`teams/?name=${name}`); + async read(obj: TTeamGetParams) { + const params = { ...obj }; + + if (!!obj.company_id) params.company_id = obj.company_id; + if (!!obj.name) params.name = obj.name; + + const { data } = await instance.get(`teams/`, { + params, + }); return data; }, diff --git a/src/API/api.ts b/src/API/api.ts index c8b4ab2..7fc24f1 100644 --- a/src/API/api.ts +++ b/src/API/api.ts @@ -1,7 +1,7 @@ import axios from "axios"; // const instance = axios.create({ -// baseURL: "http://10.10.10.19:8080/api/v1/", +// baseURL: "http://10.10.10.64:8080/api/v1/", // }); const instance = axios.create({ baseURL: "https://api.tteld.co/api/v1/", diff --git a/src/API/auth/Login.ts b/src/API/auth/Login.ts index 322373b..b31bc14 100644 --- a/src/API/auth/Login.ts +++ b/src/API/auth/Login.ts @@ -32,11 +32,13 @@ export const LoginApi = async ({ username, password }: loginInterface) => { localStorage.setItem("refresh", data?.data.refresh); localStorage.setItem("admin_id", data?.data.id); document.location.replace("/"); - } catch (err) { + } catch (err: any) { setTimeout(() => { message.error({ - content: "Username or password incorrect!", - duration: 2, + content: err?.response?.data + ? err?.response?.data?.message + : "Username or password incorrect!!!", + duration: 8, }); }, 1000); } diff --git a/src/App.tsx b/src/App.tsx index 6c250c4..55765e4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -263,7 +263,7 @@ const App: React.FC = () => { admin_id ) { // taskSocket = new WebSocket( - // `ws://10.10.10.19:8080/global/?user_id=${admin_id}` + // `ws://10.10.10.64:8080/global/?user_id=${admin_id}` // ); taskSocket = new WebSocket( `wss://api.tteld.co/global/?user_id=${admin_id}` diff --git a/src/Components/Companies/AddDriver.tsx b/src/Components/Companies/AddDriver.tsx index 7bfc6f5..5eae419 100644 --- a/src/Components/Companies/AddDriver.tsx +++ b/src/Components/Companies/AddDriver.tsx @@ -1,51 +1,20 @@ -import { Input, Modal, Form as FormAnt, Select } from "antd"; +import { Input, Modal, Form as FormAnt } from "antd"; import { customerController } from "../../API/LayoutApi/customers"; -import { useCompanyData, useCompanyOne } from "../../Hooks/Companies"; -// @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 { useState } from "react"; +import { useCompanyOne } from "../../Hooks/Companies"; const AddDriver = ({ open, id, setOpen, }: { - id: any; + id: number | undefined; open: boolean; setOpen(open: boolean): void; }) => { const [form] = FormAnt.useForm(); - + const companyData = useCompanyOne(id); const handleCancel = () => { setOpen(!open); }; - - const companyData = useCompanyOne(id); - const companyDataAll = useCompanyData({ name: "" }); - const [companyName, setCompanyName] = useState(); - 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; - } - }; return (
+ + + - - {id ? ( - - ) : ( - setTeam(e)} + onChange={(e: string) => setTeam(e)} /> @@ -286,7 +298,7 @@ const CompanyEdit = () => { }, }; }} - dataSource={customerData?.data?.map((u, i) => ({ + dataSource={customerData.data?.data?.map((u, i) => ({ ...u, no: i + 1, key: u?.id, @@ -327,7 +339,40 @@ const CompanyEdit = () => { }, }, ]} + pagination={false} /> + + + + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + {open && ( )} diff --git a/src/Components/Customers/AddCustomer.tsx b/src/Components/Customers/AddCustomer.tsx index dadaf48..bf71cf6 100644 --- a/src/Components/Customers/AddCustomer.tsx +++ b/src/Components/Customers/AddCustomer.tsx @@ -16,10 +16,9 @@ import tt from "../../assets/tticon.svg"; const AddCustomer = ({ open, setOpen, - refetch, }: { open: boolean; - refetch: any; + setOpen(open: boolean): void; }) => { const [form] = FormAnt.useForm(); @@ -66,7 +65,6 @@ const AddCustomer = ({ setOpen(!open); } }); - refetch(); }); }} > diff --git a/src/Components/Customers/Customers.tsx b/src/Components/Customers/Customers.tsx index 8d70b81..05ccbba 100644 --- a/src/Components/Customers/Customers.tsx +++ b/src/Components/Customers/Customers.tsx @@ -11,7 +11,7 @@ import { Button, Input, Space } from "antd"; const Customer = () => { const [open, setOpen] = useState(false); - const [page, setPage] = useState(1) + const [page, setPage] = useState(1); const showModal = () => { setOpen(true); }; @@ -21,7 +21,7 @@ const Customer = () => { name: search, is_active: undefined, page_size: 10, - page: page + page: page, }); const Next = () => { @@ -50,7 +50,7 @@ const Customer = () => { const theme = localStorage.getItem("theme") === "true" ? true : false; return (
- {open && } + {open && }

Drivers