feat: update shift management with jadwal shift integration and improved error handling

This commit is contained in:
2025-10-13 23:13:40 +07:00
parent 5ed5ee26bf
commit 973713286f
5 changed files with 192 additions and 76 deletions

View File

@@ -22,13 +22,23 @@ const DetailJadwalShift = (props) => {
const [FormData, setFormData] = useState(defaultData);
const fetchShifts = async () => {
const response = await getAllShift(new URLSearchParams());
setShifts(response.data.data);
try {
const response = await getAllShift(new URLSearchParams());
setShifts(response?.data?.data || []);
} catch (error) {
console.error("Failed to fetch shifts:", error);
setShifts([]);
}
};
const fetchUsers = async () => {
const response = await getAllUser(new URLSearchParams("limit=1000")); // Fetch all users
setUsers(response.data.data);
try {
const response = await getAllUser(new URLSearchParams("limit=1000")); // Fetch all users
setUsers(response?.data?.data || []);
} catch (error) {
console.error("Failed to fetch users:", error);
setUsers([]);
}
};
useEffect(() => {
@@ -82,6 +92,7 @@ const DetailJadwalShift = (props) => {
});
props.setActionMode('list');
props.fetchData();
} else {
NotifAlert({
icon: 'error',