fix : review MR
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
<div class="col-span-1">Code</div>
|
||||
</div>
|
||||
<div v-if="bovinList.length === 0" class="px-4 py-6 text-slate-400">
|
||||
Aucun client.
|
||||
Aucun type de bovin.
|
||||
</div>
|
||||
<div v-else>
|
||||
<div
|
||||
@@ -34,7 +34,7 @@
|
||||
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.name }}</div>
|
||||
<div class="col-span-1">{{ bovin.label }}</div>
|
||||
<div class="col-span-1">{{ bovin.code }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -46,11 +46,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getBovinList } from "~/services/bovine-type"
|
||||
import type { BovinData } from "~/services/dto/bovine-type-data"
|
||||
import { getBovineTypeList } from "~/services/bovine-type"
|
||||
import type { BovineTypeData } from "~/services/dto/bovine-type-data"
|
||||
import { useAuthStore } from "~/stores/auth"
|
||||
|
||||
const bovinList = ref<BovinData[]>([])
|
||||
const bovinList = ref<BovineTypeData[]>([])
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
|
||||
@@ -66,6 +66,6 @@ const handleAddClick = (event: Event) => {
|
||||
|
||||
onMounted(async () => {
|
||||
if (!auth.isAdmin) return
|
||||
bovinList.value = await getBovinList()
|
||||
bovinList.value = await getBovineTypeList()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -22,21 +22,6 @@ export async function getBovineTypeList(): Promise<BovineTypeData[]> {
|
||||
return []
|
||||
}
|
||||
|
||||
export async function getBovinList(): Promise<BovinData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<BovineTypeListResponse>('bovine_types', {}, {
|
||||
toastErrorKey: 'errors.bovin.list'
|
||||
})
|
||||
|
||||
const items = Array.isArray(response)
|
||||
? response
|
||||
: response && typeof response === 'object' && Array.isArray(response['hydra:member'])
|
||||
? response['hydra:member']
|
||||
: []
|
||||
|
||||
return items.map(mapToBovinData)
|
||||
}
|
||||
|
||||
export async function getBovin(id: number): Promise<BovinData> {
|
||||
const api = useApi()
|
||||
const response = await api.get<BovineTypeData>(`bovine_types/${id}`)
|
||||
|
||||
@@ -4,12 +4,6 @@ export interface BovineTypeData{
|
||||
code: string
|
||||
}
|
||||
|
||||
export interface BovinData {
|
||||
id: number
|
||||
name: string
|
||||
code: string
|
||||
}
|
||||
|
||||
export interface BovinFormData {
|
||||
name: string
|
||||
code: string
|
||||
|
||||
Reference in New Issue
Block a user