Create a feature that allows consumers to remove their previously created posts. Before a post is removed, the consumer should be asked to confirm the action to prevent accidental deletions.
Requirements
Remove Post Functionality:
Allow consumers to remove posts they have created.
Display a "Remove Post" button on the project detail view for the post owner.
Ensure that only the consumer who created the post can remove it.
Confirmation Prompt:
When the "Remove Post" button is clicked, display a confirmation prompt asking, "Are you sure you want to remove this project?"
Include "Yes" and "No" options in the confirmation prompt.
Only remove the post if the consumer confirms the action by selecting "Yes".
Post Removal:
If the consumer confirms the removal, delete the post from the database.
Display a success message indicating that the post has been successfully removed.
Redirect the user to an appropriate page (e.g., their profile or homepage) after the post is removed.
Acceptance Criteria
Consumers can remove their posts with a "Remove Post" button.
A confirmation prompt appears before a post is removed.
The post is only removed if the consumer confirms the action.
A success message is displayed, and the user is redirected appropriately.
Additional Information
Ensure the component is responsive and accessible.
Provide clear error messages for any issues in removing the post.
Mockups / Examples
Provide any mockups or examples of the desired component if available.
Technical Requirements
Ensure compatibility with the existing tech stack of the project.
Utilize efficient algorithms to handle post removal without significant performance degradation.
Mongoose Schema for Reference
const mongoose = require('mongoose');
const projectSchema = mongoose.Schema({
"title": String,
"description": String,
"requirements": String,
"budget": Number,
"deadline": Date,
"consumerId": String, // Reference to the user who posted the project
"category": String,
"images": [
{
"url": String, // URL of the image stored in an external service
"description": String, // Optional description of the image
"uploadedAt": Date // Timestamp when the image was uploaded
}
],
"bids": [
{
"bidderId": String, // Reference to the user who placed the bid
"amount": Number,
"message": String,
"createdAt": Date
}
],
"selectedBidder": String, // Reference to the selected bidder (if any)
"status": String, // "open", "closed", "in progress", "completed"
"createdAt": Date,
"updatedAt": Date
});
projectSchema.virtual('id').get(function () {
return this._id.toHexString();
});
projectSchema.set('toJSON', {
virtuals: true,
});
module.exports = mongoose.model('project', projectSchema);
Steps to Implement
Update Backend Endpoint:
Create an endpoint to handle post removal requests.
Description
Create a feature that allows consumers to remove their previously created posts. Before a post is removed, the consumer should be asked to confirm the action to prevent accidental deletions.
Requirements
Remove Post Functionality:
Confirmation Prompt:
Post Removal:
Acceptance Criteria
Additional Information
Mockups / Examples
Provide any mockups or examples of the desired component if available.
Technical Requirements
Mongoose Schema for Reference
Steps to Implement
Update Backend Endpoint:
Update Frontend Component:
Integrate and Test:
Tasks