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(
|
const { tripApproveRequest } = await import(
|
||||||
"@/controller/TripController"
|
"@/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
|
// Gọi API gửi yêu cầu phê duyệt
|
||||||
await tripApproveRequest(tripId);
|
await tripApproveRequest(tripId);
|
||||||
@@ -248,9 +264,14 @@ export default function diary() {
|
|||||||
}, 100);
|
}, 100);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ Error sending trip for approval:", 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(
|
const handleDeleteTrip = useCallback(
|
||||||
|
|||||||
@@ -199,6 +199,9 @@
|
|||||||
"cancelTripConfirmTitle": "Cancel Request Confirmation",
|
"cancelTripConfirmTitle": "Cancel Request Confirmation",
|
||||||
"cancelTripConfirmMessage": "Are you sure you want to cancel the approval request? The trip will be reset to initial status.",
|
"cancelTripConfirmMessage": "Are you sure you want to cancel the approval request? The trip will be reset to initial status.",
|
||||||
"cancelTripError": "Unable to cancel request. Please try again.",
|
"cancelTripError": "Unable to cancel request. Please try again.",
|
||||||
|
"noCrewErrorTitle": "Cannot Send for Approval",
|
||||||
|
"noCrewErrorMessage": "This trip has no crew members. Please add crew members before sending for approval.",
|
||||||
|
"sendApprovalError": "Unable to send approval request. Please try again.",
|
||||||
"crew": {
|
"crew": {
|
||||||
"title": "Crew Members",
|
"title": "Crew Members",
|
||||||
"loading": "Loading crew members...",
|
"loading": "Loading crew members...",
|
||||||
|
|||||||
@@ -199,6 +199,9 @@
|
|||||||
"cancelTripConfirmTitle": "Xác nhận hủy yêu cầu",
|
"cancelTripConfirmTitle": "Xác nhận hủy yêu cầu",
|
||||||
"cancelTripConfirmMessage": "Bạn có chắc chắn muốn hủy yêu cầu phê duyệt? Chuyến đi sẽ trở về trạng thái đã khởi tạo.",
|
"cancelTripConfirmMessage": "Bạn có chắc chắn muốn hủy yêu cầu phê duyệt? Chuyến đi sẽ trở về trạng thái đã khởi tạo.",
|
||||||
"cancelTripError": "Không thể hủy yêu cầu. Vui lòng thử lại.",
|
"cancelTripError": "Không thể hủy yêu cầu. Vui lòng thử lại.",
|
||||||
|
"noCrewErrorTitle": "Không thể gửi phê duyệt",
|
||||||
|
"noCrewErrorMessage": "Chuyến đi chưa có thuyền viên. Vui lòng thêm thuyền viên trước khi gửi phê duyệt.",
|
||||||
|
"sendApprovalError": "Không thể gửi yêu cầu phê duyệt. Vui lòng thử lại.",
|
||||||
"crew": {
|
"crew": {
|
||||||
"title": "Danh sách thuyền viên",
|
"title": "Danh sách thuyền viên",
|
||||||
"loading": "Đang tải danh sách thuyền viên...",
|
"loading": "Đang tải danh sách thuyền viên...",
|
||||||
|
|||||||
Reference in New Issue
Block a user