All checks were successful
Auto Tag Develop / tag (push) Successful in 5s
| 313| Création d'une page d'administration : modification/création d'un fournisseur | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [ ] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #20 Reviewed-by: Autin <tristan@yuno.malio.fr> Co-authored-by: Matteo <matteo@yuno.malio.fr> Co-committed-by: Matteo <matteo@yuno.malio.fr>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { useApi } from '~/composables/useApi'
|
|
import type { AddressData } from '~/services/dto/address-data'
|
|
export interface AddressPayload {
|
|
label: string
|
|
street: string
|
|
street2?: string | null
|
|
postalCode: string
|
|
city: string
|
|
countryCode: string
|
|
}
|
|
|
|
export interface AddressData extends AddressPayload {
|
|
id: number
|
|
}
|
|
|
|
export async function createAddress(
|
|
payload: AddressPayload
|
|
): Promise<AddressData> {
|
|
const api = useApi()
|
|
|
|
return await api.post<AddressData>('addresses', payload, {
|
|
toastErrorKey: 'errors.address.create',
|
|
toastSuccessKey: 'success.address.create',
|
|
})
|
|
}
|
|
|
|
export async function updateAddress(
|
|
id: number,
|
|
payload: AddressPayload
|
|
): Promise<AddressData> {
|
|
const api = useApi()
|
|
|
|
return await api.patch<AddressData>(`addresses/${id}`, payload, {
|
|
toastErrorKey: 'errors.address.update',
|
|
toastSuccessKey: 'success.address.update',
|
|
})
|
|
}
|
|
|
|
export async function getAddress(id: number): Promise<AddressData> {
|
|
const api = useApi()
|
|
|
|
return await api.get<AddressData>(`addresses/${id}`, {}, {
|
|
toastErrorKey: 'errors.address.fetch',
|
|
})
|
|
}
|