57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
export const useOrdersRestAPI = () => {
|
|
const config = useRuntimeConfig()
|
|
|
|
const getTeamOrders = async (teamUuid) => {
|
|
try {
|
|
const response = await $fetch(`${config.public.odooApiUrl}/fastapi/orders/api/v1/orders/team/${teamUuid}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
|
|
return response
|
|
} catch (error) {
|
|
console.error('Error fetching team orders:', error)
|
|
throw error
|
|
}
|
|
}
|
|
|
|
const getOrderByUuid = async (orderUuid) => {
|
|
try {
|
|
const response = await $fetch(`${config.public.odooApiUrl}/fastapi/orders/api/v1/orders/${orderUuid}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
|
|
return response
|
|
} catch (error) {
|
|
console.error('Error fetching order:', error)
|
|
throw error
|
|
}
|
|
}
|
|
|
|
const getCompanies = async () => {
|
|
try {
|
|
const response = await $fetch(`${config.public.odooApiUrl}/fastapi/companies/api/v1/companies`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
|
|
return response
|
|
} catch (error) {
|
|
console.error('Error fetching companies:', error)
|
|
throw error
|
|
}
|
|
}
|
|
|
|
return {
|
|
getTeamOrders,
|
|
getOrderByUuid,
|
|
getCompanies
|
|
}
|
|
} |