Bug#182 - Add fallback error message handling with server response support #68
@ -27,7 +27,7 @@ const EmployeeList = () => {
|
|||||||
const { projects, loading: projectLoading } = useProjects();
|
const { projects, loading: projectLoading } = useProjects();
|
||||||
const ManageEmployee = useHasUserPermission(MANAGE_EMPLOYEES);
|
const ManageEmployee = useHasUserPermission(MANAGE_EMPLOYEES);
|
||||||
|
|
||||||
const { employees, loading, setLoading, error,recallEmployeeData } =
|
const { employees, loading, setLoading, error, recallEmployeeData } =
|
||||||
useEmployeesAllOrByProjectId(selectedProject);
|
useEmployeesAllOrByProjectId(selectedProject);
|
||||||
const [projectsList, setProjectsList] = useState(projects || []);
|
const [projectsList, setProjectsList] = useState(projects || []);
|
||||||
|
|
||||||
@ -110,11 +110,15 @@ const EmployeeList = () => {
|
|||||||
clearCacheKey("employeeListByProject");
|
clearCacheKey("employeeListByProject");
|
||||||
clearCacheKey("allEmployeeList");
|
clearCacheKey("allEmployeeList");
|
||||||
clearCacheKey("employeeProfile");
|
clearCacheKey("employeeProfile");
|
||||||
setEmployeeList([])
|
setEmployeeList([]);
|
||||||
recallEmployeeData()
|
recallEmployeeData();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
showToast(error.message, "error");
|
const message =
|
||||||
|
error.response?.data?.message ||
|
||||||
|
error.message ||
|
||||||
|
"An unexpected error occurred";
|
||||||
|
showToast(message, "error");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -127,7 +131,7 @@ const EmployeeList = () => {
|
|||||||
openModal();
|
openModal();
|
||||||
}
|
}
|
||||||
}, [modelConfig, isCreateModalOpen]);
|
}, [modelConfig, isCreateModalOpen]);
|
||||||
|
|
||||||
const tableRef = useRef(null);
|
const tableRef = useRef(null);
|
||||||
const handleExport = (type) => {
|
const handleExport = (type) => {
|
||||||
if (!currentItems || currentItems.length === 0) return;
|
if (!currentItems || currentItems.length === 0) return;
|
||||||
@ -449,7 +453,8 @@ const EmployeeList = () => {
|
|||||||
className="text-heading text-truncate cursor-pointer"
|
className="text-heading text-truncate cursor-pointer"
|
||||||
>
|
>
|
||||||
<span className="fw-normal">
|
<span className="fw-normal">
|
||||||
{item.firstName} {item.middleName} {item.lastName}
|
{item.firstName} {item.middleName}{" "}
|
||||||
|
{item.lastName}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -520,7 +525,8 @@ const EmployeeList = () => {
|
|||||||
className="dropdown-item py-1"
|
className="dropdown-item py-1"
|
||||||
onClick={() => suspendEmployee(item.id)}
|
onClick={() => suspendEmployee(item.id)}
|
||||||
>
|
>
|
||||||
<i className="bx bx-task-x bx-sm"></i> Suspend
|
<i className="bx bx-task-x bx-sm"></i>{" "}
|
||||||
|
Suspend
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item py-1"
|
className="dropdown-item py-1"
|
||||||
@ -529,7 +535,8 @@ const EmployeeList = () => {
|
|||||||
data-bs-target="#managerole-modal"
|
data-bs-target="#managerole-modal"
|
||||||
onClick={() => handleConfigData(item.id)}
|
onClick={() => handleConfigData(item.id)}
|
||||||
>
|
>
|
||||||
<i className="bx bx-cog bx-sm"></i> Manage Role
|
<i className="bx bx-cog bx-sm"></i> Manage
|
||||||
|
Role
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user