From 44f3d8783d5d6ebc193b55e4fdd14e3b26883afa Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 09:54:02 +0530 Subject: [PATCH 01/16] Adding additional fields in landing subscription cards. --- src/pages/Home/SubscriptionPlans.jsx | 93 +++++++++++++++++++++------- 1 file changed, 72 insertions(+), 21 deletions(-) diff --git a/src/pages/Home/SubscriptionPlans.jsx b/src/pages/Home/SubscriptionPlans.jsx index 59ef4a7e..6c47826b 100644 --- a/src/pages/Home/SubscriptionPlans.jsx +++ b/src/pages/Home/SubscriptionPlans.jsx @@ -9,7 +9,7 @@ const SubscriptionPlans = () => { const [frequency, setFrequency] = useState(1); const { data, isLoading, isError, error } = useSubscription(frequency); const [loading, setLoading] = useState(false); - + console.log(data); const frequencyLabel = (freq) => { switch (freq) { case 0: @@ -35,9 +35,8 @@ const SubscriptionPlans = () => { + + +
+
+ {mod.features && mod.features.length > 0 ? ( +
    + {mod.features.map((feat) => ( +
  • + + + {feat.name} +
  • + ))} +
+ ) : ( +

+ No additional features +

+ )} +
+
+ + ); + })} + + + {/* Button */}
From 630c11985de1ff108604e1ddc6338e8f21587f14 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 11:18:11 +0530 Subject: [PATCH 02/16] Correction in Subscription page. --- .../Project/Team/TeamAssignToProject.jsx | 76 ++++++------- src/pages/Home/SubscriptionPlans.jsx | 102 ++++++++---------- 2 files changed, 81 insertions(+), 97 deletions(-) diff --git a/src/components/Project/Team/TeamAssignToProject.jsx b/src/components/Project/Team/TeamAssignToProject.jsx index 9c99333a..45673f9d 100644 --- a/src/components/Project/Team/TeamAssignToProject.jsx +++ b/src/components/Project/Team/TeamAssignToProject.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import TeamEmployeeList from "./TeamEmployeeList"; import { useOrganization } from "../../../hooks/useDirectory"; import { useOrganizationsList } from "../../../hooks/useOrganization"; @@ -14,56 +14,48 @@ const TeamAssignToProject = ({ closeModal }) => { const project = useSelectedProject(); const { data, isLoading, isError, error } = useProjectAssignedOrganizationsName(project); - const { control, watch, formState: { errors } } = useForm({ + const { control, watch, setValue, formState: { errors } } = useForm({ defaultValues: { organizationId: "" }, }); + + useEffect(() => { + if (data?.length === 1) { + setValue("organizationId", data[0].id, { + shouldValidate: true, + shouldDirty: true, + }); + } + }, [data, setValue]); + return (
{/*

Assign Employee To Project

*/}
Assign Employee To Project
-
- - {!isLoading && data && ( - <> - {data.length === 1 && ( -
{data[0].name}
- )} - - {/* If multiple organizations → show dropdown */} - {data.length > 1 && ( -
- ( - - )} - /> - {errors.organizationId && ( - - {errors.organizationId.message} - - )} -
- )} - +
+ ( + + )} + /> + {errors.organizationId && ( + {errors.organizationId.message} )} - {/*
*/} -
diff --git a/src/pages/Home/SubscriptionPlans.jsx b/src/pages/Home/SubscriptionPlans.jsx index 6c47826b..f6357ff3 100644 --- a/src/pages/Home/SubscriptionPlans.jsx +++ b/src/pages/Home/SubscriptionPlans.jsx @@ -108,64 +108,56 @@ const SubscriptionPlans = () => { if (!mod || !mod.name) return null; return ( -
-

- -

+ + + -
-
- {mod.features && mod.features.length > 0 ? ( -
    - {mod.features.map((feat) => ( -
  • - +
    +
    + {mod.features?.length > 0 ? ( +
      + {mod.features.map((feat) => ( +
    • + + {feat.name} +
    • + ))} +
    + ) : ( +

    No additional features

    + )} +
    +
    +
- {feat.name} - - ))} - - ) : ( -

- No additional features -

- )} -
-
-
); })}
From e695807e77fb47d24776b48193ecc2e7ab449ba3 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 11:18:45 +0530 Subject: [PATCH 03/16] Adding --- src/pages/Home/SubscriptionPlans.jsx | 91 ++++++++++++++-------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/src/pages/Home/SubscriptionPlans.jsx b/src/pages/Home/SubscriptionPlans.jsx index f6357ff3..8637e121 100644 --- a/src/pages/Home/SubscriptionPlans.jsx +++ b/src/pages/Home/SubscriptionPlans.jsx @@ -109,54 +109,53 @@ const SubscriptionPlans = () => { return (
-

- -

+ + + -
-
- {mod.features?.length > 0 ? ( -
    - {mod.features.map((feat) => ( -
  • - - {feat.name} -
  • - ))} -
- ) : ( -

No additional features

- )} -
-
-
+
+
+ {mod.features?.length > 0 ? ( +
    + {mod.features.map((feat) => ( +
  • + + {feat.name} +
  • + ))} +
+ ) : ( +

No additional features

+ )} +
+
+
); })} From 3ff80ee0320d41b766b57cffc981233caaae85ae Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 11:20:16 +0530 Subject: [PATCH 04/16] Sorting in Subscription page. --- src/pages/Home/SubscriptionPlans.jsx | 99 ++++++++++++++-------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/src/pages/Home/SubscriptionPlans.jsx b/src/pages/Home/SubscriptionPlans.jsx index 8637e121..cdf33454 100644 --- a/src/pages/Home/SubscriptionPlans.jsx +++ b/src/pages/Home/SubscriptionPlans.jsx @@ -104,61 +104,64 @@ const SubscriptionPlans = () => {
{plan.features?.modules && - Object.entries(plan.features.modules).map(([key, mod]) => { - if (!mod || !mod.name) return null; + Object.entries(plan.features.modules) + .sort(([, a], [, b]) => Number(b.enabled) - Number(a.enabled)) + .map(([key, mod]) => { - return ( -
-

- +

+ +
- - {mod.enabled ? ( - +
+ {mod.features?.length > 0 ? ( +
    + {mod.features.map((feat) => ( +
  • + + {feat.name} +
  • + ))} +
) : ( - +

No additional features

)} - {mod.name} - - - - - - -
-
- {mod.features?.length > 0 ? ( -
    - {mod.features.map((feat) => ( -
  • - - {feat.name} -
  • - ))} -
- ) : ( -

No additional features

- )} +
-
- ); - })} + ); + })}
From a9bbd75d6c5d84c18c00009b7856e4c53b0e0d7a Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 11:26:50 +0530 Subject: [PATCH 05/16] Correction in name of Project by status to Attendance by Project --- src/components/Dashboard/ProjectWiseTeamCount.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Dashboard/ProjectWiseTeamCount.jsx b/src/components/Dashboard/ProjectWiseTeamCount.jsx index 3e5abb8f..a7928fb6 100644 --- a/src/components/Dashboard/ProjectWiseTeamCount.jsx +++ b/src/components/Dashboard/ProjectWiseTeamCount.jsx @@ -33,7 +33,7 @@ const ProjectWiseTeamCount = () => {
{/* Header */}
-
Project wise Employee
+
Attendance by Project
From fa694d83614cdd6dd6b17f3eabc859f1d77ff020 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 11:37:53 +0530 Subject: [PATCH 06/16] Correction in Attendance page. --- src/pages/Activities/AttendancePage.jsx | 90 +++++++++++-------------- 1 file changed, 38 insertions(+), 52 deletions(-) diff --git a/src/pages/Activities/AttendancePage.jsx b/src/pages/Activities/AttendancePage.jsx index 23e8b75a..0e3af802 100644 --- a/src/pages/Activities/AttendancePage.jsx +++ b/src/pages/Activities/AttendancePage.jsx @@ -136,6 +136,15 @@ const AttendancePage = () => { : []), ]; // --- END: Tab Configuration Array + useEffect(() => { + if (!orgLoading && organizations?.length === 1) { + setAppliedFilters((prev) => ({ + ...prev, + selectedOrganization: organizations[0].id, + })); + } + }, [orgLoading, organizations]); + return ( <> @@ -173,19 +182,21 @@ const AttendancePage = () => { {/* Tabs header with search and filter */}
- - {/* Tabs Buttons - Now col-12 col-md-6 */} -
+ {/* Tabs Buttons */} +
    {tabsData.map((tab) => (
- {/* Search + Organization Filter - Now col-12 col-md-6 */} -
-
- - {/* Organization */} + {/* Search + Organization filter */} +
+
- - {/* If only 1 organization → show name only */} - {!orgLoading && organizations?.length === 1 && ( -
{organizations[0].name}
- )} - - {/* If multiple organizations → show dropdown */} - {!orgLoading && organizations?.length > 1 && ( - - )} - - {/* Loading case (optional) */} - {orgLoading && ( -
- Loading... -
- )} - +
- - - {/* Search */}
{ onChange={(e) => setSearchTerm(e.target.value)} />
-
-
- {/* Tab Content */}
{selectedProject ? ( From a309d13247c0362bf97dc3fa12efbceaf231a9e6 Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 11:51:16 +0530 Subject: [PATCH 07/16] Correction in teams, projectinfra and daily task for dropdown. --- src/components/Project/ProjectInfra.jsx | 62 +++++++++------ src/components/Project/Team/Teams.jsx | 61 +++++++------- src/pages/Activities/TaskPlannng.jsx | 67 ++++++++-------- .../DailyProgrssReport.jsx | 79 ++++++++++--------- 4 files changed, 145 insertions(+), 124 deletions(-) diff --git a/src/components/Project/ProjectInfra.jsx b/src/components/Project/ProjectInfra.jsx index cd817a77..2c1c4749 100644 --- a/src/components/Project/ProjectInfra.jsx +++ b/src/components/Project/ProjectInfra.jsx @@ -55,7 +55,7 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => { const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId); - const { control } = useForm({ + const { control, setValue } = useForm({ defaultValues: { serviceId: selectedService || "", }, @@ -74,6 +74,22 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => { }; + useEffect(() => { + if (!servicesLoading && assignedServices?.length === 1) { + const serviceId = assignedServices[0].id; + + // set form value + setValue("serviceId", serviceId, { + shouldDirty: true, + shouldValidate: true, + }); + + // sync redux + dispatch(setService(serviceId)); + } + }, [assignedServices, servicesLoading, setValue, dispatch]); + + return ( <> {showModalBuilding && ( @@ -132,31 +148,27 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
{!servicesLoading && assignedServices?.length > 0 && ( - assignedServices.length > 1 ? ( - ( - { - field.onChange(val); - handleServiceChange(val); - }} - isLoading={servicesLoading} - /> - )} - /> - ) : ( -
{assignedServices[0].name}
- ) + ( + { + field.onChange(val); + dispatch(setService(val)); + }} + isLoading={servicesLoading} + /> + )} + /> )} +
diff --git a/src/components/Project/Team/Teams.jsx b/src/components/Project/Team/Teams.jsx index ff919a69..e91a5dbf 100644 --- a/src/components/Project/Team/Teams.jsx +++ b/src/components/Project/Team/Teams.jsx @@ -34,7 +34,7 @@ const Teams = () => { const [selectedEmployee, setSelectedEmployee] = useState(null); const [deleteEmployee, setDeleteEmplyee] = useState(null); const [activeEmployee, setActiveEmployee] = useState(false); - const { control, watch } = useForm({ + const { control, watch, setValue } = useForm({ defaultValues: { selectedService: "", searchTerm: "", @@ -136,6 +136,18 @@ const Teams = () => { return () => eventBus.off("employee", employeeHandler); }, [employeeHandler]); + useEffect(() => { + if (!servicesLoading && assignedServices?.length === 1) { + const serviceId = assignedServices[0].id; + + setValue("selectedService", serviceId, { + shouldDirty: true, + shouldValidate: true, + }); + } + }, [assignedServices, servicesLoading, setValue]); + + return ( <> {AssigTeam && ( @@ -162,37 +174,30 @@ const Teams = () => {
- {!servicesLoading && assignedServices && ( - <> - {assignedServices.length === 1 && ( -
{assignedServices[0].name}
- )} - - {assignedServices.length > 1 && ( -
- ( - - )} + {!servicesLoading && assignedServices?.length > 0 && ( +
+ ( + -
- )} - + )} + /> +
)} +
{ const selectedProject = useSelectedProject(); const selectedService = useCurrentService(); const dispatch = useDispatch(); - const { control } = useForm({ + const { control,setValue } = useForm({ defaultValues: { serviceFilter: selectedService ?? "" }, @@ -39,6 +39,20 @@ const TaskPlanning = () => { return
Loading...
; } + useEffect(() => { + if (!servicesLoading && data?.length === 1) { + const serviceId = data[0].id; + + setValue("serviceFilter", serviceId, { + shouldValidate: true, + shouldDirty: true, + }); + + dispatch(setService(serviceId)); + } + }, [servicesLoading, data, setValue, dispatch]); + + return (
{ />
-
- - {/* When no services available */} +
{data?.length === 0 ? (

) : ( - <> - {/* When exactly 1 service assigned → display heading */} - {data?.length === 1 && ( -
{data[0].name}
- )} - - {/* When multiple services → show dropdown */} - {data?.length > 1 && ( - ( - { - field.onChange(val); - dispatch(setService(val)); - }} - className="m-0" - /> - )} + ( + { + field.onChange(val); + dispatch(setService(val)); + }} + className="m-0" /> )} - + /> )} -
diff --git a/src/pages/DailyProgressReport/DailyProgrssReport.jsx b/src/pages/DailyProgressReport/DailyProgrssReport.jsx index 258e0d2f..8f4f2e4a 100644 --- a/src/pages/DailyProgressReport/DailyProgrssReport.jsx +++ b/src/pages/DailyProgressReport/DailyProgrssReport.jsx @@ -46,7 +46,7 @@ const DailyProgrssReport = () => { filter, }; - const { control } = useForm({ + const { control,setValue } = useForm({ defaultValues: { serviceFilter: "" } @@ -85,6 +85,22 @@ const DailyProgrssReport = () => { return updated; }); }; + + useEffect(() => { + if (!isLoading && data?.length === 1) { + const serviceId = data[0].id; + + // set form value + setValue("serviceFilter", serviceId, { + shouldDirty: true, + shouldValidate: true, + }); + + // set local state + setService(serviceId); + } + }, [isLoading, data, setValue]); + return (
@@ -120,44 +136,31 @@ const DailyProgrssReport = () => { />
-
- {/* Service Heading or Dropdown */} - {!isLoading && data && ( - <> - {/* If only 1 service assigned → show heading */} - {data.length === 1 && ( -
{data[0].name}
+ {data?.length > 0 && ( +
+ ( + { + field.onChange(val); + setService(val); + }} + className="m-0" + /> )} - - {/* If multiple services → show dropdown */} - {data.length > 1 && ( -
- ( - { - field.onChange(val); - setService(val); - }} - className="w-100" - /> - )} - /> -
- )} - - )} -
+ /> +
+ )}
Date: Sat, 13 Dec 2025 14:51:17 +0530 Subject: [PATCH 08/16] Change the design of subscription page. --- src/pages/Home/SubscriptionPlans.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/Home/SubscriptionPlans.jsx b/src/pages/Home/SubscriptionPlans.jsx index cdf33454..6f62eba3 100644 --- a/src/pages/Home/SubscriptionPlans.jsx +++ b/src/pages/Home/SubscriptionPlans.jsx @@ -9,6 +9,7 @@ const SubscriptionPlans = () => { const [frequency, setFrequency] = useState(1); const { data, isLoading, isError, error } = useSubscription(frequency); const [loading, setLoading] = useState(false); + const [isOpen, setIsOpen] = useState(true); console.log(data); const frequencyLabel = (freq) => { switch (freq) { @@ -63,7 +64,7 @@ const SubscriptionPlans = () => {

{error.name}

) : ( - data.map((plan) => ( + data.map((plan, index) => (
{/* Header */} @@ -109,6 +110,7 @@ const SubscriptionPlans = () => { .map(([key, mod]) => { if (!mod || !mod.name) return null; + const isFirst = index === 0; return (
@@ -118,7 +120,7 @@ const SubscriptionPlans = () => { type="button" data-bs-toggle="collapse" data-bs-target={`#collapse-${plan.id}-${mod.id}`} - aria-expanded="true" + aria-expanded={`${isFirst ? "true" : "false"}`} aria-controls={`collapse-${plan.id}-${mod.id}`} > @@ -136,7 +138,7 @@ const SubscriptionPlans = () => {
@@ -164,8 +166,6 @@ const SubscriptionPlans = () => { })}
- - {/* Button */}
{
+ )) )}
From e8886577d888c29e75364fbbcb1d4aab453a55dd Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Sat, 13 Dec 2025 16:36:47 +0530 Subject: [PATCH 09/16] Correction in weidget. --- src/components/Dashboard/ServiceJobs.jsx | 112 +++++++++++++------- src/components/reports/ReportsDonutCard.jsx | 7 +- src/components/reports/ReportsLegend.jsx | 11 +- src/components/reports/report-dpr.jsx | 6 ++ 4 files changed, 86 insertions(+), 50 deletions(-) diff --git a/src/components/Dashboard/ServiceJobs.jsx b/src/components/Dashboard/ServiceJobs.jsx index d69a2faa..35ee2365 100644 --- a/src/components/Dashboard/ServiceJobs.jsx +++ b/src/components/Dashboard/ServiceJobs.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect, useRef, useState } from "react"; import { useParams } from "react-router-dom"; import { useJobsProgression } from "../../hooks/useDashboard_Data"; import { SpinnerLoader } from "../common/Loader"; @@ -7,55 +7,90 @@ import { useServiceProject } from "../../hooks/useServiceProject"; const ServiceJobs = () => { const { projectId } = useParams(); + const { data, isLoading, isError } = useJobsProgression(projectId); const jobs = data || {}; - const { data: projectData, isLoading: projectLoading } = useServiceProject(projectId); + + const { data: projectData, isLoading: projectLoading } = + useServiceProject(projectId); + + const [activeTab, setActiveTab] = useState("tab-new"); + + // 👇 prevents re-running auto logic after first load + const hasInitializedTab = useRef(false); + const tabMapping = [ { id: "tab-new", label: "My Jobs", key: "myJobs" }, - { id: "tab-preparing", label: "Assigned", key: "assignedJobs" }, { id: "tab-shipping", label: "In Progress", key: "inProgressJobs" }, + { id: "tab-preparing", label: "Assigned", key: "assignedJobs" }, ]; + /* ---------- INITIAL TAB SELECTION ONLY ---------- */ + useEffect(() => { + if (hasInitializedTab.current || !jobs) return; + + if (jobs.myJobs?.length > 0) { + setActiveTab("tab-new"); + } else if (jobs.inProgressJobs?.length > 0) { + setActiveTab("tab-shipping"); + } else { + setActiveTab("tab-preparing"); + } + + hasInitializedTab.current = true; +}, [jobs]); + + return ( -
+
+ {/* Header */}
Service Jobs

- {projectLoading ? "Loading..." : projectData?.name || "All Projects"} + {projectLoading + ? "Loading..." + : projectData?.name || "All Projects"}

- - {/* ---------------- Tabs ---------------- */} -