Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(post): integrate to create post resource
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Oct 11, 2022
1 parent 45dd896 commit 83a67e2
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions components/post/create_post_form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const postAttachmentFetcher = new PostAttachmentFetcher()
const { isShown } = defineProps<{ isShown: boolean }>()
const departmentID = ref("")
const userID = ref("")
const roleID = ref("")
const content = ref("")
const attachmentResources = ref<DeserializedPostAttachmentResource[]>([])
Expand Down Expand Up @@ -70,7 +73,41 @@ function uploadPostAttachment(event: Event): void {
})
}
function createPost(data: FormData): void {
fetcher.create(data).then()
function createPost(): void {
fetcher.create({
"content": content.value,
"deletedAt": null
}, {
"extraCreateDocumentProps": {
"relationships": {
"department": {
"data": {
"id": departmentID.value,
"type": "department"
}
},
"postAttachments": {
"data": attachmentResources.value.map(resource => ({
"id": resource.id,
"type": "post_attachment"
}))
},
"poster": {
"data": {
"id": userID.value,
"type": "user"
}
},
"posterRole": {
"data": {
"id": roleID.value,
"type": "role"
}
}
}
}
}).then(() => {
close()
}).catch(console.log)
}
</script>

0 comments on commit 83a67e2

Please sign in to comment.