selected default current selected service - create task

This commit is contained in:
pramod.mahajan 2025-12-10 16:52:52 +05:30
parent b62fc82a9c
commit 8033fdb7e7
2 changed files with 39 additions and 26 deletions

View File

@ -8,7 +8,7 @@ import {
useGroups,
useWorkCategoriesMaster,
} from "../../../hooks/masterHook/useMaster";
import { useManageTask, useProjectAssignedOrganizationsName, useProjectAssignedServices } from "../../../hooks/useProjects";
import { useCurrentService, useManageTask, useProjectAssignedOrganizationsName, useProjectAssignedServices } from "../../../hooks/useProjects";
import showToast from "../../../services/toastService";
import Label from "../../common/Label";
import { useSelectedProject } from "../../../slices/apiDataManager";
@ -28,12 +28,16 @@ const taskSchema = z.object({
comment: z.string(),
});
const defaultModel = {
const TaskModel = ({ project, onSubmit, onClose }) => {
const currentService = useCurrentService()
const defaultModel = {
id: null,
buildingID: "",
floorId: "",
workAreaId: "",
serviceId: "",
serviceId: currentService ?? "",
activityGroupId: "",
activityID: "",
workCategoryId: "",
@ -41,8 +45,6 @@ const defaultModel = {
completedWork: 0,
comment: "",
};
const TaskModel = ({ project, onSubmit, onClose }) => {
// const { activities, loading: activityLoading } = useActivitiesMaster();
const { categories, categoryLoading } = useWorkCategoriesMaster();

View File

@ -1,4 +1,10 @@
import React, { createContext, useContext, useEffect, useRef, useState } from "react";
import React, {
createContext,
useContext,
useEffect,
useRef,
useState,
} from "react";
import Breadcrumb from "../../components/common/Breadcrumb";
import {
ITEMS_PER_PAGE,
@ -68,7 +74,7 @@ const ProjectPage = () => {
const handleToggleProject = (value) => {
setCoreProjects(value);
sessionStorage.setItem("whichProjectDisplay", String(value));
sessionStorage.setItem("whichProjectDisplay", value ? "true" : "false");
};
useEffect(() => {
@ -100,8 +106,9 @@ const ProjectPage = () => {
{/* Service Project Button */}
<button
type="button"
className={`btn px-2 py-1 rounded-0 text-tiny ${!coreProjects ? "btn-primary text-white" : ""
}`}
className={`btn px-2 py-1 rounded-0 text-tiny ${
!coreProjects ? "btn-primary text-white" : ""
}`}
onClick={() => handleToggleProject(false)}
>
Service Project
@ -109,8 +116,9 @@ const ProjectPage = () => {
{/* Organization Project Button */}
<button
type="button"
className={`btn px-2 py-1 rounded-0 text-tiny ${coreProjects ? "btn-primary text-white" : ""
}`}
className={`btn px-2 py-1 rounded-0 text-tiny ${
coreProjects ? "btn-primary text-white" : ""
}`}
onClick={() => handleToggleProject(true)}
>
Infra Project
@ -138,8 +146,9 @@ const ProjectPage = () => {
<div className="d-flex gap-2">
<button
type="button"
className={`btn btn-sm p-1 ${!listView ? "btn-primary" : "btn-outline-primary"
}`}
className={`btn btn-sm p-1 ${
!listView ? "btn-primary" : "btn-outline-primary"
}`}
onClick={() => setListView(false)}
title="Card View"
>
@ -148,8 +157,9 @@ const ProjectPage = () => {
<button
type="button"
className={`btn btn-sm p-1 ${listView ? "btn-primary" : "btn-outline-primary"
}`}
className={`btn btn-sm p-1 ${
listView ? "btn-primary" : "btn-outline-primary"
}`}
onClick={() => setListView(true)}
title="List View"
>
@ -164,12 +174,16 @@ const ProjectPage = () => {
onClick={() => setOpen(!open)}
>
<i
className={`bx bx-slider-alt fs-5 ${selectedStatuses.length !== PROJECT_STATUS.length ? "text-primary" : ""
}`}
className={`bx bx-slider-alt fs-5 ${
selectedStatuses.length !== PROJECT_STATUS.length
? "text-primary"
: ""
}`}
></i>
{selectedStatuses.length !== PROJECT_STATUS.length && (
<span className="badge bg-warning text-white rounded-pill position-absolute"
<span
className="badge bg-warning text-white rounded-pill position-absolute"
style={{
top: "-4px",
right: "-4px",
@ -186,7 +200,7 @@ const ProjectPage = () => {
<ul
ref={dropdownRef}
className="dropdown-menu show p-2 text-capitalize"
onMouseDown={(e) => e.stopPropagation()} // IMPORTANT
onMouseDown={(e) => e.stopPropagation()} // IMPORTANT
>
{PROJECT_STATUS.map(({ id, label }) => (
<li key={id}>
@ -200,7 +214,7 @@ const ProjectPage = () => {
/>
<label
className="form-check-label"
onClick={(e) => e.stopPropagation()} // OPTIONAL
onClick={(e) => e.stopPropagation()} // OPTIONAL
>
{label}
</label>
@ -211,9 +225,6 @@ const ProjectPage = () => {
)}
</div>
{HasManageProject && (
<button
type="button"
@ -223,9 +234,9 @@ const ProjectPage = () => {
coreProjects
? setMangeProject({ isOpen: true, Project: null }) // Organization Project Infra
: setManageServiceProject({
isOpen: true,
Project: null,
}) // Service Project
isOpen: true,
Project: null,
}) // Service Project
}
>
<i className="bx bx-plus-circle me-2"></i>