diff --git a/src/components/PaymentRequest/ActionPaymentRequest.jsx b/src/components/PaymentRequest/ActionPaymentRequest.jsx index 5f3cc1d9..52222b55 100644 --- a/src/components/PaymentRequest/ActionPaymentRequest.jsx +++ b/src/components/PaymentRequest/ActionPaymentRequest.jsx @@ -40,7 +40,6 @@ const ActionPaymentRequest = ({ requestId }) => { error: PaymentModeError, } = usePaymentMode(); - console.log("Kartik", data) const IsReview = useHasUserPermission(REVIEW_EXPENSE); const [imageLoaded, setImageLoaded] = useState({}); diff --git a/src/components/Project/Infrastructure/EditActivityModal.jsx b/src/components/Project/Infrastructure/EditActivityModal.jsx index e57b6a30..14e66020 100644 --- a/src/components/Project/Infrastructure/EditActivityModal.jsx +++ b/src/components/Project/Infrastructure/EditActivityModal.jsx @@ -82,7 +82,6 @@ const EditActivityModal = ({ useEffect(() => { if (!workItem) return; - console.log(workItem) reset({ activityID: String( workItem?.workItem?.activityId || workItem?.activityMaster?.id diff --git a/src/components/ServiceProject/BranchSchema.js b/src/components/ServiceProject/BranchSchema.js deleted file mode 100644 index 346654d3..00000000 --- a/src/components/ServiceProject/BranchSchema.js +++ /dev/null @@ -1,43 +0,0 @@ -import { z } from "zod"; - -export const BranchSchema = () => - z.object({ - projectId: z - .string() - .trim() - .min(1, { message: "Project is required" }), - - branchName: z - .string() - .trim() - .min(1, { message: "Branch Name is required" }), - - contactInformation: z - .string() - .trim() - .min(1, { message: "Contact Information is required" }), - - address: z - .string() - .trim() - .min(1, { message: "Address is required" }), - - branchType: z - .string() - .trim() - .min(1, { message: "Branch Type is required" }), - - googleMapUrl: z - .string() - .trim() - .url({ message: "Enter a valid Google Map URL" }), - }); - -export const defaultBranches = { - branchName: "", - projectId: "", - contactInformation: "", - address: "", - branchType: "", - googleMapUrl: "", -}; \ No newline at end of file diff --git a/src/components/ServiceProject/ManageBranch.jsx b/src/components/ServiceProject/ManageBranch.jsx deleted file mode 100644 index 70257710..00000000 --- a/src/components/ServiceProject/ManageBranch.jsx +++ /dev/null @@ -1,186 +0,0 @@ -import React, { useEffect } from 'react' -import { useProjectName } from '../../hooks/useProjects'; -import { BranchSchema, defaultBranches } from './BranchSchema'; -import { useForm } from 'react-hook-form'; -import { zodResolver } from '@hookform/resolvers/zod'; -import Label from '../common/Label'; -import { useCreateBranch, useServiceProjects, useUpdateBranch } from '../../hooks/useServiceProject'; -import { useAppForm } from '../../hooks/appHooks/useAppForm'; -import { useParams } from 'react-router-dom'; - -const ManageBranch = ({ closeModal, BranchToEdit = null }) => { - const { data } = {} - const { projectId } = useParams(); - const schema = BranchSchema(); - const { - register, - control, - watch, - handleSubmit, - setValue, - reset, - formState: { errors }, - } = useAppForm({ - resolver: zodResolver(schema), - defaultValues: { - ...defaultBranches, - projectId: projectId || "" - }, - }); - - const handleClose = () => { - reset(); - closeModal(); - }; - - useEffect(() => { - if (BranchToEdit && data) { - reset({ - branchName: data.branchName || "", - projectId: data.project?.id || projectId || "", - contactInformation: data.contactInformation || "", - address: data.address || "", - branchType: data.branchType || "", - googleMapUrl: data.googleMapUrl || "", - }); - } - }, [data, reset]); - - const { mutate: CreateServiceBranch, isPending: createPending } = - useCreateBranch(() => { - handleClose(); - }); - const { mutate: ServiceBranchUpdate, isPending } = - useUpdateBranch(() => handleClose()); - - const onSubmit = (fromdata) => { - let payload = { - ...fromdata, projectId, - }; - if (BranchToEdit) { - const editPayload = { ...payload, id: data.id }; - ServiceBranchUpdate({ id: data.id, payload: editPayload }); - } else { - CreateServiceBranch(payload); - } - }; - - return ( -
-
- {BranchToEdit - ? "Update Branch" - : "Create Branch"} -
-
-
- -
- - - {errors.branchName && ( - {errors.branchName.message} - )} -
-
- - - {errors.contactInformation && ( - {errors.contactInformation.message} - )} -
-
- -
- - -
- - - {errors.address && ( - {errors.address.message} - )} -
-
- - - {errors.branchType && ( - {errors.branchType.message} - )} -
-
- - -
- - -
- - - {errors.googleMapUrl && ( - {errors.googleMapUrl.message} - )} -
-
- -
- - - -
- - - -
-
- ) -} - -export default ManageBranch diff --git a/src/components/ServiceProject/ManageJob.jsx b/src/components/ServiceProject/ManageJob.jsx index 97cd1a97..6ec96e3b 100644 --- a/src/components/ServiceProject/ManageJob.jsx +++ b/src/components/ServiceProject/ManageJob.jsx @@ -41,7 +41,8 @@ const ManageJob = ({ Job }) => { control, watch, handleSubmit, - reset,setValue, + reset, + setValue, formState: { errors }, } = methods; @@ -164,6 +165,7 @@ const ManageJob = ({ Job }) => { dueDate: JobData.dueDate ?? null, tags: JobData.tags ?? [], statusId: JobData.status.id, + branchId : JobData?.projectBranch?.id }); }, [JobData, Job, projectId]); return ( @@ -201,7 +203,7 @@ const ManageJob = ({ Job }) => { />
- + { name="tags" label="Tag" placeholder="Enter Tag" - />
setValue("branchId", val)} valueKey="id" labelKey="branchName" - hookParams={[projectId,true,10,1]} + hookParams={[projectId, true, 10, 1]} useFetchHook={useBranches} isMultiple={false} + disabled={Job} />
diff --git a/src/components/ServiceProject/ManageJobTicket.jsx b/src/components/ServiceProject/ManageJobTicket.jsx index 9dbf0b9f..c589509c 100644 --- a/src/components/ServiceProject/ManageJobTicket.jsx +++ b/src/components/ServiceProject/ManageJobTicket.jsx @@ -124,10 +124,16 @@ const ManageJobTicket = ({ Job }) => { ); })()}
+
+ + {" "} + Branch Name : + +
- Created By + Created By
{ {data?.assignees?.length > 0 && (
- Assigned To + Assigned To
diff --git a/src/components/ServiceProject/ServiceBranch.jsx b/src/components/ServiceProject/ServiceBranch.jsx deleted file mode 100644 index fc0bf1ac..00000000 --- a/src/components/ServiceProject/ServiceBranch.jsx +++ /dev/null @@ -1,162 +0,0 @@ -import React, { useState } from 'react' -import GlobalModel from '../common/GlobalModel'; -import ManageBranch from './ManageBranch'; -import { Pagination } from 'swiper/modules'; -import { useBranches } from '../../hooks/useServiceProject'; -import { ITEMS_PER_PAGE } from '../../utils/constants'; -import { useDebounce } from '../../utils/appUtils'; -import { useParams } from 'react-router-dom'; - -const ServiceBranch = () => { - - const [ManageServiceBranch, setManageServiceBranch] = useState({ - IsOpen: null, - branchId: null, - }); - - const { projectId } = useParams(); - - const [search, setSearch] = useState(""); - const [currentPage, setCurrentPage] = useState(1); - const debouncedSearch = useDebounce(search, 500); - - const { data, isLoading, isError, error } = useBranches( - projectId, - true, - ITEMS_PER_PAGE, - currentPage, - debouncedSearch, - ); - const paginate = (page) => { - if (page >= 1 && page <= (data?.totalPages ?? 1)) { - setCurrentPage(page); - } - }; - - const ServiceBranch = [ - { - key: "branchName", - label: "Branch Name", - align: "text-start", - getValue: (e) => e?.branchName || "N/A", - }, - ]; - return ( -
-
-
-
- -
-
- - -
- {/* {Array.isArray(filteredData) && filteredData.length > 0 && ( */} - - - - {ServiceBranch.map((col) => ( - - ))} - - - - - {isLoading ? ( - - - - ) : isError ? ( - - - - ) : data?.data?.length > 0 ? ( - data.data.map((branch) => ( - - {ServiceBranch.map((col) => ( - - ))} - - - )) - ) : ( - - - - )} - -
- {col.label} - Action
- Loading... -
- {error?.message || "Error loading branches"} -
- {col.getValue(branch)} - - - setManageServiceBranch({ - IsOpen: true, - branchId: branch.id, - }) - } - /> -
- No Branch Found -
- {/* )} */} - {/* {!filteredData || - filteredData.length === 0 - && ( -
- {isError ? (

{error.message}

) : (

No Recurring Expense Found

)} -
- )} */} -
- - {ManageServiceBranch.IsOpen && ( - - setManageServiceBranch({ IsOpen: null, branchId: null }) - } - > - - setManageServiceBranch({ IsOpen: null, branchId: null }) - } - // requestToEdit={ManageServiceBranch.branchId} - /> - - )} - - {/* */} -
-
- ) -} - -export default ServiceBranch diff --git a/src/components/ServiceProject/ServiceProfile.jsx b/src/components/ServiceProject/ServiceProfile.jsx new file mode 100644 index 00000000..30864106 --- /dev/null +++ b/src/components/ServiceProject/ServiceProfile.jsx @@ -0,0 +1,95 @@ +import React from 'react' +import { formatUTCToLocalTime } from '../../utils/dateUtils' + +const ServiceProfile = ({data,setIsOpenModal}) => { + return ( +
+
+
+ {" "} + + Project Profile +
+
+
+
    + +
  • +
    + + Name: +
    + +
    + {data.name} +
    +
  • +
  • +
    + + Nick Name: +
    + {data.shortName} +
  • +
  • +
    + + Assign Date: +
    + + {data.assignedDate ? formatUTCToLocalTime(data.assignedDate) : "NA"} + +
  • + +
  • +
    + + Status: +
    + {data?.status.status} +
  • +
  • +
    + + Contact: +
    + {data.contactName} +
  • +
  • + {/* Label section with icon */} +
    + + Address: +
    + + {/* Content section that wraps nicely */} +
    + {data.address} +
    +
  • + + + +
  • + + + + + +
  • +
+ +
+
+ ) +} + +export default ServiceProfile diff --git a/src/components/ServiceProject/ServiceProjectBranch/ManageBranch.jsx b/src/components/ServiceProject/ServiceProjectBranch/ManageBranch.jsx new file mode 100644 index 00000000..34cc0530 --- /dev/null +++ b/src/components/ServiceProject/ServiceProjectBranch/ManageBranch.jsx @@ -0,0 +1,183 @@ +import React, { useEffect } from "react"; +import { useProjectName } from "../../../hooks/useProjects"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import Label from "../../common/Label"; +import { + useCreateBranch, + useServiceProjects, + useUpdateBranch, +} from "../../../hooks/useServiceProject"; +import { useAppForm } from "../../../hooks/appHooks/useAppForm"; +import { useParams } from "react-router-dom"; +import { BranchSchema, defaultBranches } from "../ServiceProjectSchema"; + +const ManageBranch = ({ closeModal, BranchToEdit = null }) => { + const { data } = {}; + const { projectId } = useParams(); + const schema = BranchSchema(); + const { + register, + control, + watch, + handleSubmit, + setValue, + reset, + formState: { errors }, + } = useAppForm({ + resolver: zodResolver(schema), + defaultValues: { + ...defaultBranches, + projectId: projectId || "", + }, + }); + + const handleClose = () => { + reset(); + closeModal(); + }; + + useEffect(() => { + if (BranchToEdit && data) { + reset({ + branchName: data.branchName || "", + projectId: data.project?.id || projectId || "", + contactInformation: data.contactInformation || "", + address: data.address || "", + branchType: data.branchType || "", + googleMapUrl: data.googleMapUrl || "", + }); + } + }, [data, reset]); + + const { mutate: CreateServiceBranch, isPending: createPending } = + useCreateBranch(() => { + handleClose(); + }); + const { mutate: ServiceBranchUpdate, isPending } = useUpdateBranch(() => + handleClose() + ); + + const onSubmit = (fromdata) => { + let payload = { + ...fromdata, + projectId, + }; + if (BranchToEdit) { + const editPayload = { ...payload, id: data.id }; + ServiceBranchUpdate({ id: data.id, payload: editPayload }); + } else { + CreateServiceBranch(payload); + } + }; + + return ( +
+
+ {BranchToEdit ? "Update Branch" : "Create Branch"} +
+
+
+
+ + + {errors.branchName && ( + {errors.branchName.message} + )} +
+
+ + + {errors.contactInformation && ( + + {errors.contactInformation.message} + + )} +
+
+ +
+ +
+ + + {errors.branchType && ( + {errors.branchType.message} + )} +
+
+ + + {errors.googleMapUrl && ( + + {errors.googleMapUrl.message} + + )} +
+
+ +
+ +
+ +