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

Implement controller and backend logic for isApproved feature #53

Merged
merged 9 commits into from
Oct 25, 2024
Merged

Implement controller and backend logic for isApproved feature #53

merged 9 commits into from
Oct 25, 2024

Conversation

Tasnim1147
Copy link

Description: This PR implements a feature that allows users to approve or disapprove posts using a toggle button. The changes ensure that the UI reflects the current approval state immediately after an action is taken, without needing to reload the page.

Changes Made:

  • AJAX Call Implementation:

Added an AJAX call to handle the approval status of posts via a PUT request to the API endpoint /api/v3/posts/:pid/approve.
The request includes the post ID, current approval status, and CSRF token for security.

  • Dynamic UI Updates:

Implemented logic to update the button icon and text based on the approval state returned from the server.
The toggle button's icon will switch between fa-toggle-on and fa-toggle-off, and the accompanying text will change between "Approve Post" and "Disapprove Post".

  • Event Listener Setup:

The click event listener is set up to handle clicks on the toggle button, ensuring that the correct post ID is targeted for approval changes.
Used jQuery to manage DOM interactions, ensuring clean and readable code.

  • Console Logging for Debugging:

Added console logging to track the approval process and response data for easier debugging.

  • Error Handling:

Included error handling to notify users of issues that may arise during the approval process.

@Tasnim1147 Tasnim1147 added enhancement New feature or request backend labels Oct 20, 2024
@Tasnim1147 Tasnim1147 added this to the Sprint 2 milestone Oct 20, 2024
@Tasnim1147 Tasnim1147 requested a review from jdufitum October 20, 2024 20:33
@Tasnim1147 Tasnim1147 self-assigned this Oct 20, 2024
Copy link

@jdufitum jdufitum left a comment

Choose a reason for hiding this comment

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

The code looks good to me. we need to fix the bug which is causing the test fail

@Tasnim1147 Tasnim1147 marked this pull request as ready for review October 25, 2024 15:00
Copy link

@jdufitum jdufitum left a comment

Choose a reason for hiding this comment

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

LGTM

@jdufitum jdufitum merged commit 06f31f7 into CMU-17313Q:f24 Oct 25, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend enhancement New feature or request
Projects
None yet
3 participants