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
|
||||
useEffect(() => {
|
||||
if (Task?.workItem) {
|
||||
if (!TaskLoading && (Task?.workItem || activity)) {
|
||||
reset({
|
||||
workCategoryId: Task?.workItem?.workCategoryId || "",
|
||||
activityId: Task?.workItem?.activityId || activity?.workItem?.activityId,
|
||||
plannedWork: Number(Task?.notApprovedTask || Task?.workItem?.plannedWork),
|
||||
activityId:
|
||||
Task?.workItem?.activityId || activity?.workItem?.activityId,
|
||||
plannedWork: Number(
|
||||
Task?.notApprovedTask || Task?.workItem?.plannedWork || 0
|
||||
),
|
||||
completedWork: 0,
|
||||
comment: "",
|
||||
});
|
||||
}
|
||||
}, [Task, reset]);
|
||||
}, [TaskLoading, Task, activity, reset, loading]);
|
||||
|
||||
const handleCategoryChange = (e) => {
|
||||
const value = e.target.value;
|
||||
@ -131,7 +134,9 @@ const SubTask = ({ activity, onClose }) => {
|
||||
{...register("workCategoryId")}
|
||||
onChange={handleCategoryChange}
|
||||
>
|
||||
<option value="">{categoryLoading ? "Loading..." : "-- Select Category --" }</option>
|
||||
<option value="">
|
||||
{categoryLoading ? "Loading..." : "-- Select Category --"}
|
||||
</option>
|
||||
{categoryData.map((category) => (
|
||||
<option key={category.id} value={category.id}>
|
||||
{category.name}
|
||||
@ -146,17 +151,19 @@ const SubTask = ({ activity, onClose }) => {
|
||||
<label className="form-label">Select Activity</label>
|
||||
<select
|
||||
className="form-select form-select-sm"
|
||||
{...register( "activityId" )}
|
||||
{...register("activityId")}
|
||||
disabled
|
||||
>
|
||||
<option value="">
|
||||
{categoryLoading && "Loading..." }
|
||||
</option>
|
||||
{activities?.map((activity) => (
|
||||
<option key={activity.id} value={activity.id}>
|
||||
{activity.activityName}
|
||||
</option>
|
||||
))}
|
||||
{loading ? "Loading..." : "-- Select Activity --"}
|
||||
</option>
|
||||
|
||||
{!loading &&
|
||||
activities?.map((activity) => (
|
||||
<option key={activity.id} value={activity.id}>
|
||||
{activity.activityName}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{errors.activityId && (
|
||||
<div className="danger-text">{errors.activityId.message}</div>
|
||||
@ -168,7 +175,7 @@ const SubTask = ({ activity, onClose }) => {
|
||||
<input
|
||||
type="number"
|
||||
className="form-control form-control-sm"
|
||||
{...register("plannedWork", { valueAsNumber: true })}
|
||||
{...register("plannedWork", { valueAsNumber: true })}
|
||||
/>
|
||||
{errors.plannedWork && (
|
||||
<div className="danger-text">{errors.plannedWork.message}</div>
|
||||
@ -180,7 +187,7 @@ const SubTask = ({ activity, onClose }) => {
|
||||
<input
|
||||
type="number"
|
||||
className="form-control form-control-sm"
|
||||
{...register( "completedWork" )}
|
||||
{...register("completedWork")}
|
||||
disabled
|
||||
/>
|
||||
{errors.completedWork && (
|
||||
@ -211,7 +218,11 @@ const SubTask = ({ activity, onClose }) => {
|
||||
</div>
|
||||
|
||||
<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"}
|
||||
</button>
|
||||
<button
|
||||
|
@ -97,30 +97,29 @@ export const useActivitiesMaster = () =>
|
||||
{
|
||||
const [ activities, setActivites ] = useState( [] )
|
||||
const [ loading, setloading ] = useState( false );
|
||||
const [ error, setError ] = useState( "" )
|
||||
|
||||
const [ error, setError ] = useState()
|
||||
const fetchActivities =async () => {
|
||||
const cacheddata = getCachedData("ActivityMaster");
|
||||
|
||||
if (!cacheddata) {
|
||||
setloading(true);
|
||||
try {
|
||||
const response = await MasterRespository.getActivites();
|
||||
setActivites(response.data);
|
||||
cacheData("ActivityMaster", response.data);
|
||||
cacheData( "ActivityMaster", response.data );
|
||||
setloading(false);
|
||||
} catch (err) {
|
||||
setError(err);
|
||||
console.log(err);
|
||||
} finally {
|
||||
setloading(false);
|
||||
}
|
||||
} else {
|
||||
setActivites(cacheddata);
|
||||
}
|
||||
}
|
||||
useEffect( () =>
|
||||
{
|
||||
fetchActivities()
|
||||
const cacheddata = getCachedData( "ActivityMaster" );
|
||||
if ( !cacheddata )
|
||||
{
|
||||
fetchActivities()
|
||||
} else
|
||||
{
|
||||
setActivites(cacheddata);
|
||||
}
|
||||
}, [] )
|
||||
|
||||
return {activities,loading,error}
|
||||
|
@ -191,13 +191,17 @@ const EmployeeList = () => {
|
||||
recallEmployeeData(e.target.checked);
|
||||
};
|
||||
|
||||
const handleAllEmployeesToggle = (e) => {
|
||||
const isChecked = e.target.checked;
|
||||
setShowInactive(false)
|
||||
setShowAllEmployees( isChecked );
|
||||
const handleAllEmployeesToggle = (e) => {
|
||||
const isChecked = e.target.checked;
|
||||
setShowInactive(false);
|
||||
setShowAllEmployees(isChecked);
|
||||
|
||||
if (!isChecked) {
|
||||
setSelectedProject(selectedProjectId || "");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
recallEmployeeData(showInactive, isChecked ? null : selectedProject);
|
||||
};
|
||||
|
||||
const handleEmployeeModel = (id) => {
|
||||
setSelecedEmployeeId(id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user