cập nhật modal CRUD thuyền viên trong trip
This commit is contained in:
19
controller/CrewController.ts
Normal file
19
controller/CrewController.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { api } from "@/config";
|
||||
import { API_CREW, API_GET_PHOTO } from "@/constants";
|
||||
|
||||
export async function newCrew(body: Model.NewCrewAPIRequest) {
|
||||
return api.post(API_CREW, body);
|
||||
}
|
||||
|
||||
export async function updateCrewInfo(
|
||||
personalId: string,
|
||||
body: Model.UpdateCrewAPIRequest
|
||||
) {
|
||||
return api.put(`${API_CREW}/${personalId}`, body);
|
||||
}
|
||||
|
||||
export async function queryCrewImage(personal_id: string) {
|
||||
return await api.get(`${API_GET_PHOTO}/people/${personal_id}/main`, {
|
||||
responseType: "arraybuffer",
|
||||
});
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
API_GET_LAST_TRIP,
|
||||
API_POST_TRIP,
|
||||
API_PUT_TRIP,
|
||||
API_TRIP_CREW,
|
||||
} from "@/constants";
|
||||
|
||||
export async function queryTrip() {
|
||||
|
||||
@@ -1,12 +1,27 @@
|
||||
import { api } from "@/config";
|
||||
import { API_GET_PHOTO, API_GET_TRIP_CREW } from "@/constants";
|
||||
import {
|
||||
API_GET_PHOTO,
|
||||
API_GET_TRIP_CREW,
|
||||
API_SEARCH_CREW,
|
||||
API_TRIP_CREW,
|
||||
} from "@/constants";
|
||||
|
||||
export async function queryTripCrew(tripId: string) {
|
||||
return api.get<Model.TripCrews[]>(`${API_GET_TRIP_CREW}/${tripId}`);
|
||||
}
|
||||
|
||||
export async function queryCrewImage(personal_id: string) {
|
||||
return await api.get(`${API_GET_PHOTO}/people/${personal_id}/main`, {
|
||||
responseType: "arraybuffer",
|
||||
});
|
||||
export async function searchCrew(personal_id: string) {
|
||||
return api.get<Model.TripCrewPerson>(`${API_SEARCH_CREW}/${personal_id}`);
|
||||
}
|
||||
|
||||
export async function newTripCrew(body: Model.NewTripCrewAPIRequest) {
|
||||
return api.post(API_TRIP_CREW, body);
|
||||
}
|
||||
|
||||
export async function updateTripCrew(body: Model.UpdateTripCrewAPIRequest) {
|
||||
return api.put(API_TRIP_CREW, body);
|
||||
}
|
||||
|
||||
export async function deleteTripCrew(tripId: string, personalId: string) {
|
||||
return api.delete(`${API_TRIP_CREW}/${tripId}/${personalId}`);
|
||||
}
|
||||
|
||||
31
controller/typings.d.ts
vendored
31
controller/typings.d.ts
vendored
@@ -154,6 +154,37 @@ declare namespace Model {
|
||||
created_at: Date;
|
||||
updated_at: Date;
|
||||
}
|
||||
|
||||
// TripCrew Request Body
|
||||
interface NewTripCrewAPIRequest {
|
||||
trip_id: string;
|
||||
personal_id: string;
|
||||
role: "captain" | "crew";
|
||||
}
|
||||
interface UpdateTripCrewAPIRequest {
|
||||
trip_id: string;
|
||||
personal_id: string;
|
||||
role: "captain" | "crew";
|
||||
note: string;
|
||||
}
|
||||
interface NewCrewAPIRequest {
|
||||
personal_id: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
birth_date: Date;
|
||||
note: string;
|
||||
address: string;
|
||||
}
|
||||
interface UpdateCrewAPIRequest {
|
||||
name: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
birth_date: Date;
|
||||
//note: string;
|
||||
address: string;
|
||||
}
|
||||
|
||||
// Chi phí chuyến đi
|
||||
interface TripCost {
|
||||
type: string;
|
||||
|
||||
Reference in New Issue
Block a user