Cập nhật validate có thuyển viên trong chuyến đi -> gửi chuyển đi
This commit is contained in:
@@ -226,6 +226,22 @@ export default function diary() {
|
||||
const { tripApproveRequest } = await import(
|
||||
"@/controller/TripController"
|
||||
);
|
||||
const { queryTripCrew } = await import(
|
||||
"@/controller/TripCrewController"
|
||||
);
|
||||
|
||||
// Kiểm tra xem có thuyền viên không trước khi gửi phê duyệt
|
||||
const crewResponse = await queryTripCrew(tripId);
|
||||
const tripCrews = crewResponse.data?.trip_crews || [];
|
||||
|
||||
// Nếu response 204 hoặc không có thuyền viên
|
||||
if (crewResponse.status === 204 || tripCrews.length === 0) {
|
||||
Alert.alert(
|
||||
t("diary.noCrewErrorTitle"),
|
||||
t("diary.noCrewErrorMessage")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Gọi API gửi yêu cầu phê duyệt
|
||||
await tripApproveRequest(tripId);
|
||||
@@ -248,9 +264,14 @@ export default function diary() {
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
console.error("❌ Error sending trip for approval:", error);
|
||||
Alert.alert(
|
||||
t("common.error") || "Lỗi",
|
||||
t("diary.sendApprovalError") ||
|
||||
"Không thể gửi yêu cầu phê duyệt. Vui lòng thử lại."
|
||||
);
|
||||
}
|
||||
},
|
||||
[payloadTrips, getTripsList]
|
||||
[payloadTrips, getTripsList, t]
|
||||
);
|
||||
|
||||
const handleDeleteTrip = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user