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 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,7 +106,8 @@ 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)}
>
@ -109,7 +116,8 @@ 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)}
>
@ -138,7 +146,8 @@ 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,7 +157,8 @@ 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",
@ -211,9 +225,6 @@ const ProjectPage = () => {
)}
</div>
{HasManageProject && (
<button
type="button"