Skip to content
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

Add Comment Section #26

Merged
merged 4 commits into from
Nov 23, 2022
Merged

Add Comment Section #26

merged 4 commits into from
Nov 23, 2022

Conversation

heintayzar-hm
Copy link
Owner

In this milestone,
I added :

  1. Comment Section
  2. Comment Section Add form

@ginabeki
Copy link
Collaborator

Status: Required Changes ♻️

Hi @ginabeki ,

Good job so far!
There are some issues that you still need to work on to go to the next project but you are almost there!

Highlights

  • No linter errors found. ✔️
  • Good README file. ✔️
  • Correct Git Flow. ✔️

Required Changes ♻️

Check the comments under the review.

Optional suggestions

Every comment with the [OPTIONAL] prefix is not crucial enough to stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better.

Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, remember to tag me in your question so I can receive the notification.

Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

Comment on lines 1 to 44
import axios from 'axios';

export default class Comments {
constructor() {
this.involvementApi = process.env.INVOLVEMENT_API_LINK;
this.involvementApiId = process.env.INVOLVEMENT_ID;
this.commentsEndPoint = `/apps/${this.involvementApiId}/comments`;
this.commentsAllEndPoint = `/apps/${this.involvementApiId}/comments?item_id=`;
}

// eslint-disable-next-line consistent-return
getComments = async (id) => {
try {
// eslint-disable-next-line consistent-return
return await axios.get(`${this.involvementApi}${this.commentsAllEndPoint}${id}`).then((res) => {
if (res.status === 200) {
return res;
}
});
} catch (error) {
if (error.response) {
return false;
}
}
}

addComment = async (itemId, username, comment) => {
try {
// eslint-disable-next-line consistent-return
return await axios.post(`${this.involvementApi}${this.commentsEndPoint}`, {
item_id: itemId,
username,
comment,
}).then((res) => {
if (res.status === 201) {
return true;
}
throw new Error('Fail');
});
} catch (error) {
throw new Error('Fail');
}
}
}
Copy link
Collaborator

@ginabeki ginabeki Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Kindly add descriptive comments to your code to make it readable. Proper use of commenting can make code maintenance much easier, as well as helping make finding bugs faster. Also, it will be very important when writing functions that other people will use.

@heintayzar-hm heintayzar-hm merged commit 3bacb31 into development Nov 23, 2022
@heintayzar-hm heintayzar-hm deleted the Comments branch November 24, 2022 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants