-
Notifications
You must be signed in to change notification settings - Fork 0
DEV-401 Implement commentService.ts #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: preview
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
frontend/api/commentService.ts
Outdated
| export async function createNewComment(): Promise<Comment | null> { | ||
| // POST answers/{answerId}/comments/ | ||
| return null; | ||
| export async function getAllComments(answerId: string | number): Promise<Comment[] | null> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can treat answerId as a string
| } | ||
|
|
||
| export async function updateCommentDetails(commentId: string): Promise<Comment | null> { | ||
| type UpdateCommentPayload = Partial<Pick<Comment, 'text' | 'is_anonymous' | 'hearts'>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just make the payload a type with all the fields for a comment for now
frontend/api/commentService.ts
Outdated
| export async function getAllComments(): Promise<Comment[] | null> { | ||
| // GET answers/{answerId}/comments/ | ||
| return null; | ||
| async function parseComment(res: Response): Promise<Comment | null> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if these parsing functions are needed since they are pretty self explanatory and might make more sense within the functions. We also don't need the check for 204 since that's for empty response, which should only happen for delete
References
Proposed Changes