feat [front]: fix some types
This commit is contained in:
parent
ac07bf5e1a
commit
c91ae8e6a2
|
@ -199,22 +199,24 @@ const emits = defineEmits(["save", "publish", "update:modelValue"])
|
|||
const film = useModel<Film>("modelValue", { type: "object" })
|
||||
|
||||
const foundFilms = ref()
|
||||
const chosenFilm = ref<Film | undefined>()
|
||||
// https://developers.themoviedb.org/3/getting-started/images
|
||||
const image = computed(() => (index: number) => {
|
||||
return `https://image.tmdb.org/t/p/w500${foundFilms.value[index]?.posterPath}`
|
||||
})
|
||||
|
||||
const durationNoSecond = computed<string>({
|
||||
const durationNoSecond = computed<string | undefined>({
|
||||
get: () => film.value.duration,
|
||||
set(value: string) {
|
||||
film.value.duration = value.replace(/:\d{2}$/, ":00")
|
||||
set(value: string | undefined) {
|
||||
film.value.duration = value?.replace(/:\d{2}$/, ":00")
|
||||
},
|
||||
})
|
||||
|
||||
const projectionDateObject = computed<Date>({
|
||||
get: () => new Date(film.value.projectionDate),
|
||||
set(value: Date) {
|
||||
film.value.projectionDate = value.toISOString()
|
||||
const projectionDateObject = computed<Date | undefined>({
|
||||
get: () =>
|
||||
film.value.projectionDate ? new Date(film.value.projectionDate) : undefined,
|
||||
set(value: Date | undefined) {
|
||||
film.value.projectionDate = value?.toISOString()
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<h1 hidden>Page d'accueil</h1>
|
||||
<section class="section">
|
||||
<h2 class="title">La semaine prochaine</h2>
|
||||
<MovieCardFull :film="firstFilm" />
|
||||
<template v-if="firstFilm">
|
||||
<MovieCardFull :film="firstFilm" />
|
||||
</template>
|
||||
</section>
|
||||
<section v-if="nextFilms.length" class="section is-relative">
|
||||
<h2 class="title">Et après</h2>
|
||||
|
@ -35,9 +37,9 @@ import "swiper/css/navigation"
|
|||
const modules = ref<SwiperModule[]>([Navigation])
|
||||
|
||||
const films = ref<Film[]>()
|
||||
films.value = (await apiGet<Film[]>(`films/`)).data.value
|
||||
const firstFilm = computed(() => films.value[0])
|
||||
const nextFilms = computed(() => films.value.slice(1))
|
||||
films.value = ((await apiGet<Film[]>(`films/`)).data.value || []) as Film[]
|
||||
const firstFilm = computed(() => films.value?.[0])
|
||||
const nextFilms = computed(() => films.value?.slice(1))
|
||||
</script>
|
||||
|
||||
<style lang="sass">
|
||||
|
|
Loading…
Reference in a new issue