Compare commits
6 Commits
19ff94c3b7
...
v0.0.67
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0213c3212 | ||
| 3ac676689d | |||
|
|
9f47e81efd | ||
| 257b93e691 | |||
|
|
dc5320b324 | ||
| 09a641e5cf |
@@ -55,7 +55,10 @@ Ajouter dans le fichier .env du frontend
|
|||||||
* [#332] Refonte écran réception terminée
|
* [#332] Refonte écran réception terminée
|
||||||
* [#327] afficher/modifier écran expédition terminée
|
* [#327] afficher/modifier écran expédition terminée
|
||||||
* [#352] modification front admin fournisseur
|
* [#352] modification front admin fournisseur
|
||||||
* [#355] afficher/modifier écran expédition terminée
|
* [#355] modification front admin transporteur
|
||||||
|
* [#356] front page admin bovin
|
||||||
|
* [#353] modification front admin client
|
||||||
|
* [#353] modification front admin utilisateur
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.0.64'
|
app.version: '0.0.67'
|
||||||
|
|||||||
@@ -82,7 +82,10 @@
|
|||||||
"list": "Impossible de récupérer la liste des camions."
|
"list": "Impossible de récupérer la liste des camions."
|
||||||
},
|
},
|
||||||
"bovin": {
|
"bovin": {
|
||||||
"list": "Impossible de récupérer la liste des races de bovins."
|
"list": "Impossible de récupérer la liste des races de bovins.",
|
||||||
|
"fetch": "Impossible de récupérer le type bovin.",
|
||||||
|
"create": "Impossible de créer le type bovin.",
|
||||||
|
"update": "Impossible de mettre à jour le type bovin."
|
||||||
},
|
},
|
||||||
"carrier": {
|
"carrier": {
|
||||||
"list": "Impossible de récupérer la liste des transporteurs.",
|
"list": "Impossible de récupérer la liste des transporteurs.",
|
||||||
@@ -133,6 +136,10 @@
|
|||||||
"update": "Transporteur mis à jour",
|
"update": "Transporteur mis à jour",
|
||||||
"create": "Transporteur créé"
|
"create": "Transporteur créé"
|
||||||
},
|
},
|
||||||
|
"bovin": {
|
||||||
|
"update": "Type bovin mis à jour avec succès.",
|
||||||
|
"create": "Type bovin créé avec succès."
|
||||||
|
},
|
||||||
"weight": {
|
"weight": {
|
||||||
"update": "Pesée mis à jour"
|
"update": "Pesée mis à jour"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
|
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
v-if="auth.isAdmin"
|
v-if="auth.isAdmin"
|
||||||
to="/admin/bovin/list"
|
to="/admin/bovin/bovin-list"
|
||||||
custom
|
custom
|
||||||
v-slot="{ href, navigate }"
|
v-slot="{ href, navigate }"
|
||||||
>
|
>
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
<NuxtLink v-if="auth.isAdmin" to="/admin/customer/customer-list" @click="closeMenu">
|
<NuxtLink v-if="auth.isAdmin" to="/admin/customer/customer-list" @click="closeMenu">
|
||||||
Clients
|
Clients
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink v-if="auth.isAdmin" to="/admin/bovin/list" @click="closeMenu">
|
<NuxtLink v-if="auth.isAdmin" to="/admin/bovin/bovin-list" @click="closeMenu">
|
||||||
Bovins
|
Bovins
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -1,24 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="validate">
|
<form @submit.prevent="validate">
|
||||||
<div class="text-primary-500 flex items-center justify-between">
|
<div class="flex items-center justify-between relative">
|
||||||
<h1 class="text-3xl font-bold uppercase">
|
<div class="flex flex-row absolute -left-[60px]">
|
||||||
{{ route.params.id ? 'Modifier bovin' : 'Ajout bovin' }}
|
<Icon
|
||||||
|
@click="router.push('/admin/bovin/bovin-list')"
|
||||||
|
name="gg:arrow-left-o"
|
||||||
|
size="40"
|
||||||
|
class="cursor-pointer text-primary-500"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<h1 class="text-3xl text-primary-500 font-bold uppercase">
|
||||||
|
{{ route.params.id ? 'Modifications du type bovin' : 'Ajout d\'un type bovin' }}
|
||||||
</h1>
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 items-start pt-7 mb-11 gap-x-[200px]">
|
||||||
|
<UiTextInput label="Nom du bovin" id="bovin-label" v-model="form.label" />
|
||||||
|
<UiTextInput label="Code bovin" id="code-id" v-model="form.code" />
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-center items-center">
|
||||||
<UiButton
|
<UiButton
|
||||||
type="submit"
|
type="submit"
|
||||||
:disabled="isLoading || isHydrating"
|
:disabled="isLoading || isHydrating"
|
||||||
class="inline-flex items-center justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
class="inline-flex items-center justify-center text-xl min-w-[194px] text-white uppercase bg-primary-500 h-[50px] rounded hover:opacity-80 justify-self-end"
|
||||||
>
|
>
|
||||||
<Icon :name="isEdit ? '' : 'mdi:plus'" size="28" />
|
Valider
|
||||||
{{ isEdit ? 'Valider' : 'Ajouter' }}
|
|
||||||
</UiButton>
|
</UiButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 py-12">
|
|
||||||
<UiTextInput label="Nom du bovin" id="bovin-label" v-model="form.label" />
|
|
||||||
<UiTextInput label="Code bovin" id="code-id" v-model="form.code" />
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -29,6 +37,8 @@ const router = useRouter()
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
const isHydrating = ref(false)
|
const isHydrating = ref(false)
|
||||||
|
const idBovin = computed(() => resolveId(route.params.id))
|
||||||
|
const isEdit = computed(() => idBovin.value !== null)
|
||||||
|
|
||||||
function resolveId(param: unknown) {
|
function resolveId(param: unknown) {
|
||||||
const idStr = Array.isArray(param) ? param[0] : param
|
const idStr = Array.isArray(param) ? param[0] : param
|
||||||
@@ -37,9 +47,6 @@ function resolveId(param: unknown) {
|
|||||||
return Number.isFinite(id) ? id : null
|
return Number.isFinite(id) ? id : null
|
||||||
}
|
}
|
||||||
|
|
||||||
const idBovin = computed(() => resolveId(route.params.id))
|
|
||||||
const isEdit = computed(() => idBovin.value !== null)
|
|
||||||
|
|
||||||
const form = reactive<BovinFormData>({
|
const form = reactive<BovinFormData>({
|
||||||
label: '',
|
label: '',
|
||||||
code: ''
|
code: ''
|
||||||
@@ -92,7 +99,6 @@ async function validate() {
|
|||||||
} else {
|
} else {
|
||||||
await createBovin(basePayload)
|
await createBovin(basePayload)
|
||||||
}
|
}
|
||||||
await navigate()
|
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
67
frontend/pages/admin/bovin/bovin-list.vue
Normal file
67
frontend/pages/admin/bovin/bovin-list.vue
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex items-center justify-between ">
|
||||||
|
<h1 class="text-4xl font-bold uppercase text-primary-500">Liste des types bovins</h1>
|
||||||
|
</div>
|
||||||
|
<div class="mt-7 border border-slate-200 mb-11 ">
|
||||||
|
<div class="grid grid-cols-2 gap-4 text-primary-700 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
||||||
|
<div>Nom</div>
|
||||||
|
<div>Code</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="!auth.isAdmin" class="px-4 py-6 text-slate-400">
|
||||||
|
Accès réservé aux administrateurs.
|
||||||
|
</div>
|
||||||
|
<div v-else-if="bovinList.length === 0" class="px-4 py-6 text-slate-400">
|
||||||
|
Aucun type de bovin.
|
||||||
|
</div>
|
||||||
|
<template v-else>
|
||||||
|
<div
|
||||||
|
v-for="bovin in bovinList"
|
||||||
|
:key="bovin.id"
|
||||||
|
class="grid grid-cols-2 text-primary-700 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
@click="goToBovin(bovin.id)"
|
||||||
|
@keydown.enter="goToBovin(bovin.id)"
|
||||||
|
>
|
||||||
|
<div>{{ bovin.label }}</div>
|
||||||
|
<div>{{ bovin.code }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-center items-center">
|
||||||
|
<NuxtLink
|
||||||
|
to="/admin/bovin"
|
||||||
|
class="inline-flex items-center justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
||||||
|
:class="auth.isAdmin ? '' : 'cursor-not-allowed opacity-60'"
|
||||||
|
@click="handleAddClick"
|
||||||
|
>
|
||||||
|
<Icon name="mdi:plus" size="28" />
|
||||||
|
Ajouter
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getBovineTypeList } from "~/services/bovine-type"
|
||||||
|
import type { BovineTypeData } from "~/services/dto/bovine-type-data"
|
||||||
|
import { useAuthStore } from "~/stores/auth"
|
||||||
|
|
||||||
|
const bovinList = ref<BovineTypeData[]>([])
|
||||||
|
const router = useRouter()
|
||||||
|
const auth = useAuthStore()
|
||||||
|
|
||||||
|
const goToBovin = (id: number) => {
|
||||||
|
if (!auth.isAdmin) return
|
||||||
|
router.push(`/admin/bovin/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleAddClick = (event: Event) => {
|
||||||
|
if (auth.isAdmin) return
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (!auth.isAdmin) return
|
||||||
|
bovinList.value = await getBovineTypeList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<h1 class="text-3xl font-bold text-primary-500 uppercase">Liste des types bovins</h1>
|
|
||||||
<NuxtLink
|
|
||||||
to="/admin/bovin"
|
|
||||||
class="inline-flex items-center justify-center
|
|
||||||
text-xl text-white uppercase
|
|
||||||
bg-primary-500 h-[50px] px-8 rounded
|
|
||||||
hover:opacity-80 gap-2"
|
|
||||||
@click="handleAddClick"
|
|
||||||
>
|
|
||||||
<Icon name="mdi:plus" size="28" />
|
|
||||||
Ajouter
|
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
|
||||||
<div v-if="auth.isAdmin" class="mt-6 border border-slate-200 mb-16">
|
|
||||||
<div class="max-h-96 overflow-y-auto">
|
|
||||||
<div
|
|
||||||
class="sticky
|
|
||||||
grid grid-cols-2 gap-4
|
|
||||||
bg-slate-100 px-4 py-3
|
|
||||||
font-semibold uppercase
|
|
||||||
tracking-wide"
|
|
||||||
>
|
|
||||||
<div class="col-span-1">Nom</div>
|
|
||||||
<div class="col-span-1">Code</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="bovinList.length === 0" class="px-4 py-6 text-slate-400">
|
|
||||||
Aucun type de bovin.
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<div
|
|
||||||
v-for="bovin in bovinList"
|
|
||||||
:key="bovin.id"
|
|
||||||
class="grid grid-cols-2 border-t gap-4 px-4 py-2 hover:bg-slate-50 cursor-pointer"
|
|
||||||
@click="goToBovin(bovin.id)"
|
|
||||||
>
|
|
||||||
<div class="col-span-1">{{ bovin.label }}</div>
|
|
||||||
<div class="col-span-1">{{ bovin.code }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else class="mt-6 border border-slate-200 mb-16 px-4 py-6 text-slate-400">
|
|
||||||
Accès réservé aux administrateurs.
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { getBovineTypeList } from "~/services/bovine-type"
|
|
||||||
import type { BovineTypeData } from "~/services/dto/bovine-type-data"
|
|
||||||
import { useAuthStore } from "~/stores/auth"
|
|
||||||
|
|
||||||
const bovinList = ref<BovineTypeData[]>([])
|
|
||||||
const router = useRouter()
|
|
||||||
const auth = useAuthStore()
|
|
||||||
|
|
||||||
const goToBovin = (id: number) => {
|
|
||||||
if (!auth.isAdmin) return
|
|
||||||
router.push(`/admin/bovin/${id}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAddClick = (event: Event) => {
|
|
||||||
if (auth.isAdmin) return
|
|
||||||
event.preventDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
if (!auth.isAdmin) return
|
|
||||||
bovinList.value = await getBovineTypeList()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@@ -10,8 +10,8 @@
|
|||||||
class="cursor-pointer text-primary-500"
|
class="cursor-pointer text-primary-500"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="text-4xl text-primary-500 font-bold uppercase">
|
<h1 class="text-3xl text-primary-500 font-bold uppercase">
|
||||||
{{ route.params.id ? 'Modifications du transporteur' : 'Ajout d\'un transporteur' }}
|
{{ route.params.id ? 'Modification du transporteur' : 'Ajout d\'un transporteur' }}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -101,11 +101,10 @@ async function validate() {
|
|||||||
|
|
||||||
if(idCarrier.value){
|
if(idCarrier.value){
|
||||||
await updateCarrier(idCarrier.value, basePayload)
|
await updateCarrier(idCarrier.value, basePayload)
|
||||||
navigate()
|
|
||||||
return
|
return
|
||||||
}
|
}else{
|
||||||
await createCarrier(basePayload)
|
await createCarrier(basePayload)
|
||||||
navigate()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigate(){
|
function navigate(){
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="validate">
|
<form @submit.prevent="validate">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center relative">
|
||||||
<h1 class="text-3xl font-bold uppercase">
|
<div class="flex flex-row absolute -left-[60px] ">
|
||||||
{{ customerId ? "Modifications du client" : "Ajout d'un client" }}
|
<Icon @click="router.push('/admin/customer/customer-list')" name="gg:arrow-left-o" size="40" class="cursor-pointer text-primary-500"/>
|
||||||
|
</div>
|
||||||
|
<h1 class="text-3xl text-primary-500 font-bold uppercase">
|
||||||
|
{{ customerId ? "Modification du client" : "Ajout d'un client" }}
|
||||||
</h1>
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-cols-3 justify-between mb-11 pt-7">
|
||||||
|
<UiTextInput id="customer-name" v-model="form.name" label="Nom du client" :disabled="!auth.isAdmin" wrapper-class="w-[280px]"/>
|
||||||
|
<UiTextInput id="customer-phone" v-model="form.phone" label="Téléphone" :disabled="!auth.isAdmin" wrapper-class="w-[280px]"/>
|
||||||
|
<UiTextInput id="customer-email" v-model="form.email" label="Email" :disabled="!auth.isAdmin" wrapper-class="w-[280px]"/>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
<UiButton
|
<UiButton
|
||||||
class="inline-flex items-center justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
class="inline-flex mb-28 items-center justify-center text-xl min-w-[194px] text-white uppercase bg-primary-500 h-[50px] rounded hover:opacity-80 justify-self-end"
|
||||||
type="submit"
|
type="submit"
|
||||||
:disabled="isLoading || !auth.isAdmin"
|
:disabled="isLoading || !auth.isAdmin"
|
||||||
>
|
>
|
||||||
@@ -15,35 +25,19 @@
|
|||||||
</UiButton>
|
</UiButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-y-8 gap-x-80 mb-10 py-12">
|
<div class="flex items-center justify-between mb-7">
|
||||||
<UiTextInput id="customer-name" v-model="form.name" label="Nom du client" :disabled="!auth.isAdmin"/>
|
<h2 class="text-3xl text-primary-500 font-bold uppercase">Adresses du client</h2>
|
||||||
<UiTextInput id="customer-phone" v-model="form.phone" label="Téléphone" :disabled="!auth.isAdmin"/>
|
|
||||||
<UiTextInput id="customer-email" v-model="form.email" label="Email" :disabled="!auth.isAdmin"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="overflow-x-auto mb-11 text-primary-700">
|
||||||
<div class="mx-24 mb-4 py-6 border-t border-black"></div>
|
<table class="w-full border-collapse text-primary-700">
|
||||||
<div class="flex items-center justify-between mb-4">
|
|
||||||
<h2 class="text-3xl font-bold uppercase">Adresses client</h2>
|
|
||||||
<UiButton
|
|
||||||
type="button"
|
|
||||||
class="inline-flex items-center justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
|
||||||
:disabled="customerId === null || !auth.isAdmin"
|
|
||||||
@click="goToAddAddress"
|
|
||||||
>
|
|
||||||
<Icon name="mdi:plus" size="28" />
|
|
||||||
Ajouter
|
|
||||||
</UiButton>
|
|
||||||
</div>
|
|
||||||
<div class="overflow-x-auto mb-10">
|
|
||||||
<table class="w-full border-collapse">
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-left border-b border-gray-200">
|
<tr class="text-left border bg-slate-100 border-gray-200">
|
||||||
<th class="py-3 pr-4 text-sm uppercase">Libellé</th>
|
<th class="py-3 px-4 text-sm uppercase">Libellé</th>
|
||||||
<th class="py-3 pr-4 text-sm uppercase">Rue</th>
|
<th class="py-3 px-4 text-sm uppercase">Rue</th>
|
||||||
<th class="py-3 pr-4 text-sm uppercase">Complément</th>
|
<th class="py-3 px-4 text-sm uppercase">Complément</th>
|
||||||
<th class="py-3 pr-4 text-sm uppercase">Code postal</th>
|
<th class="py-3 px-4 text-sm uppercase">Code postal</th>
|
||||||
<th class="py-3 pr-4 text-sm uppercase">Ville</th>
|
<th class="py-3 px-4 text-sm uppercase">Ville</th>
|
||||||
<th class="py-3 pr-4 text-sm uppercase">Pays</th>
|
<th class="py-3 px-4 text-sm uppercase">Pays</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -58,21 +52,32 @@
|
|||||||
<tr
|
<tr
|
||||||
v-for="(address, index) in form.addresses"
|
v-for="(address, index) in form.addresses"
|
||||||
:key="address.id ?? index"
|
:key="address.id ?? index"
|
||||||
class="border-b border-gray-100 hover:bg-slate-50"
|
class="border border-gray-100 hover:bg-slate-50"
|
||||||
:class="auth.isAdmin ? 'cursor-pointer' : 'cursor-not-allowed opacity-60'"
|
:class="auth.isAdmin ? 'cursor-pointer' : 'cursor-not-allowed opacity-60'"
|
||||||
@click="goToEditAddress(address.id ?? null)"
|
@click="goToEditAddress(address.id ?? null)"
|
||||||
>
|
>
|
||||||
<td class="py-3 pr-4">{{ address.label || "—" }}</td>
|
<td class="py-3 px-4">{{ address.label || "—" }}</td>
|
||||||
<td class="py-3 pr-4">{{ address.street || "—" }}</td>
|
<td class="py-3 px-4">{{ address.street || "—" }}</td>
|
||||||
<td class="py-3 pr-4">{{ address.street2 || "—" }}</td>
|
<td class="py-3 px-4">{{ address.street2 || "—" }}</td>
|
||||||
<td class="py-3 pr-4">{{ address.postalCode || "—" }}</td>
|
<td class="py-3 px-4">{{ address.postalCode || "—" }}</td>
|
||||||
<td class="py-3 pr-4">{{ address.city || "—" }}</td>
|
<td class="py-3 px-4">{{ address.city || "—" }}</td>
|
||||||
<td class="py-3 pr-4">{{ address.countryCode || "—" }}</td>
|
<td class="py-3 px-4">{{ address.countryCode || "—" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex justify-center items-center">
|
||||||
|
<UiButton
|
||||||
|
type="button"
|
||||||
|
class="inline-flex items-center justify-center text-xl gap-2 text-white uppercase bg-primary-500 h-[50px] rounded hover:opacity-80 justify-self-end"
|
||||||
|
:disabled="customerId === null || !auth.isAdmin"
|
||||||
|
@click="goToAddAddress"
|
||||||
|
>
|
||||||
|
<Icon name="mdi:plus" size="28" />
|
||||||
|
Ajouter
|
||||||
|
</UiButton>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ const addressId = computed(() => (route.query.addressId !== undefined ? Number(r
|
|||||||
const address = ref<AddressData | null>(null)
|
const address = ref<AddressData | null>(null)
|
||||||
|
|
||||||
const validate = async (payload: AddressPayload) => {
|
const validate = async (payload: AddressPayload) => {
|
||||||
try {
|
|
||||||
if (addressId.value !== null) {
|
if (addressId.value !== null) {
|
||||||
await updateAddress(addressId.value, payload)
|
await updateAddress(addressId.value, payload)
|
||||||
} else {
|
} else {
|
||||||
await addAddress(payload)
|
await addAddress(payload)
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
await router.push("/admin/customer/" + customerId.value)
|
await router.push("/admin/customer/" + customerId.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h1 class="text-3xl font-bold uppercase text-primary-500">Liste des Clients</h1>
|
<h1 class="text-4xl font-bold uppercase text-primary-500">Liste des clients</h1>
|
||||||
<NuxtLink
|
|
||||||
to="/admin/customer"
|
|
||||||
class="inline-flex items-center justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
|
||||||
:class="auth.isAdmin ? '' : 'cursor-not-allowed opacity-60'"
|
|
||||||
@click="handleAddClick"
|
|
||||||
>
|
|
||||||
<Icon name="mdi:plus" size="28" />
|
|
||||||
Ajouter
|
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="auth.isAdmin" class="mt-6 border border-slate-200 mb-16">
|
<div v-if="auth.isAdmin" class="mt-7 border border-slate-200 mb-11">
|
||||||
<div class="max-h-96 overflow-y-auto">
|
<div class="max-h-96 overflow-y-auto">
|
||||||
<div
|
<div
|
||||||
class="sticky top-0 z-10 grid grid-cols-8 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide"
|
class="sticky text-primary-700 top-0 z-10 grid grid-cols-8 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide"
|
||||||
>
|
>
|
||||||
<div>Nom</div>
|
<div>Nom</div>
|
||||||
<div>Téléphone</div>
|
<div>Téléphone</div>
|
||||||
@@ -34,7 +25,7 @@
|
|||||||
<div v-for="customer in customerList" :key="customer.id">
|
<div v-for="customer in customerList" :key="customer.id">
|
||||||
<div
|
<div
|
||||||
v-if="!customer.addresses || customer.addresses.length === 0"
|
v-if="!customer.addresses || customer.addresses.length === 0"
|
||||||
class="grid grid-cols-8 border-t gap-4 px-4 py-2 hover:bg-slate-50 cursor-pointer"
|
class="grid text-primary-700 grid-cols-8 border-t gap-4 px-4 py-2 hover:bg-slate-50 cursor-pointer"
|
||||||
@click="goToCustomer(customer.id)"
|
@click="goToCustomer(customer.id)"
|
||||||
>
|
>
|
||||||
<div class="truncate">{{ customer.name || "—" }}</div>
|
<div class="truncate">{{ customer.name || "—" }}</div>
|
||||||
@@ -51,7 +42,7 @@
|
|||||||
<div
|
<div
|
||||||
v-for="(address, idx) in customer.addresses"
|
v-for="(address, idx) in customer.addresses"
|
||||||
:key="address.id ?? `${customer.id}-${idx}-${address.street}-${address.postalCode}`"
|
:key="address.id ?? `${customer.id}-${idx}-${address.street}-${address.postalCode}`"
|
||||||
class="grid grid-cols-8 hover:bg-slate-50 border-t gap-4 px-4 py-2 cursor-pointer"
|
class="grid grid-cols-8 text-primary-700 hover:bg-slate-50 border-t gap-4 px-4 py-2 cursor-pointer"
|
||||||
:class="idx > 0 ? 'pl-4 border-l-4 border-l-slate-200 bg-slate-50' : ''"
|
:class="idx > 0 ? 'pl-4 border-l-4 border-l-slate-200 bg-slate-50' : ''"
|
||||||
@click="goToCustomer(customer.id)"
|
@click="goToCustomer(customer.id)"
|
||||||
>
|
>
|
||||||
@@ -70,7 +61,7 @@
|
|||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div
|
<div
|
||||||
class="grid grid-cols-8 hover:bg-slate-50 border-t gap-4 px-4 py-2 cursor-pointer"
|
class="grid grid-cols-8 text-primary-700 hover:bg-slate-50 border-t gap-4 px-4 py-2 cursor-pointer"
|
||||||
@click="goToCustomer(customer.id)"
|
@click="goToCustomer(customer.id)"
|
||||||
>
|
>
|
||||||
<div class="truncate">{{ customer.name || "—" }}</div>
|
<div class="truncate">{{ customer.name || "—" }}</div>
|
||||||
@@ -84,9 +75,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="mt-6 border border-slate-200 mb-16 px-4 py-6 text-slate-400">
|
<div v-else class="mt-7 border border-slate-200 mb-11 px-4 py-6 text-slate-400">
|
||||||
Accès réservé aux administrateurs.
|
Accès réservé aux administrateurs.
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex justify-center items-center">
|
||||||
|
<NuxtLink
|
||||||
|
to="/admin/customer"
|
||||||
|
class="inline-flex items-center mb-16 justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
||||||
|
:class="auth.isAdmin ? '' : 'cursor-not-allowed opacity-60'"
|
||||||
|
@click="handleAddClick"
|
||||||
|
>
|
||||||
|
<Icon name="mdi:plus" size="28" />
|
||||||
|
Ajouter
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<Icon @click="router.push('/admin/supplier/supplier-list')" name="gg:arrow-left-o" size="40" class="cursor-pointer text-primary-500"/>
|
<Icon @click="router.push('/admin/supplier/supplier-list')" name="gg:arrow-left-o" size="40" class="cursor-pointer text-primary-500"/>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="text-3xl text-primary-500 font-bold uppercase">
|
<h1 class="text-3xl text-primary-500 font-bold uppercase">
|
||||||
{{ supplierId ? "Modifications du fournisseur" : "Ajout d'un fournisseur" }}
|
{{ supplierId ? "Modification du fournisseur" : "Ajout d'un fournisseur" }}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center justify-between mb-7">
|
<div class="flex items-center justify-between mb-7">
|
||||||
<h2 class="text-3xl text-primary-500 font-bold uppercase">Adresses fournisseur</h2>
|
<h2 class="text-3xl text-primary-500 font-bold uppercase">Adresses du fournisseur</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-x-auto mb-11 text-primary-700">
|
<div class="overflow-x-auto mb-11 text-primary-700">
|
||||||
<table class="w-full border-collapse">
|
<table class="w-full border-collapse">
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ const addressId = computed(() => { return route.query.addressId !== undefined ?
|
|||||||
const address = ref<AddressData|null>(null)
|
const address = ref<AddressData|null>(null)
|
||||||
|
|
||||||
const validate = async (address: AddressPayload) => {
|
const validate = async (address: AddressPayload) => {
|
||||||
try {
|
|
||||||
if (addressId.value !== null) {
|
if (addressId.value !== null) {
|
||||||
await updateAddress(addressId.value, address)
|
await updateAddress(addressId.value, address)
|
||||||
} else {
|
} else {
|
||||||
await addAddress(address)
|
await addAddress(address)
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
await router.push('/admin/supplier/' + supplierId.value)
|
await router.push('/admin/supplier/' + supplierId.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,70 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="validate">
|
<form @submit.prevent="validate">
|
||||||
<div
|
<div class="flex items-center relative">
|
||||||
class="flex items-center justify-between gap-10">
|
<div class="flex flex-row absolute -left-[60px]">
|
||||||
<h1 class="text-3xl font-bold uppercase">
|
<Icon
|
||||||
{{ userId ? "Modifications de l'utilisateur" : "Ajout d'un utilisateur" }}
|
@click="router.push('/admin/user/list')"
|
||||||
|
name="gg:arrow-left-o"
|
||||||
|
size="40"
|
||||||
|
class="cursor-pointer text-primary-500"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<h1 class="text-3xl text-primary-500 font-bold uppercase">
|
||||||
|
{{ userId ? "Modification de l'utilisateur" : "Ajout d'un utilisateur" }}
|
||||||
</h1>
|
</h1>
|
||||||
<UiButton
|
|
||||||
class="inline-flex items-center justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
<Icon :name="userId ? '' : 'mdi:plus'" size="28" />
|
|
||||||
{{ userId ? 'Valider' : 'Ajouter' }}
|
|
||||||
</UiButton>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid gap-y-16 gap-x-40 py-12">
|
<div class="flex flex-cols-3 justify-between mb-11 pt-7">
|
||||||
<UiTextInput
|
<UiTextInput
|
||||||
id="user-name"
|
id="user-name"
|
||||||
v-model="form.username"
|
v-model="form.username"
|
||||||
label="Nom de l'utilisateur"
|
label="Nom de l'utilisateur"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
wrapper-class="w-[280px]"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UiSelect
|
<UiSelect
|
||||||
id="user-role"
|
id="user-role"
|
||||||
v-model="form.role"
|
v-model="form.role"
|
||||||
label="Rôle de l'utilisateur"
|
label="Role de l'utilisateur"
|
||||||
:options="ROLE"
|
:options="ROLE"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
wrapper-class="w-[280px]"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UiTextInput
|
<UiTextInput
|
||||||
id="user-password"
|
id="user-password"
|
||||||
v-model="form.password"
|
v-model="form.password"
|
||||||
label="Mot de passe"
|
label="Mot de passe"
|
||||||
type="password"
|
type="password"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
wrapper-class="w-[280px]"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<UiButton
|
||||||
|
class="inline-flex mb-28 items-center justify-center text-xl min-w-[194px] text-white uppercase bg-primary-500 h-[50px] rounded hover:opacity-80 justify-self-end"
|
||||||
|
type="submit"
|
||||||
|
:disabled="isLoading || isHydrating || !auth.isAdmin"
|
||||||
|
>
|
||||||
|
<Icon :name="userId ? '' : 'mdi:plus'" size="28" />
|
||||||
|
{{ userId ? 'Valider' : 'Ajouter' }}
|
||||||
|
</UiButton>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed, reactive, ref, watch} from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import {ROLE} from '~/utils/constants'
|
import { ROLE } from '~/utils/constants'
|
||||||
import {createUser, updateUser, getUser} from '~/services/auth'
|
import { createUser, updateUser, getUser } from '~/services/auth'
|
||||||
import type {UserData, UserFormData, UserPayload} from '~/services/dto/user-data'
|
import type { UserData, UserFormData, UserPayload } from '~/services/dto/user-data'
|
||||||
|
import { useAuthStore } from '~/stores/auth'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const auth = useAuthStore()
|
||||||
const userId = computed(() => resolveUserId(route.params.id))
|
const userId = computed(() => resolveUserId(route.params.id))
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
const isHydrating = ref(false)
|
const isHydrating = ref(false)
|
||||||
@@ -59,7 +78,6 @@ const resolveUserId = (param: unknown) => {
|
|||||||
return Number.isFinite(id) ? id : null
|
return Number.isFinite(id) ? id : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const form = reactive<UserFormData>({
|
const form = reactive<UserFormData>({
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
@@ -73,8 +91,8 @@ const hydrateFromUser = (user: UserData | null) => {
|
|||||||
isHydrating.value = true
|
isHydrating.value = true
|
||||||
form.username = user.username ?? ''
|
form.username = user.username ?? ''
|
||||||
const roles = user.roles ?? []
|
const roles = user.roles ?? []
|
||||||
const hasAdmin = roles.includes("ROLE_ADMIN")
|
const hasAdmin = roles.includes('ROLE_ADMIN')
|
||||||
form.role = hasAdmin ? "ROLE_ADMIN" : "ROLE_USER"
|
form.role = hasAdmin ? 'ROLE_ADMIN' : 'ROLE_USER'
|
||||||
form.password = ''
|
form.password = ''
|
||||||
isHydrating.value = false
|
isHydrating.value = false
|
||||||
}
|
}
|
||||||
@@ -93,10 +111,11 @@ watch(
|
|||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{immediate: true}
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
async function validate() {
|
async function validate() {
|
||||||
|
if (!auth.isAdmin) return
|
||||||
|
|
||||||
const normalizedUsername = form.username.trim()
|
const normalizedUsername = form.username.trim()
|
||||||
const normalizedRole = form.role.trim()
|
const normalizedRole = form.role.trim()
|
||||||
@@ -112,13 +131,12 @@ async function validate() {
|
|||||||
|
|
||||||
if (userId.value) {
|
if (userId.value) {
|
||||||
await updateUser(userId.value, basePayload)
|
await updateUser(userId.value, basePayload)
|
||||||
await router.push(`/admin/user/list/`)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const created = await createUser(basePayload)
|
const created = await createUser(basePayload)
|
||||||
if (created) {
|
if (created) {
|
||||||
await router.push(`/admin/user/list/`)
|
await router.push('/admin/user/list')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,58 +1,72 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h1 class="text-3xl font-bold uppercase text-primary-500">Liste des utilisateurs</h1>
|
<h1 class="text-4xl font-bold uppercase text-primary-500">Liste des utilisateurs</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="auth.isAdmin" class="mt-7 border border-slate-200 mb-11">
|
||||||
|
<div class="grid grid-cols-2 text-primary-700 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
||||||
|
<div>Utilisateur</div>
|
||||||
|
<div>Role</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="userList.length === 0" class="px-4 py-6 text-slate-400">
|
||||||
|
Aucun utilisateur.
|
||||||
|
</div>
|
||||||
|
<template v-else>
|
||||||
|
<div
|
||||||
|
v-for="user in userList"
|
||||||
|
:key="user.id"
|
||||||
|
class="grid grid-cols-2 text-primary-700 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200 items-center"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
@click="goToUser(user.id)"
|
||||||
|
@keydown.enter="goToUser(user.id)"
|
||||||
|
>
|
||||||
|
<div>{{ user.username }}</div>
|
||||||
|
<div>{{ getRoleLabels(user.roles) }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div v-else class="mt-7 border border-slate-200 mb-11 px-4 py-6 text-slate-400">
|
||||||
|
Acces reserve aux administrateurs.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-center items-center">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
to="/admin/user"
|
to="/admin/user"
|
||||||
class="inline-flex items-center justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
class="inline-flex items-center mb-16 justify-center text-xl text-white uppercase bg-primary-500 h-[50px] px-8 rounded hover:opacity-80 gap-2"
|
||||||
|
:class="auth.isAdmin ? '' : 'cursor-not-allowed opacity-60'"
|
||||||
|
@click="handleAddClick"
|
||||||
>
|
>
|
||||||
<Icon name="mdi:plus" size="28" />
|
<Icon name="mdi:plus" size="28" />
|
||||||
Ajouter
|
Ajouter
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div class="mt-6 border border-slate-200 mb-16 ">
|
|
||||||
<div class="grid grid-cols-3 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
|
||||||
<div>Username</div>
|
|
||||||
<div>Role</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="user in userList"
|
|
||||||
:key="user.id"
|
|
||||||
class="grid grid-cols-3 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t items-center"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
@click="goToUser(user.id)"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
{{ user.username }}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{{ getRoleLabels(user.roles) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type {UserData} from "~/services/dto/user-data";
|
import type { UserData } from "~/services/dto/user-data"
|
||||||
import {getAdminUsers} from "~/services/auth";
|
import { getAdminUsers } from "~/services/auth"
|
||||||
import {ROLE} from "~/utils/constants";
|
import { ROLE } from "~/utils/constants"
|
||||||
|
import { useAuthStore } from "~/stores/auth"
|
||||||
|
|
||||||
const userList = ref<UserData[]>([])
|
const userList = ref<UserData[]>([])
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const auth = useAuthStore()
|
||||||
const roleLabelByValue = new Map(ROLE.map((role) => [role.value, role.label]))
|
const roleLabelByValue = new Map(ROLE.map((role) => [role.value, role.label]))
|
||||||
|
|
||||||
const goToUser = (id: number) => {
|
const goToUser = (id: number) => {
|
||||||
|
if (!auth.isAdmin) return
|
||||||
router.push(`/admin/user/${id}`)
|
router.push(`/admin/user/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleAddClick = (event: Event) => {
|
||||||
|
if (auth.isAdmin) return
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
const getRoleLabels = (roles?: string[]) => {
|
const getRoleLabels = (roles?: string[]) => {
|
||||||
if (!roles || roles.length === 0) {
|
if (!roles || roles.length === 0) {
|
||||||
return ' ---'
|
return '---'
|
||||||
}
|
}
|
||||||
|
|
||||||
return roles
|
return roles
|
||||||
@@ -61,6 +75,7 @@ const getRoleLabels = (roles?: string[]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
if (!auth.isAdmin) return
|
||||||
userList.value = await getAdminUsers()
|
userList.value = await getAdminUsers()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -24,19 +24,27 @@ export async function getBovineTypeList(): Promise<BovineTypeData[]> {
|
|||||||
|
|
||||||
export async function getBovin(id: number): Promise<BovineTypeData> {
|
export async function getBovin(id: number): Promise<BovineTypeData> {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
const response = await api.get<BovineTypeData>(`bovine_types/${id}`)
|
const response = await api.get<BovineTypeData>(`bovine_types/${id}`, {}, {
|
||||||
|
toastErrorKey: 'errors.bovin.fetch'
|
||||||
|
})
|
||||||
return mapToBovineTypeData(response)
|
return mapToBovineTypeData(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createBovin(payload: BovinPayload = {}): Promise<BovineTypeData> {
|
export async function createBovin(payload: BovinPayload = {}): Promise<BovineTypeData> {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
const response = await api.post<BovineTypeData>('bovine_types', toBovineTypePayload(payload))
|
const response = await api.post<BovineTypeData>('bovine_types', toBovineTypePayload(payload), {
|
||||||
|
toastErrorKey: 'errors.bovin.create',
|
||||||
|
toastSuccessKey: 'success.bovin.create'
|
||||||
|
})
|
||||||
return mapToBovineTypeData(response)
|
return mapToBovineTypeData(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateBovin(id: number, payload: BovinPayload = {}): Promise<BovineTypeData> {
|
export async function updateBovin(id: number, payload: BovinPayload = {}): Promise<BovineTypeData> {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
const response = await api.patch<BovineTypeData>(`bovine_types/${id}`, toBovineTypePayload(payload))
|
const response = await api.patch<BovineTypeData>(`bovine_types/${id}`, toBovineTypePayload(payload), {
|
||||||
|
toastErrorKey: 'errors.bovin.update',
|
||||||
|
toastSuccessKey: 'success.bovin.update'
|
||||||
|
})
|
||||||
return mapToBovineTypeData(response)
|
return mapToBovineTypeData(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user