From c91ae8e6a2b508743b13e3c12863ddecab618ced Mon Sep 17 00:00:00 2001 From: _aandres Date: Sun, 4 Dec 2022 01:26:43 +0100 Subject: [PATCH] feat [front]: fix some types --- front/components/admin/form.vue | 16 +++++++++------- front/pages/index.vue | 10 ++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/front/components/admin/form.vue b/front/components/admin/form.vue index b59837d..20b1629 100644 --- a/front/components/admin/form.vue +++ b/front/components/admin/form.vue @@ -199,22 +199,24 @@ const emits = defineEmits(["save", "publish", "update:modelValue"]) const film = useModel("modelValue", { type: "object" }) const foundFilms = ref() +const chosenFilm = ref() // 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({ +const durationNoSecond = computed({ 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({ - get: () => new Date(film.value.projectionDate), - set(value: Date) { - film.value.projectionDate = value.toISOString() +const projectionDateObject = computed({ + get: () => + film.value.projectionDate ? new Date(film.value.projectionDate) : undefined, + set(value: Date | undefined) { + film.value.projectionDate = value?.toISOString() }, }) diff --git a/front/pages/index.vue b/front/pages/index.vue index 938d485..a9c7d36 100644 --- a/front/pages/index.vue +++ b/front/pages/index.vue @@ -3,7 +3,9 @@

Page d'accueil

La semaine prochaine

- +

Et après

@@ -35,9 +37,9 @@ import "swiper/css/navigation" const modules = ref([Navigation]) const films = ref() -films.value = (await apiGet(`films/`)).data.value -const firstFilm = computed(() => films.value[0]) -const nextFilms = computed(() => films.value.slice(1)) +films.value = ((await apiGet(`films/`)).data.value || []) as Film[] +const firstFilm = computed(() => films.value?.[0]) +const nextFilms = computed(() => films.value?.slice(1))