responses and general modifications
This commit is contained in:
@ -1,3 +1,10 @@
|
||||
/*******************************************************
|
||||
* File: forum.js
|
||||
* Author: Anthony Debucquoy
|
||||
* Scope: Extension messagerie
|
||||
* Description: Forum related functions and calls
|
||||
*******************************************************/
|
||||
|
||||
import { ref } from 'vue'
|
||||
import { restGet, restPost, restDelete, restPatch } from './restConsumer.js'
|
||||
|
||||
@ -18,17 +25,11 @@ export function createForum(id, name){
|
||||
* List post of a specified forum
|
||||
*/
|
||||
export async function getPostsOfForum(id){
|
||||
PostsOfCurrentForum.value = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Post~1"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Post~2"
|
||||
},
|
||||
]
|
||||
// PostsCurrentForum.value = await restGet("/forum/" + id);
|
||||
PostsOfCurrentForum.value = await restGet("/forum/" + id);
|
||||
}
|
||||
|
||||
export function createPost(id, subject, content){
|
||||
restPost("/forum/" + id, {subject: subject, content: content}).then(_ => getPostsOfForum(id));
|
||||
}
|
||||
|
||||
export const PostsOfCurrentForum = ref();
|
||||
@ -37,29 +38,11 @@ export const PostsOfCurrentForum = ref();
|
||||
* Get a post and its responses
|
||||
*/
|
||||
export async function fetchPost(id){
|
||||
fetchedPost.value = {
|
||||
id: 1,
|
||||
subject: "This is the subject of the post",
|
||||
content: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
|
||||
messages: [
|
||||
{
|
||||
id: 1,
|
||||
author: "author~1",
|
||||
content: "J'ai pas copris le message !"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
author: "author~2",
|
||||
content: "tu as fait une faute dans ton message..."
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
author: null,
|
||||
content: "I'm anonymous noww..."
|
||||
}
|
||||
]
|
||||
}
|
||||
// fetchedPost.value = await restGet("/forum/post/" + id);
|
||||
fetchedPost.value = await restGet("/forum/post/" + id);
|
||||
}
|
||||
|
||||
export function sendAnswer(id, content){
|
||||
restPost("/forum/post/" + id, {content: content}).then(_ => fetchPost(id))
|
||||
}
|
||||
|
||||
export const fetchedPost = ref();
|
||||
|
Reference in New Issue
Block a user