Bovins Admin #29
@@ -25,7 +25,7 @@
|
|||||||
<div class="col-span-1">Code</div>
|
<div class="col-span-1">Code</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="bovinList.length === 0" class="px-4 py-6 text-slate-400">
|
<div v-if="bovinList.length === 0" class="px-4 py-6 text-slate-400">
|
||||||
Aucun client.
|
Aucun type de bovin.
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div
|
<div
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
class="grid grid-cols-2 border-t gap-4 px-4 py-2 hover:bg-slate-50 cursor-pointer"
|
class="grid grid-cols-2 border-t gap-4 px-4 py-2 hover:bg-slate-50 cursor-pointer"
|
||||||
@click="goToBovin(bovin.id)"
|
@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 class="col-span-1">{{ bovin.code }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getBovinList } from "~/services/bovine-type"
|
import { getBovineTypeList } from "~/services/bovine-type"
|
||||||
import type { BovinData } from "~/services/dto/bovine-type-data"
|
import type { BovineTypeData } from "~/services/dto/bovine-type-data"
|
||||||
import { useAuthStore } from "~/stores/auth"
|
import { useAuthStore } from "~/stores/auth"
|
||||||
|
|
||||||
const bovinList = ref<BovinData[]>([])
|
const bovinList = ref<BovineTypeData[]>([])
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
|
|
||||||
@@ -66,6 +66,6 @@ const handleAddClick = (event: Event) => {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!auth.isAdmin) return
|
if (!auth.isAdmin) return
|
||||||
bovinList.value = await getBovinList()
|
bovinList.value = await getBovineTypeList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -22,21 +22,6 @@ export async function getBovineTypeList(): Promise<BovineTypeData[]> {
|
|||||||
return []
|
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> {
|
export async function getBovin(id: number): Promise<BovinData> {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
const response = await api.get<BovineTypeData>(`bovine_types/${id}`)
|
const response = await api.get<BovineTypeData>(`bovine_types/${id}`)
|
||||||
|
|||||||
@@ -4,12 +4,6 @@ export interface BovineTypeData{
|
|||||||
code: string
|
code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BovinData {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
code: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BovinFormData {
|
export interface BovinFormData {
|
||||||
name: string
|
name: string
|
||||||
code: string
|
code: string
|
||||||
|
|||||||
Reference in New Issue
Block a user