added event attachments support
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<div class="sm-workshop-body">
|
||||
<h2 class="sm-workshop-title">{{ event.title }}</h2>
|
||||
<SMHTML :html="event.content" class="sm-workshop-content" />
|
||||
<SMAttachments :attachments="event.attachments || []" />
|
||||
</div>
|
||||
<div class="sm-workshop-info">
|
||||
<div
|
||||
@@ -119,6 +120,7 @@ import { useRoute } from "vue-router";
|
||||
import SMButton from "../components/SMButton.vue";
|
||||
import SMHTML from "../components/SMHTML.vue";
|
||||
import SMMessage from "../components/SMMessage.vue";
|
||||
import SMAttachments from "../components/SMAttachments.vue";
|
||||
import { api } from "../helpers/api";
|
||||
import { Event, EventResponse, MediaResponse } from "../helpers/api.types";
|
||||
import { SMDate } from "../helpers/datetime";
|
||||
|
||||
@@ -299,6 +299,12 @@ const loadData = async () => {
|
||||
form.controls.hero.value = data.event.hero;
|
||||
form.controls.price.value = data.event.price;
|
||||
form.controls.ages.value = data.event.ages;
|
||||
|
||||
attachments.value = (data.event.attachments || []).map(function (
|
||||
attachment
|
||||
) {
|
||||
return attachment.id.toString();
|
||||
});
|
||||
} catch (err) {
|
||||
pageError.value = err.response.status;
|
||||
} finally {
|
||||
@@ -334,7 +340,10 @@ const handleSubmit = async () => {
|
||||
ages: form.controls.ages.value,
|
||||
};
|
||||
|
||||
let event_id = "";
|
||||
|
||||
if (route.params.id) {
|
||||
event_id = route.params.id as string;
|
||||
await api.put({
|
||||
url: "/events/{id}",
|
||||
params: {
|
||||
@@ -343,12 +352,24 @@ const handleSubmit = async () => {
|
||||
body: data,
|
||||
});
|
||||
} else {
|
||||
await api.post({
|
||||
let result = await api.post({
|
||||
url: "/events",
|
||||
body: data,
|
||||
});
|
||||
|
||||
if (result.data) {
|
||||
const data = result.data as EventResponse;
|
||||
event_id = data.event.id;
|
||||
}
|
||||
}
|
||||
|
||||
await api.put({
|
||||
url: `/events/${event_id}/attachments`,
|
||||
body: {
|
||||
attachments: attachments.value,
|
||||
},
|
||||
});
|
||||
|
||||
useToastStore().addToast({
|
||||
title: route.params.id ? "Event Updated" : "Event Created",
|
||||
content: route.params.id
|
||||
|
||||
Reference in New Issue
Block a user