From 2d7a91e3683985d60d459f452c4f49208c515589 Mon Sep 17 00:00:00 2001 From: James Collins Date: Sun, 23 Apr 2023 20:35:31 +1000 Subject: [PATCH] fix params.id --- resources/js/views/dashboard/EventEdit.vue | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/resources/js/views/dashboard/EventEdit.vue b/resources/js/views/dashboard/EventEdit.vue index fbb7c8e..5a5473c 100644 --- a/resources/js/views/dashboard/EventEdit.vue +++ b/resources/js/views/dashboard/EventEdit.vue @@ -158,9 +158,8 @@ const route = useRoute(); const router = useRouter(); const pageError = ref(200); -const pageLoading = ref(true); -const pageHeading = - route.params.id !== "create" ? "Edit Event" : "Create Event"; +const pageLoading = ref(false); +const pageHeading = route.params.id ? "Edit Event" : "Create Event"; const attachments = ref([]); @@ -231,9 +230,7 @@ let form = reactive( ]) ), publish_at: FormControl( - route.params.id !== "create" - ? "" - : new SMDate("now").format("d/M/yy h:mm aa"), + route.params.id ? "" : new SMDate("now").format("d/M/yy h:mm aa"), DateTime() ), status: FormControl(), @@ -267,7 +264,7 @@ let form = reactive( ); const loadData = async () => { - if (route.params.id !== "create") { + if (route.params.id) { try { pageLoading.value = true; @@ -316,7 +313,7 @@ const loadData = async () => { return attachment.id.toString(); }); } catch (err) { - pageError.value = err.response.status; + pageError.value = err.status; } finally { pageLoading.value = false; } @@ -352,7 +349,7 @@ const handleSubmit = async () => { let event_id = ""; - if (route.params.id !== "create") { + if (route.params.id) { event_id = route.params.id as string; await api.put({ url: "/events/{id}", @@ -381,10 +378,7 @@ const handleSubmit = async () => { }); useToastStore().addToast({ - title: - route.params.id !== "create" - ? "Event Updated" - : "Event Created", + title: route.params.id ? "Event Updated" : "Event Created", content: route.params.id ? "The event has been updated." : "The event has been created.",