Finalisation réception marchandise, ajout de composant UI et ajout de fixtures (!7)
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## 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: https://gitea.malio.fr/MALIO-DEV/Ferme/pulls/7 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { BuildingData } from '~/services/dto/building-data'
|
||||
|
||||
export type BuildingListResponse =
|
||||
| BuildingData[]
|
||||
| { 'hydra:member'?: BuildingData[] }
|
||||
|
||||
export async function getBuildingList(): Promise<BuildingData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<BuildingListResponse>('buildings', {}, {
|
||||
toastErrorKey: 'errors.building.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
|
||||
export type CarrierListResponse =
|
||||
| CarrierData[]
|
||||
| { 'hydra:member'?: CarrierData[] }
|
||||
|
||||
export async function getCarrierList(): Promise<CarrierData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<CarrierListResponse>('carriers', {}, {
|
||||
toastErrorKey: 'errors.carrier.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { DriverData } from '~/services/dto/driver-data'
|
||||
|
||||
export type DriverListResponse =
|
||||
| DriverData[]
|
||||
| { 'hydra:member'?: DriverData[] }
|
||||
|
||||
export async function getDriverList(): Promise<DriverData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<DriverListResponse>('drivers', {}, {
|
||||
toastErrorKey: 'errors.driver.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export interface AddressData {
|
||||
id: number
|
||||
label: string
|
||||
street: string
|
||||
street2?: string | null
|
||||
postalCode: string
|
||||
city: string
|
||||
countryCode: string
|
||||
fullAddress?: string
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface BuildingData {
|
||||
id: number
|
||||
label: string
|
||||
code: string
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface CarrierData {
|
||||
id: number
|
||||
name: string
|
||||
code: string
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
|
||||
export interface DriverData {
|
||||
id: number
|
||||
name: string
|
||||
carrier?: CarrierData | null
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface MerchandiseTypeData {
|
||||
id: number
|
||||
label: string
|
||||
code: string
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface PelletTypeData {
|
||||
id: number
|
||||
label: string
|
||||
code: string
|
||||
}
|
||||
@@ -1,10 +1,33 @@
|
||||
import type { ReceptionTypeData } from '~/services/dto/reception-type-data'
|
||||
import type { MerchandiseTypeData } from '~/services/dto/merchandise-type-data'
|
||||
import type { BuildingData } from '~/services/dto/building-data'
|
||||
import type { ReceptionPelletBuildingData } from '~/services/dto/reception-pellet-building-data'
|
||||
import type { UserData } from '~/services/dto/user-data'
|
||||
import type { SupplierData } from '~/services/dto/supplier-data'
|
||||
import type { AddressData } from '~/services/dto/address-data'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
import type { DriverData } from '~/services/dto/driver-data'
|
||||
|
||||
export interface ReceptionData {
|
||||
id: number
|
||||
identificationNumber?: string | null
|
||||
licensePlate: string | null
|
||||
weights?: WeightEntryData[] | null
|
||||
receptionDate: string
|
||||
currentStep: number
|
||||
isValid: boolean
|
||||
receptionType?: ReceptionTypeData | null
|
||||
merchandiseType?: MerchandiseTypeData | null
|
||||
merchandiseDetail?: string | null
|
||||
buildings?: BuildingData[] | null
|
||||
pelletBuildings?: ReceptionPelletBuildingData[] | null
|
||||
user?: UserData | null
|
||||
supplier?: SupplierData | null
|
||||
address?: AddressData | null
|
||||
truck?: TruckData | null
|
||||
carrier?: CarrierData | null
|
||||
driver?: DriverData | null
|
||||
}
|
||||
|
||||
export interface WeightEntryData {
|
||||
@@ -14,3 +37,20 @@ export interface WeightEntryData {
|
||||
weight: number | null
|
||||
weighedAt: string | null
|
||||
}
|
||||
|
||||
export type ReceptionPayload = {
|
||||
licensePlate?: string | null
|
||||
receptionDate?: string
|
||||
currentStep?: number
|
||||
isValid?: boolean
|
||||
receptionType?: string | null
|
||||
merchandiseType?: string | null
|
||||
merchandiseDetail?: string | null
|
||||
buildings?: string[] | null
|
||||
user?: string | null
|
||||
supplier?: string | null
|
||||
address?: string | null
|
||||
truck?: string | null
|
||||
carrier?: string | null
|
||||
driver?: string | null
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { BuildingData } from '~/services/dto/building-data'
|
||||
import type { PelletTypeData } from '~/services/dto/pellet-type-data'
|
||||
|
||||
export interface ReceptionPelletBuildingData {
|
||||
id: number
|
||||
reception?: string
|
||||
building: BuildingData
|
||||
pelletType: PelletTypeData
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface ReceptionTypeData {
|
||||
id: number
|
||||
label: string
|
||||
code: string
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { AddressData } from '~/services/dto/address-data'
|
||||
|
||||
export interface SupplierData {
|
||||
id: number
|
||||
name: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
addresses?: AddressData[] | null
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface TruckData {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export interface UserData {
|
||||
id: number
|
||||
username: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
|
||||
export interface VehicleData {
|
||||
id: number
|
||||
plate: string
|
||||
carrier?: CarrierData | null
|
||||
truck?: TruckData | null
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { MerchandiseTypeData } from '~/services/dto/merchandise-type-data'
|
||||
|
||||
export type MerchandiseTypeListResponse =
|
||||
| MerchandiseTypeData[]
|
||||
| { 'hydra:member'?: MerchandiseTypeData[] }
|
||||
|
||||
export async function getMerchandiseTypeList(): Promise<MerchandiseTypeData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<MerchandiseTypeListResponse>('merchandise_types', {}, {
|
||||
toastErrorKey: 'errors.merchandiseType.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { PelletTypeData } from '~/services/dto/pellet-type-data'
|
||||
|
||||
export type PelletTypeListResponse =
|
||||
| PelletTypeData[]
|
||||
| { 'hydra:member'?: PelletTypeData[] }
|
||||
|
||||
export async function getPelletTypeList(): Promise<PelletTypeData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<PelletTypeListResponse>('pellet_types', {}, {
|
||||
toastErrorKey: 'errors.pelletType.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { ReceptionPelletBuildingData } from '~/services/dto/reception-pellet-building-data'
|
||||
|
||||
export type ReceptionPelletBuildingListResponse =
|
||||
| ReceptionPelletBuildingData[]
|
||||
| { 'hydra:member'?: ReceptionPelletBuildingData[] }
|
||||
|
||||
export type ReceptionPelletBuildingPayload = {
|
||||
reception: string
|
||||
pelletType: string
|
||||
building: string
|
||||
}
|
||||
|
||||
export async function getReceptionPelletBuildingList(
|
||||
receptionIri: string
|
||||
): Promise<ReceptionPelletBuildingData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<ReceptionPelletBuildingListResponse>(
|
||||
'reception_pellet_buildings',
|
||||
{ reception: receptionIri },
|
||||
{
|
||||
toastErrorKey: 'errors.receptionPelletBuilding.list'
|
||||
}
|
||||
)
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
export async function createReceptionPelletBuilding(
|
||||
payload: ReceptionPelletBuildingPayload
|
||||
): Promise<ReceptionPelletBuildingData> {
|
||||
const api = useApi()
|
||||
return api.post<ReceptionPelletBuildingData>('reception_pellet_buildings', payload, {
|
||||
toastErrorKey: 'errors.receptionPelletBuilding.create'
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteReceptionPelletBuilding(id: number): Promise<void> {
|
||||
const api = useApi()
|
||||
await api.delete<void>(`reception_pellet_buildings/${id}`, {}, {
|
||||
toastErrorKey: 'errors.receptionPelletBuilding.delete'
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { ReceptionTypeData } from '~/services/dto/reception-type-data'
|
||||
|
||||
export type ReceptionTypeListResponse =
|
||||
| ReceptionTypeData[]
|
||||
| { 'hydra:member'?: ReceptionTypeData[] }
|
||||
|
||||
export async function getReceptionTypeList(): Promise<ReceptionTypeData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<ReceptionTypeListResponse>('reception_types', {}, {
|
||||
toastErrorKey: 'errors.receptionType.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import {useApi} from '~/composables/useApi'
|
||||
import type {ReceptionData} from '~/services/dto/reception-data'
|
||||
import type {ReceptionData, ReceptionPayload} from '~/services/dto/reception-data'
|
||||
import type {WeightData} from '~/services/dto/weight-data'
|
||||
|
||||
export async function getReceptionList() {
|
||||
@@ -16,14 +16,14 @@ export async function getReception(id: number) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function createReception(payload: Partial<ReceptionData> = {}) {
|
||||
export async function createReception(payload: ReceptionPayload = {}) {
|
||||
const api = useApi()
|
||||
return api.post<ReceptionData>('receptions', payload, {
|
||||
toastErrorKey: 'errors.reception.create'
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateReception(id: number, payload: Partial<ReceptionData>) {
|
||||
export async function updateReception(id: number, payload: ReceptionPayload) {
|
||||
const api = useApi()
|
||||
return api.patch<ReceptionData>(`receptions/${id}`, payload, {
|
||||
toastErrorKey: 'errors.reception.update',
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { SupplierData } from '~/services/dto/supplier-data'
|
||||
|
||||
export type SupplierListResponse =
|
||||
| SupplierData[]
|
||||
| { 'hydra:member'?: SupplierData[] }
|
||||
|
||||
export async function getSupplierList(): Promise<SupplierData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<SupplierListResponse>('suppliers', {}, {
|
||||
toastErrorKey: 'errors.supplier.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
|
||||
export type TruckListResponse =
|
||||
| TruckData[]
|
||||
| { 'hydra:member'?: TruckData[] }
|
||||
|
||||
export async function getTruckList(): Promise<TruckData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<TruckListResponse>('trucks', {}, {
|
||||
toastErrorKey: 'errors.truck.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { VehicleData } from '~/services/dto/vehicle-data'
|
||||
|
||||
export type VehicleListResponse =
|
||||
| VehicleData[]
|
||||
| { 'hydra:member'?: VehicleData[] }
|
||||
|
||||
export async function getVehicleList(): Promise<VehicleData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<VehicleListResponse>('vehicles', {}, {
|
||||
toastErrorKey: 'errors.vehicle.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
Reference in New Issue
Block a user