comments
This commit is contained in:
parent
52b5a490ac
commit
91e1116532
9 changed files with 226 additions and 33 deletions
|
@ -1,5 +1,6 @@
|
|||
import { Post } from './posts.ts'
|
||||
import { ApiClient } from '../../api/client.ts'
|
||||
import { useUserStore } from '../../user/user.ts'
|
||||
|
||||
export class PostsService {
|
||||
constructor(private readonly client: ApiClient) {}
|
||||
|
@ -78,6 +79,17 @@ export class PostsService {
|
|||
credentials: 'include',
|
||||
})
|
||||
}
|
||||
|
||||
async addComment(postId: string, content: string): Promise<void> {
|
||||
const authorId = useUserStore.getState().user?.id
|
||||
if (!authorId) return
|
||||
|
||||
await this.client.POST('/posts/{postId}/comments', {
|
||||
params: { path: { postId } },
|
||||
body: { content, authorId },
|
||||
credentials: 'include',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
interface CreatePostMedia {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue