56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import api from "./api"
|
|
import type { VoyageData, VoyageLink } from "../types"
|
|
|
|
export const voyagesLinksService = {
|
|
async getVoyagesLinks(): Promise<VoyageLink[]> {
|
|
try {
|
|
const response: VoyageLink[] = await api.get("voyages/")
|
|
return response
|
|
} catch (error: any) {
|
|
console.error("Error fetching voyages:", error)
|
|
throw error
|
|
}
|
|
},
|
|
|
|
async createVoyage(voyageData: VoyageData): Promise<VoyageLink> {
|
|
try {
|
|
const response: VoyageLink = await api.post("voyages/", {
|
|
voyage: voyageData,
|
|
permission: {},
|
|
})
|
|
return response
|
|
} catch (error) {
|
|
console.error("Error creating voyage:", error)
|
|
throw error
|
|
}
|
|
},
|
|
|
|
async getVoyageLinkDetails(voyageId: String): Promise<VoyageLink> {
|
|
try {
|
|
const response: VoyageLink = await api.get(`voyages/${voyageId}/`)
|
|
return response
|
|
} catch (error) {
|
|
console.error("Error fetching voyage details:", error)
|
|
throw error
|
|
}
|
|
},
|
|
|
|
// async updateVoyage(voyageId, voyageData) {
|
|
// try {
|
|
// const response = await api.put(`voyages/${voyageId}/`, voyageData)
|
|
// return response
|
|
// } catch (error) {
|
|
// console.error("Error updating voyage:", error)
|
|
// throw error
|
|
// }
|
|
// },
|
|
|
|
// async deleteVoyage(voyageId) {
|
|
// try {
|
|
// await api.delete(`voyages/${voyageId}/`)
|
|
// } catch (error) {
|
|
// console.error("Error deleting voyage:", error)
|
|
// throw error
|
|
// }
|
|
// },
|
|
}
|