fixed restore selected project when toggling off "Show All Employees"
This commit is contained in:
parent
c8707fe7b1
commit
928a50432d
@ -45,16 +45,19 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
|
|
||||||
// Set initial values from activity
|
// Set initial values from activity
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Task?.workItem) {
|
if (!TaskLoading && (Task?.workItem || activity)) {
|
||||||
reset({
|
reset({
|
||||||
workCategoryId: Task?.workItem?.workCategoryId || "",
|
workCategoryId: Task?.workItem?.workCategoryId || "",
|
||||||
activityId: Task?.workItem?.activityId || activity?.workItem?.activityId,
|
activityId:
|
||||||
plannedWork: Number(Task?.notApprovedTask || Task?.workItem?.plannedWork),
|
Task?.workItem?.activityId || activity?.workItem?.activityId,
|
||||||
|
plannedWork: Number(
|
||||||
|
Task?.notApprovedTask || Task?.workItem?.plannedWork || 0
|
||||||
|
),
|
||||||
completedWork: 0,
|
completedWork: 0,
|
||||||
comment: "",
|
comment: "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [Task, reset]);
|
}, [TaskLoading, Task, activity, reset, loading]);
|
||||||
|
|
||||||
const handleCategoryChange = (e) => {
|
const handleCategoryChange = (e) => {
|
||||||
const value = e.target.value;
|
const value = e.target.value;
|
||||||
@ -131,7 +134,9 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
{...register("workCategoryId")}
|
{...register("workCategoryId")}
|
||||||
onChange={handleCategoryChange}
|
onChange={handleCategoryChange}
|
||||||
>
|
>
|
||||||
<option value="">{categoryLoading ? "Loading..." : "-- Select Category --" }</option>
|
<option value="">
|
||||||
|
{categoryLoading ? "Loading..." : "-- Select Category --"}
|
||||||
|
</option>
|
||||||
{categoryData.map((category) => (
|
{categoryData.map((category) => (
|
||||||
<option key={category.id} value={category.id}>
|
<option key={category.id} value={category.id}>
|
||||||
{category.name}
|
{category.name}
|
||||||
@ -146,17 +151,19 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
<label className="form-label">Select Activity</label>
|
<label className="form-label">Select Activity</label>
|
||||||
<select
|
<select
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
{...register( "activityId" )}
|
{...register("activityId")}
|
||||||
disabled
|
disabled
|
||||||
>
|
>
|
||||||
<option value="">
|
<option value="">
|
||||||
{categoryLoading && "Loading..." }
|
{loading ? "Loading..." : "-- Select Activity --"}
|
||||||
</option>
|
</option>
|
||||||
{activities?.map((activity) => (
|
|
||||||
<option key={activity.id} value={activity.id}>
|
{!loading &&
|
||||||
{activity.activityName}
|
activities?.map((activity) => (
|
||||||
</option>
|
<option key={activity.id} value={activity.id}>
|
||||||
))}
|
{activity.activityName}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.activityId && (
|
{errors.activityId && (
|
||||||
<div className="danger-text">{errors.activityId.message}</div>
|
<div className="danger-text">{errors.activityId.message}</div>
|
||||||
@ -168,7 +175,7 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register("plannedWork", { valueAsNumber: true })}
|
{...register("plannedWork", { valueAsNumber: true })}
|
||||||
/>
|
/>
|
||||||
{errors.plannedWork && (
|
{errors.plannedWork && (
|
||||||
<div className="danger-text">{errors.plannedWork.message}</div>
|
<div className="danger-text">{errors.plannedWork.message}</div>
|
||||||
@ -180,7 +187,7 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register( "completedWork" )}
|
{...register("completedWork")}
|
||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
{errors.completedWork && (
|
{errors.completedWork && (
|
||||||
@ -211,7 +218,11 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 text-center">
|
<div className="col-12 text-center">
|
||||||
<button type="submit" className="btn btn-sm btn-primary me-2" disabled={isSubmitting}>
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary me-2"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
{isSubmitting ? "Please wait..." : "Submit"}
|
{isSubmitting ? "Please wait..." : "Submit"}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
@ -97,30 +97,29 @@ export const useActivitiesMaster = () =>
|
|||||||
{
|
{
|
||||||
const [ activities, setActivites ] = useState( [] )
|
const [ activities, setActivites ] = useState( [] )
|
||||||
const [ loading, setloading ] = useState( false );
|
const [ loading, setloading ] = useState( false );
|
||||||
const [ error, setError ] = useState( "" )
|
const [ error, setError ] = useState()
|
||||||
|
|
||||||
const fetchActivities =async () => {
|
const fetchActivities =async () => {
|
||||||
const cacheddata = getCachedData("ActivityMaster");
|
|
||||||
|
|
||||||
if (!cacheddata) {
|
|
||||||
setloading(true);
|
setloading(true);
|
||||||
try {
|
try {
|
||||||
const response = await MasterRespository.getActivites();
|
const response = await MasterRespository.getActivites();
|
||||||
setActivites(response.data);
|
setActivites(response.data);
|
||||||
cacheData("ActivityMaster", response.data);
|
cacheData( "ActivityMaster", response.data );
|
||||||
|
setloading(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err);
|
setError(err);
|
||||||
console.log(err);
|
|
||||||
} finally {
|
|
||||||
setloading(false);
|
setloading(false);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setActivites(cacheddata);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
useEffect( () =>
|
useEffect( () =>
|
||||||
{
|
{
|
||||||
fetchActivities()
|
const cacheddata = getCachedData( "ActivityMaster" );
|
||||||
|
if ( !cacheddata )
|
||||||
|
{
|
||||||
|
fetchActivities()
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
setActivites(cacheddata);
|
||||||
|
}
|
||||||
}, [] )
|
}, [] )
|
||||||
|
|
||||||
return {activities,loading,error}
|
return {activities,loading,error}
|
||||||
|
@ -191,13 +191,17 @@ const EmployeeList = () => {
|
|||||||
recallEmployeeData(e.target.checked);
|
recallEmployeeData(e.target.checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAllEmployeesToggle = (e) => {
|
const handleAllEmployeesToggle = (e) => {
|
||||||
const isChecked = e.target.checked;
|
const isChecked = e.target.checked;
|
||||||
setShowInactive(false)
|
setShowInactive(false);
|
||||||
setShowAllEmployees( isChecked );
|
setShowAllEmployees(isChecked);
|
||||||
|
|
||||||
|
if (!isChecked) {
|
||||||
|
setSelectedProject(selectedProjectId || "");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
recallEmployeeData(showInactive, isChecked ? null : selectedProject);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEmployeeModel = (id) => {
|
const handleEmployeeModel = (id) => {
|
||||||
setSelecedEmployeeId(id);
|
setSelecedEmployeeId(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user