diff --git a/src/apis/api_services.ts b/src/apis/api_services.ts new file mode 100644 index 0000000..b60bac4 --- /dev/null +++ b/src/apis/api_services.ts @@ -0,0 +1,31 @@ +import apis from "./axios"; +import { SERVICE_ALL, SERVICE_W_CLIENT } from "./req_list"; +import { RES_STATUS } from "@/configs/types"; + +export const serviceAll = async () => { + try { + const response = await apis.get(SERVICE_ALL); + return response.data; + } catch (err: unknown) { + console.log("-> retrieve all service error: ", err); + return { + status: RES_STATUS.FAILED, + msg: "failed in retrieving all services", + data: "", + }; + } +}; + +export const serviceWClient = async (cid: string) => { + try { + const response = await apis.post(SERVICE_W_CLIENT, { cid }); + return response.data; + } catch (err: unknown) { + console.log("-> retrieve client services error: ", err); + return { + status: RES_STATUS.FAILED, + msg: "failed in retrieving client services", + data: "", + }; + } +}; diff --git a/src/apis/index.ts b/src/apis/index.ts index 83032ce..ecc4c38 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -5,6 +5,7 @@ import * as API_ORDER from "./api_orders"; import * as API_STAFF from "./api_staff"; import * as API_PAYSLIP from "./api_payslip"; import * as API_CHART from "./api_chart"; +import * as API_SERVICE from "./api_services"; export { API_ADMIN, @@ -14,4 +15,5 @@ export { API_ORDER, API_STAFF, API_PAYSLIP, + API_SERVICE, }; diff --git a/src/apis/req_list.ts b/src/apis/req_list.ts index 6fe98f3..c6bfc53 100644 --- a/src/apis/req_list.ts +++ b/src/apis/req_list.ts @@ -58,6 +58,10 @@ export const PAYMENT_UPDATE = "/api/order/updatePayments"; export const INVOICE_ISSUE_UPDATE = "/api/order/updateInvoiceIssue"; export const ORDER_ALL_ARRANGEMENT = "/api/order/all_arrangement"; +// Service +export const SERVICE_ALL = "/api/service/all"; +export const SERVICE_W_CLIENT = "/api/service/withClientID"; + // Assist export const SETTING_UNI_ALL = "/api/setting/uni_all"; export const SETTING_UNI_ADD = "/api/setting/uni_add"; diff --git a/src/components/table/tableBtn/OrderStatusBtn.tsx b/src/components/table/tableBtn/OrderStatusBtn.tsx index 56e6110..e9ed66c 100644 --- a/src/components/table/tableBtn/OrderStatusBtn.tsx +++ b/src/components/table/tableBtn/OrderStatusBtn.tsx @@ -24,9 +24,9 @@ const OrderStatusBtn: FC = ({ mLabel, data }) => { const submit = useSubmit(); const currentRouter = useRouterStore((state) => state.currentRouter); - const handleClick = async (oid: string, status: string) => { + const handleClick = async (cid: string, oid: string, status: string) => { submit( - { req: "orderStatus", oid, status }, + { req: "orderStatus", cid, oid, status }, { method: "PUT", action: @@ -49,7 +49,7 @@ const OrderStatusBtn: FC = ({ mLabel, data }) => {
{ //e.preventDefault(); - handleClick(data.oid, item); + handleClick(data.fk_cid, data.oid, item); }} className="flex w-full items-center rounded-md px-2 text-md font-bold" > diff --git a/src/components/table/tableBtn/ServiceStatusBtn.tsx b/src/components/table/tableBtn/ServiceStatusBtn.tsx new file mode 100644 index 0000000..42ec972 --- /dev/null +++ b/src/components/table/tableBtn/ServiceStatusBtn.tsx @@ -0,0 +1,74 @@ +import type { FC, ReactNode } from "react"; +import { useSubmit } from "react-router-dom"; +import { useRouterStore } from "@/configs/zustore"; +import { capFirstLetter, genAction } from "@/lib/literals"; +import { ORDER_STATUS } from "@/configs/utils/setting"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + // DropdownMenuLabel, + // DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { statusColor } from "@/configs/utils/color"; +import { TclientService } from "@/configs/schema/serviceSchema"; + +type Tprops = { + mLabel: ReactNode | string; + data: TclientService; +}; + +// this menu btn group component is highly designed for order status change usage +const ServiceStatusBtn: FC = ({ mLabel, data }) => { + const submit = useSubmit(); + const currentRouter = useRouterStore((state) => state.currentRouter); + + const handleClick = async (csid: string, status: string) => { + submit( + { req: "ServiceStatus", csid, status }, + { + method: "PUT", + action: + currentRouter === "client" + ? genAction(currentRouter, data.fk_cid) + : genAction(currentRouter), + } + ); + }; + + const menuContent = ORDER_STATUS.map((item, index) => { + if (item.toLocaleLowerCase() === data.status.toLocaleLowerCase()) + return; + + return ( + +
{ + //e.preventDefault(); + handleClick(data.csid, item); + }} + className="flex w-full items-center rounded-md px-2 text-md font-bold" + > + {capFirstLetter(item)} +
+
+ ); + }).filter((item) => item !== null && item !== undefined); + + return ( + + + {mLabel} + + {menuContent ? ( + {menuContent} + ) : null} + + ); +}; + +export default ServiceStatusBtn; diff --git a/src/configs/atoms/atOrderWithClient.ts b/src/configs/atoms/atOrderWithClient.ts index 07e207c..ce2062d 100644 --- a/src/configs/atoms/atOrderWithClient.ts +++ b/src/configs/atoms/atOrderWithClient.ts @@ -1,10 +1,12 @@ import { atom } from "jotai"; import { - TorderService, TorderWithClient, orderWithClientSchema, } from "@/configs/schema/orderSchema"; -import { orderServiceSchema } from "../schema/orderServiceSchema"; +import { + orderServiceSchema, + TorderService, +} from "../schema/orderServiceSchema"; const atOrderWithClient = atom( orderWithClientSchema.parse({}) diff --git a/src/configs/columnDefs/defClientService.tsx b/src/configs/columnDefs/defClientService.tsx new file mode 100644 index 0000000..180ea10 --- /dev/null +++ b/src/configs/columnDefs/defClientService.tsx @@ -0,0 +1,98 @@ +import { ColumnDef, CellContext } from "@tanstack/react-table"; +import i18n from "@/configs/i18n"; +import { TclientService } from "../schema/serviceSchema"; +import ServiceStatusBtn from "@/components/table/tableBtn/ServiceStatusBtn"; +import { StatusBadge } from "@/components/Badge"; +import { TstatusColor } from "../types"; +import { dateFormat } from "@/lib/time"; + +const useClientServiceColumnsDef = () => { + const clientServiceColumns: ColumnDef[] = [ + /* { + id: "Menu", + header: i18n.t("label.menu"), + }, */ + + { + id: "csid", + header: i18n.t("label.serviceID"), + accessorKey: "csid", + cell: (info: CellContext) => ( + {info.getValue()} + ), + }, + { + id: "title", + header: i18n.t("label.title"), + accessorKey: "title", + cell: (info: CellContext) => ( + {info.getValue()} + ), + }, + { + id: "type", + header: i18n.t("label.serviceType"), + accessorKey: "service_type", + cell: (info: CellContext) => ( + {info.getValue()} + ), + }, + { + id: "productName", + header: i18n.t("label.productName"), + accessorKey: "product_name", + cell: (info: CellContext) => ( + {info.getValue()} + ), + }, + { + id: "serviceStatus", + header: i18n.t("label.status"), + accessorKey: "status", + cell: (info: CellContext) => { + return ( + + } + data={info.row.original as TclientService} + /> + ); + }, + meta: { + filterVariant: "select", + }, + }, + { + id: "createdDate", + header: i18n.t("label.createdDate"), + accessorKey: "created_date", + cell: (info: CellContext) => ( + + {dateFormat(info.getValue(), "au")} + + ), + }, + { + id: "expiryDate", + header: i18n.t("label.expiredDate"), + accessorKey: "expiry_date", + cell: (info: CellContext) => ( + {info.getValue()} + ), + }, + { + id: "note", + header: i18n.t("label.note"), + accessorKey: "note", + cell: (info: CellContext) => ( + {info.getValue()} + ), + }, + ]; + return clientServiceColumns; +}; + +export default useClientServiceColumnsDef; diff --git a/src/configs/columnDefs/defOrderDesc.tsx b/src/configs/columnDefs/defOrderDesc.tsx index 970b7a6..6ce620a 100644 --- a/src/configs/columnDefs/defOrderDesc.tsx +++ b/src/configs/columnDefs/defOrderDesc.tsx @@ -1,8 +1,8 @@ import { ColumnDef, CellContext } from "@tanstack/react-table"; import i18n from "@/configs/i18n"; -import { TorderService } from "@/configs/schema/orderSchema"; import { rangeFilterFn } from "./filterFn"; import { formMoney } from "@/lib/literals"; +import { TorderService } from "../schema/orderServiceSchema"; const useOrderDescColumnsDef = () => { const orderDescColumns: ColumnDef[] = [ diff --git a/src/configs/i18n/scriptEn.ts b/src/configs/i18n/scriptEn.ts index 23208e3..c0d94c3 100644 --- a/src/configs/i18n/scriptEn.ts +++ b/src/configs/i18n/scriptEn.ts @@ -210,7 +210,6 @@ const en = { net: "NET", newIssueDate: "New Issue Date", none: "None", - noContent: "No Content", openMenu: "Open Menu", orders: "Orders", orderDesc: "Order Description", @@ -261,6 +260,7 @@ const en = { switch: "Switch", scheduleDate: "Schedule Date", service: "Service", + serviceID: "Service ID", services: "Services", serviceType: "Service Type", staff: "Staff", @@ -317,6 +317,7 @@ const en = { tips: { noAssignedStaff: "No Assigned Staff", noOrder: "No Order", + noContent: "No Content", noServices: "No Service", noPayments: "No Payment", noPayslips: "No Payslip", diff --git a/src/configs/schema/orderSchema.ts b/src/configs/schema/orderSchema.ts index 81d64b7..3181c51 100644 --- a/src/configs/schema/orderSchema.ts +++ b/src/configs/schema/orderSchema.ts @@ -80,7 +80,6 @@ export const orderWithClientSchema = plainOrderSchema.extend({ export type TorderWithClient = z.infer; export type TorderForm = z.infer; -export type TorderService = z.infer; export type TorderPayment = z.infer; export type TorderAbstract = z.infer; export type Tpayment = { diff --git a/src/configs/schema/serviceSchema.ts b/src/configs/schema/serviceSchema.ts new file mode 100644 index 0000000..7d878f4 --- /dev/null +++ b/src/configs/schema/serviceSchema.ts @@ -0,0 +1,17 @@ +import { z } from "zod"; +import { ORDER_STATUS } from "../utils/setting"; + +export const serviceSchema = z.object({ + csid: z.string().default(""), + fk_cid: z.string().default(""), + title: z.string().trim().default(""), + service_type: z.string().trim().default(""), + product_name: z.string().trim().default(""), + status: z.string().default(ORDER_STATUS[0]), // pending + created_date: z.string().datetime().nullable().default(null), + expiry_date: z.string().datetime().nullable().default(null), + archive: z.boolean().default(false), + note: z.string().trim().default(""), +}); + +export type TclientService = z.infer; diff --git a/src/configs/utils/setting.ts b/src/configs/utils/setting.ts index c2b8f29..5dd517e 100644 --- a/src/configs/utils/setting.ts +++ b/src/configs/utils/setting.ts @@ -14,6 +14,22 @@ export const ORDER_STATUS = [ "completed", ] as const; +// shared with service status +export const orderStatusList = [ + { name: ORDER_STATUS[0] }, // pending + { name: ORDER_STATUS[1] }, // ongoing + { name: ORDER_STATUS[2] }, // cancelled + { name: ORDER_STATUS[3] }, // completed +]; + +export const SERVICE_TYPE = ["OOP", "CTM", "SUB"] as const; + +export const serviceTypeList = [ + { name: SERVICE_TYPE[0] }, // OOP + { name: SERVICE_TYPE[1] }, // CTM + { name: SERVICE_TYPE[2] }, // SUB +]; + // the value in this array must be the same as the value in statusColor keys export const WL_STATUS = [ "pending", diff --git a/src/pageComponents/cards/OrderDescCard.tsx b/src/pageComponents/cards/OrderDescCard.tsx index 2377591..5278e64 100644 --- a/src/pageComponents/cards/OrderDescCard.tsx +++ b/src/pageComponents/cards/OrderDescCard.tsx @@ -1,9 +1,9 @@ import type { FC } from "react"; -import { TorderService } from "@/configs/schema/orderSchema"; import { useTranslation } from "react-i18next"; import Card from "@/components/Card"; import { linearLargeBG } from "@/configs/utils/color"; import { Btext } from "@/components/Btext"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; type Tprops = { data: TorderService[]; diff --git a/src/pageComponents/modals/mOrderForm/Form/FormContent.tsx b/src/pageComponents/modals/mOrderForm/Form/FormContent.tsx index cbf186d..2019225 100644 --- a/src/pageComponents/modals/mOrderForm/Form/FormContent.tsx +++ b/src/pageComponents/modals/mOrderForm/Form/FormContent.tsx @@ -13,12 +13,13 @@ import { UseFormReturn, useWatch, } from "react-hook-form"; -import { TorderForm, TorderService } from "@/configs/schema/orderSchema"; +import { TorderForm } from "@/configs/schema/orderSchema"; import { toastError } from "@/lib/toaster"; import { atOrderWithClient } from "@/configs/atoms"; import { useAtom } from "jotai"; import { useRouterStore } from "@/configs/zustore"; import { genAction } from "@/lib/literals"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; type Tprops = { register: UseFormReturn["register"]; diff --git a/src/pageComponents/modals/mOrderForm/Form/RightColumn.tsx b/src/pageComponents/modals/mOrderForm/Form/RightColumn.tsx index 187919d..b7fb8b7 100644 --- a/src/pageComponents/modals/mOrderForm/Form/RightColumn.tsx +++ b/src/pageComponents/modals/mOrderForm/Form/RightColumn.tsx @@ -7,10 +7,11 @@ import { UseFieldArraySwap, UseFormReturn, } from "react-hook-form"; -import { TorderForm, TorderService } from "@/configs/schema/orderSchema"; +import { TorderForm } from "@/configs/schema/orderSchema"; import AppendNewService from "./AppendNewService"; import { SubmitBtn } from "@/components/form"; import { useNavigation } from "react-router-dom"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; type Tprops = { register: UseFormReturn["register"]; diff --git a/src/pageComponents/modals/mOrderForm/Form/ServiceContent.tsx b/src/pageComponents/modals/mOrderForm/Form/ServiceContent.tsx index 18793ee..c23426d 100644 --- a/src/pageComponents/modals/mOrderForm/Form/ServiceContent.tsx +++ b/src/pageComponents/modals/mOrderForm/Form/ServiceContent.tsx @@ -1,6 +1,6 @@ import type { FC } from "react"; import Fieldset from "@/components/Fieldset"; -import { TorderForm, TorderService } from "@/configs/schema/orderSchema"; +import { TorderForm } from "@/configs/schema/orderSchema"; import { FieldArrayWithId, UseFieldArrayRemove, @@ -9,6 +9,7 @@ import { } from "react-hook-form"; import { useTranslation } from "react-i18next"; import ServiceItem from "./ServiceItem"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; type Tprops = { register: UseFormReturn["register"]; diff --git a/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceDetails.tsx b/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceDetails.tsx index a22a3cc..8bd2798 100644 --- a/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceDetails.tsx +++ b/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceDetails.tsx @@ -2,6 +2,7 @@ import DataList from "@/components/dataList"; import Label from "@/components/Label"; import { Input } from "@/components/ui/input"; import { TorderForm } from "@/configs/schema/orderSchema"; +import { orderStatusList, serviceTypeList } from "@/configs/utils/setting"; import type { FC } from "react"; import { UseFormReturn } from "react-hook-form"; import { useTranslation } from "react-i18next"; @@ -14,30 +15,15 @@ type Tprops = { const ServiceDetails: FC = ({ index, register }) => { const { t } = useTranslation(); - const serviceType = { - types: [{ name: "t1" }, { name: "t2" }, { name: "t3" }], - }; const serviceName = { types: [{ name: "N1" }, { name: "N2" }, { name: "N3" }], }; - const testStatus = { - types: [ - { name: "PENDING1" }, - { name: "PENDING2" }, - { name: "PENDING3" }, - ], - }; - - const serviceTypeList = serviceType ? ( - - ) : null; + const sTypeList = ( + + ); - const productNameList = serviceType ? ( + const productNameList = serviceName ? ( = ({ index, register }) => { ); @@ -85,7 +71,7 @@ const ServiceDetails: FC = ({ index, register }) => { type="text" list="serviceTypeList" /> - {serviceTypeList} + {sTypeList}
{/* product name */}
diff --git a/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceItem.tsx b/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceItem.tsx index aaa5508..6895d8e 100644 --- a/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceItem.tsx +++ b/src/pageComponents/modals/mOrderForm/Form/ServiceItem/ServiceItem.tsx @@ -1,6 +1,6 @@ import { XBtn } from "@/components/btns"; import Card from "@/components/Card"; -import { TorderForm, TorderService } from "@/configs/schema/orderSchema"; +import { TorderForm } from "@/configs/schema/orderSchema"; import { linearLargeBG } from "@/configs/utils/color"; import type { FC } from "react"; import { @@ -15,6 +15,7 @@ import Fee from "./Fee"; import Note from "./Note"; import { useTranslation } from "react-i18next"; import ServiceDetails from "./ServiceDetails"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; type Tprops = { fields: FieldArrayWithId[]; diff --git a/src/pageComponents/modals/mPayslip/StaffWLTable.tsx b/src/pageComponents/modals/mPayslip/StaffWLTable.tsx index fd88ac6..245f00b 100644 --- a/src/pageComponents/modals/mPayslip/StaffWLTable.tsx +++ b/src/pageComponents/modals/mPayslip/StaffWLTable.tsx @@ -29,7 +29,7 @@ const StaffWLTable: FC = () => { ) : ( - {t("label.noContent")} + {t("tips.noContent")} ); diff --git a/src/pageComponents/orderSubTables.tsx b/src/pageComponents/orderSubTables.tsx index c4c5fac..cb02f50 100644 --- a/src/pageComponents/orderSubTables.tsx +++ b/src/pageComponents/orderSubTables.tsx @@ -1,14 +1,11 @@ import { PTable } from "@/components/table"; -import { - TorderWithClient, - TorderPayment, - TorderService, -} from "@/configs/schema/orderSchema"; +import { TorderWithClient, TorderPayment } from "@/configs/schema/orderSchema"; import i18n from "@/configs/i18n"; import { TitemContent } from "@/configs/types"; import { ColumnDef } from "@tanstack/react-table"; import { ORDER_STATUS } from "@/configs/utils/setting"; import QuoteDetailsCard from "./cards/QuoteDetailsCard"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; export const orderSubTable = ( data: TorderWithClient, diff --git a/src/pageComponents/pdfTemplates/template1/TableFooter.tsx b/src/pageComponents/pdfTemplates/template1/TableFooter.tsx index 713593d..673b671 100644 --- a/src/pageComponents/pdfTemplates/template1/TableFooter.tsx +++ b/src/pageComponents/pdfTemplates/template1/TableFooter.tsx @@ -2,11 +2,11 @@ import { memo } from "react"; import type { FC } from "react"; import { Text, View } from "@react-pdf/renderer"; import { createTw } from "react-pdf-tailwind"; -import { TorderService } from "@/configs/schema/orderSchema"; import { useTranslation } from "react-i18next"; import { minusAB, plusAB, timesAB } from "@/lib/calculations"; import { convertToFloat, formMoney } from "@/lib/literals"; import Deposit from "./Deposit"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; type Tprops = { type?: "I" | "Q"; // Invoice or Quotation diff --git a/src/pageComponents/pdfTemplates/template1/TableRows.tsx b/src/pageComponents/pdfTemplates/template1/TableRows.tsx index bfa7e56..30fb279 100644 --- a/src/pageComponents/pdfTemplates/template1/TableRows.tsx +++ b/src/pageComponents/pdfTemplates/template1/TableRows.tsx @@ -2,8 +2,8 @@ import { memo } from "react"; import type { FC } from "react"; import { Text, View } from "@react-pdf/renderer"; import { createTw } from "react-pdf-tailwind"; -import { TorderService } from "@/configs/schema/orderSchema"; import { formMoney } from "@/lib/literals"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; type Tprops = { data: TorderService[]; diff --git a/src/pageComponents/pdfTemplates/template1/template.tsx b/src/pageComponents/pdfTemplates/template1/template.tsx index c01ec06..d37abf3 100644 --- a/src/pageComponents/pdfTemplates/template1/template.tsx +++ b/src/pageComponents/pdfTemplates/template1/template.tsx @@ -2,11 +2,7 @@ import type { FC } from "react"; import { PDFViewer, Page, View, Document, Text } from "@react-pdf/renderer"; import { createTw } from "react-pdf-tailwind"; import { Tclient } from "@/configs/schema/clientSchema"; -import { - TorderService, - TorderPayment, - TorderWithClient, -} from "@/configs/schema/orderSchema"; +import { TorderPayment, TorderWithClient } from "@/configs/schema/orderSchema"; import TableHeader from "./TableHeader"; import TableRows from "./TableRows"; import BillTitle from "./BillTitle"; @@ -17,6 +13,7 @@ import PayHeader from "./PayHeader"; import PayRows from "./PayRows"; import { Tcompany } from "@/configs/schema/settingSchema"; import { useTranslation } from "react-i18next"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; const tw = createTw({}); diff --git a/src/pages/client/Client.tsx b/src/pages/client/Client.tsx index 99c73c7..f62d3e5 100644 --- a/src/pages/client/Client.tsx +++ b/src/pages/client/Client.tsx @@ -16,13 +16,21 @@ import { mOpenOps } from "@/configs/utils/modal"; import { MpdfMaker } from "@/pageComponents/modals"; import ErrorTips from "@/components/ErrorTips"; import MainContent from "./MainContent"; +import { TclientService } from "@/configs/schema/serviceSchema"; const Client: FC = () => { const { t } = useTranslation(); const [modalOpen, setModalOpen] = useAtom(atModalOpen); const { allPromise } = useLoaderData() as { allPromise: Promise< - [Tclient[], TorderWithClient[], Tunivers, Tcompany, string] + [ + Tclient[], + TorderWithClient[], + TclientService[], + Tunivers, + Tcompany, + string, + ] >; }; const actionData = useActionData() as Tresponse; diff --git a/src/pages/client/ClientServiceContent.tsx b/src/pages/client/ClientServiceContent.tsx new file mode 100644 index 0000000..8da3ed6 --- /dev/null +++ b/src/pages/client/ClientServiceContent.tsx @@ -0,0 +1,32 @@ +import Card from "@/components/Card"; +import { PTable } from "@/components/table"; +import useClientServiceColumnsDef from "@/configs/columnDefs/defClientService"; +import { TclientService } from "@/configs/schema/serviceSchema"; +import type { FC } from "react"; +import { useTranslation } from "react-i18next"; + +type Tprops = { + services: TclientService[]; +}; + +const ClientServiceContent: FC = ({ services }) => { + const { t } = useTranslation(); + const clientServiceColumns = useClientServiceColumnsDef(); + + return ( + + {/* client orders table */} + {services.length > 0 ? ( + + ) : ( + {t("tips.noContent")} + )} + + ); +}; + +export default ClientServiceContent; diff --git a/src/pages/client/MainContent.tsx b/src/pages/client/MainContent.tsx index 638a265..fa8d1c2 100644 --- a/src/pages/client/MainContent.tsx +++ b/src/pages/client/MainContent.tsx @@ -21,6 +21,8 @@ import { Tcompany } from "@/configs/schema/settingSchema"; import { Nbtn } from "@/components/btns"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import ClientOrderContent from "./ClientOrderContent"; +import { TclientService } from "@/configs/schema/serviceSchema"; +import ClientServiceContent from "./ClientServiceContent"; const MainContent: FC = () => { const { t } = useTranslation(); @@ -34,13 +36,17 @@ const MainContent: FC = () => { const [, setCompany] = useAtom(atCompany); const [, setLogo] = useAtom(atLogo); const [, setServiceDesc] = useAtom(atOrderService); - const [client, orders, uniData, company, logo] = useAsyncValue() as [ - Tclient[], - TorderWithClient[], - Tunivers, - Tcompany, - string, - ]; + const [client, orders, services, uniData, company, logo] = + useAsyncValue() as [ + Tclient[], + TorderWithClient[], + TclientService[], + Tunivers, + Tcompany, + string, + ]; + + console.log("--> client services: ", services); const initOrder: TorderWithClient = { oid: "", @@ -149,7 +155,7 @@ const MainContent: FC = () => { -
processing
+
); diff --git a/src/routerAccFns/actions/orderAction.ts b/src/routerAccFns/actions/orderAction.ts index 3cc4acf..da7db23 100644 --- a/src/routerAccFns/actions/orderAction.ts +++ b/src/routerAccFns/actions/orderAction.ts @@ -1,5 +1,5 @@ import { API_ORDER } from "@/apis"; -import { TorderService } from "@/configs/schema/orderSchema"; +import { TorderService } from "@/configs/schema/orderServiceSchema"; import { TwlUnion } from "@/configs/schema/workSchema"; import { ActionFunctionArgs } from "react-router-dom"; @@ -78,6 +78,7 @@ export const ordersAction = async ({ // change order status else if ("PUT" === request.method && data.get("req") === "orderStatus") { const result = await API_ORDER.orderChangeStatus({ + cid: data.get("cid"), oid: data.get("oid"), status: data.get("status")?.toString().toLocaleLowerCase(), }); diff --git a/src/routerAccFns/loaders/clientPageLoader.ts b/src/routerAccFns/loaders/clientPageLoader.ts index ed94610..3035672 100644 --- a/src/routerAccFns/loaders/clientPageLoader.ts +++ b/src/routerAccFns/loaders/clientPageLoader.ts @@ -1,4 +1,10 @@ -import { API_ADMIN, API_CLIENT, API_SETTING, API_ORDER } from "@/apis"; +import { + API_ADMIN, + API_CLIENT, + API_SETTING, + API_ORDER, + API_SERVICE, +} from "@/apis"; import { TorderWithClient } from "@/configs/schema/orderSchema"; import { menuList } from "@/configs/utils/router"; import { routerStore } from "@/configs/zustore"; @@ -41,6 +47,7 @@ export const clientLoader = async ({ request, params }: LoaderFunctionArgs) => { }; }) ), + API_SERVICE.serviceWClient(cid).then((res) => res.data), API_SETTING.uniAll().then((res) => res.data), API_SETTING.companyGet().then((res) => res.data), API_SETTING.logo().then((res) => res.data),