feat: update shift management with jadwal shift integration and improved error handling
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user