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, useGroups,
useWorkCategoriesMaster, useWorkCategoriesMaster,
} from "../../../hooks/masterHook/useMaster"; } 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 showToast from "../../../services/toastService";
import Label from "../../common/Label"; import Label from "../../common/Label";
import { useSelectedProject } from "../../../slices/apiDataManager"; import { useSelectedProject } from "../../../slices/apiDataManager";
@ -28,12 +28,16 @@ const taskSchema = z.object({
comment: z.string(), comment: z.string(),
}); });
const defaultModel = {
const TaskModel = ({ project, onSubmit, onClose }) => {
const currentService = useCurrentService()
const defaultModel = {
id: null, id: null,
buildingID: "", buildingID: "",
floorId: "", floorId: "",
workAreaId: "", workAreaId: "",
serviceId: "", serviceId: currentService ?? "",
activityGroupId: "", activityGroupId: "",
activityID: "", activityID: "",
workCategoryId: "", workCategoryId: "",
@ -41,8 +45,6 @@ const defaultModel = {
completedWork: 0, completedWork: 0,
comment: "", comment: "",
}; };
const TaskModel = ({ project, onSubmit, onClose }) => {
// const { activities, loading: activityLoading } = useActivitiesMaster(); // const { activities, loading: activityLoading } = useActivitiesMaster();
const { categories, categoryLoading } = useWorkCategoriesMaster(); 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 Breadcrumb from "../../components/common/Breadcrumb";
import { import {
ITEMS_PER_PAGE, ITEMS_PER_PAGE,
@ -68,7 +74,7 @@ const ProjectPage = () => {
const handleToggleProject = (value) => { const handleToggleProject = (value) => {
setCoreProjects(value); setCoreProjects(value);
sessionStorage.setItem("whichProjectDisplay", String(value)); sessionStorage.setItem("whichProjectDisplay", value ? "true" : "false");
}; };
useEffect(() => { useEffect(() => {
@ -100,8 +106,9 @@ const ProjectPage = () => {
{/* Service Project Button */} {/* Service Project Button */}
<button <button
type="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)} onClick={() => handleToggleProject(false)}
> >
Service Project Service Project
@ -109,8 +116,9 @@ const ProjectPage = () => {
{/* Organization Project Button */} {/* Organization Project Button */}
<button <button
type="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)} onClick={() => handleToggleProject(true)}
> >
Infra Project Infra Project
@ -138,8 +146,9 @@ const ProjectPage = () => {
<div className="d-flex gap-2"> <div className="d-flex gap-2">
<button <button
type="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)} onClick={() => setListView(false)}
title="Card View" title="Card View"
> >
@ -148,8 +157,9 @@ const ProjectPage = () => {
<button <button
type="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)} onClick={() => setListView(true)}
title="List View" title="List View"
> >
@ -164,12 +174,16 @@ const ProjectPage = () => {
onClick={() => setOpen(!open)} onClick={() => setOpen(!open)}
> >
<i <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> ></i>
{selectedStatuses.length !== PROJECT_STATUS.length && ( {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={{ style={{
top: "-4px", top: "-4px",
right: "-4px", right: "-4px",
@ -186,7 +200,7 @@ const ProjectPage = () => {
<ul <ul
ref={dropdownRef} ref={dropdownRef}
className="dropdown-menu show p-2 text-capitalize" className="dropdown-menu show p-2 text-capitalize"
onMouseDown={(e) => e.stopPropagation()} // IMPORTANT onMouseDown={(e) => e.stopPropagation()} // IMPORTANT
> >
{PROJECT_STATUS.map(({ id, label }) => ( {PROJECT_STATUS.map(({ id, label }) => (
<li key={id}> <li key={id}>
@ -200,7 +214,7 @@ const ProjectPage = () => {
/> />
<label <label
className="form-check-label" className="form-check-label"
onClick={(e) => e.stopPropagation()} // OPTIONAL onClick={(e) => e.stopPropagation()} // OPTIONAL
> >
{label} {label}
</label> </label>
@ -211,9 +225,6 @@ const ProjectPage = () => {
)} )}
</div> </div>
{HasManageProject && ( {HasManageProject && (
<button <button
type="button" type="button"
@ -223,9 +234,9 @@ const ProjectPage = () => {
coreProjects coreProjects
? setMangeProject({ isOpen: true, Project: null }) // Organization Project Infra ? setMangeProject({ isOpen: true, Project: null }) // Organization Project Infra
: setManageServiceProject({ : setManageServiceProject({
isOpen: true, isOpen: true,
Project: null, Project: null,
}) // Service Project }) // Service Project
} }
> >
<i className="bx bx-plus-circle me-2"></i> <i className="bx bx-plus-circle me-2"></i>