fix params.id

This commit is contained in:
2023-04-23 20:35:31 +10:00
parent 072ab038fe
commit 2d7a91e368

View File

@@ -158,9 +158,8 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const pageError = ref(200); const pageError = ref(200);
const pageLoading = ref(true); const pageLoading = ref(false);
const pageHeading = const pageHeading = route.params.id ? "Edit Event" : "Create Event";
route.params.id !== "create" ? "Edit Event" : "Create Event";
const attachments = ref([]); const attachments = ref([]);
@@ -231,9 +230,7 @@ let form = reactive(
]) ])
), ),
publish_at: FormControl( publish_at: FormControl(
route.params.id !== "create" route.params.id ? "" : new SMDate("now").format("d/M/yy h:mm aa"),
? ""
: new SMDate("now").format("d/M/yy h:mm aa"),
DateTime() DateTime()
), ),
status: FormControl(), status: FormControl(),
@@ -267,7 +264,7 @@ let form = reactive(
); );
const loadData = async () => { const loadData = async () => {
if (route.params.id !== "create") { if (route.params.id) {
try { try {
pageLoading.value = true; pageLoading.value = true;
@@ -316,7 +313,7 @@ const loadData = async () => {
return attachment.id.toString(); return attachment.id.toString();
}); });
} catch (err) { } catch (err) {
pageError.value = err.response.status; pageError.value = err.status;
} finally { } finally {
pageLoading.value = false; pageLoading.value = false;
} }
@@ -352,7 +349,7 @@ const handleSubmit = async () => {
let event_id = ""; let event_id = "";
if (route.params.id !== "create") { if (route.params.id) {
event_id = route.params.id as string; event_id = route.params.id as string;
await api.put({ await api.put({
url: "/events/{id}", url: "/events/{id}",
@@ -381,10 +378,7 @@ const handleSubmit = async () => {
}); });
useToastStore().addToast({ useToastStore().addToast({
title: title: route.params.id ? "Event Updated" : "Event Created",
route.params.id !== "create"
? "Event Updated"
: "Event Created",
content: route.params.id content: route.params.id
? "The event has been updated." ? "The event has been updated."
: "The event has been created.", : "The event has been created.",