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

search bar placed at top #40

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
40fe51c
Delete tests directory
retr0717 Nov 7, 2023
6893188
initial setup done
retr0717 Nov 7, 2023
235eb3f
Update README.md
retr0717 Nov 7, 2023
5efbda1
Update README.md
retr0717 Nov 7, 2023
8e9b3c9
Update README.md
retr0717 Nov 7, 2023
61d348a
initial server settings
retr0717 Nov 7, 2023
2536ef4
routes,helpers,model
retr0717 Nov 7, 2023
02ec193
Merge branch 'master' of https://github.com/AKA717/retr0-stackup
retr0717 Nov 7, 2023
01d4846
server.js update
retr0717 Nov 7, 2023
ec79ea1
added server.js updated
retr0717 Nov 7, 2023
1695483
add contact route done
retr0717 Nov 8, 2023
03480d7
add-contact route done
retr0717 Nov 8, 2023
cb195b2
model.js
retr0717 Nov 8, 2023
826fbd4
get-contacts route done
retr0717 Nov 8, 2023
0259c36
delete route done
retr0717 Nov 8, 2023
520bfe3
contact update route done
retr0717 Nov 8, 2023
f8504ab
route
retr0717 Nov 8, 2023
728060a
branch 'back-end'
retr0717 Nov 8, 2023
992b127
merge mistake in user-route
retr0717 Nov 8, 2023
8b0c172
model.js merge mistake
retr0717 Nov 8, 2023
c2d8fd2
user router js merge mistake
retr0717 Nov 8, 2023
90b3964
server.js merge mistake
retr0717 Nov 8, 2023
f9beb24
back-end branch merge mistakes resolved
retr0717 Nov 8, 2023
5357886
initial redux store setup done
retr0717 Nov 8, 2023
ba8bd9c
Merge branch 'front-end'
retr0717 Nov 8, 2023
ef5d4c5
user router merge mistake
retr0717 Nov 8, 2023
95762f8
login component created
melo-maniac-29 Nov 8, 2023
f14c4e1
login component created
melo-maniac-29 Nov 8, 2023
224d670
Update README.md
melo-maniac-29 Nov 8, 2023
169f0f4
register component
melo-maniac-29 Nov 8, 2023
9935104
login register functionality works
retr0717 Nov 8, 2023
6c6e9fe
Merge branch 'master' of https://github.com/AKA717/retr0-stackup
retr0717 Nov 8, 2023
6739950
saga middlwares and actions
retr0717 Nov 8, 2023
486942a
login ,register, home view,add contact features added
retr0717 Nov 9, 2023
be07b53
added route to user view after add contact
retr0717 Nov 9, 2023
8b02153
delete feature added
retr0717 Nov 9, 2023
3193eb0
edit feature added
retr0717 Nov 10, 2023
129bde0
changed to mdn style
retr0717 Nov 10, 2023
28a5561
view style updated
Akh1l51j1 Nov 10, 2023
bc323ea
view search bar position over card
Akh1l51j1 Nov 10, 2023
6b3d3fa
search bar box shadow removed and add contact place below the search bar
Akh1l51j1 Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
delete route done
  • Loading branch information
retr0717 committed Nov 8, 2023
commit 0259c36886fab89beb64b39d84126ed108b5465e
43 changes: 42 additions & 1 deletion back-end/routes/user-router.js
Original file line number Diff line number Diff line change
@@ -34,6 +34,42 @@ if (!fs.existsSync(profileDirectory))
fs.mkdirSync(profileDirectory, { recursive: true });
}

// Add a new route to delete a contact by ID
router.delete('/delete-contact', async (req, res) => {
try {
const userId = req.body.userId;
const contactId = req.body.contactId;

console.log(userId,contactId);

// Find the user profile by user ID
let userProfile = await Contact.findById(userId);

if (!userProfile) {
return res.status(404).send(apiResponse({ message: 'User profile not found.' }));
}

// Find the index of the contact to delete
const contactIndex = userProfile.contacts.findIndex((contact) => contact._id.toString() === contactId);

if (contactIndex === -1) {
return res.status(404).send(apiResponse({ message: 'Contact not found.' }));
}

// Remove the contact from the user's profile
userProfile.contacts.splice(contactIndex, 1);

// Save the updated user profile
await userProfile.save();

return res.send(apiResponse({ message: 'Contact deleted successfully.' }));
} catch (error) {
console.error(error);
res.status(500).send(apiResponse({ message: 'Error processing the request.' }));
}
});


router.get('/get-contacts',async (req,res) => {

const userId = req.body.id;
@@ -51,7 +87,12 @@ router.get('/get-contacts',async (req,res) => {
}
else
{

res.status(401).json(
{
success: false,
message: "user already exists"
}
)
}

})