Skip to content

Conversation

DavidN016
Copy link
Collaborator

-Created a post /edit, and a helper function for edit alias.
-Created edit mode in pencil/edit button, that edits the alias when clicked.
-Created test files for post /edit with dummy document.

DavidN016 added 2 commits September 19, 2025 22:28
- Implemented a new endpoint to edit card aliases, including validation for input.
- Updated the OfficeAccessCard utility to support alias editing.
- Enhanced the CardReader component to allow users to edit card aliases directly in the UI.
- Added corresponding tests to ensure proper functionality and error handling for the new feature.
- Introduced a new audit log action for alias edits.
Comment on lines 112 to 116
setCards(prevCards =>
prevCards.map(card =>
card._id === cardId
? { ...card, alias: editedAlias.trim() }
: card
Copy link
Contributor

Choose a reason for hiding this comment

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

i think what we should do here is when the alias is successfully edited, we query mongodb for all cards again, so that way this alias isn't only client side

Comment on lines 54 to 62
export function pencilSymbol(color = '#6b7280') {
return (
<svg width='20' height='20' viewBox='0 0 24 24' fill='none' stroke={color} strokeWidth='2' strokeLinecap='round' strokeLinejoin='round'>
<path d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'/>
<path d='m18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z'/>
</svg>
);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't have to be put in this file, the trashCanSymbol function is only imported from here because it was already implemented here when card reader page was made. you can move this to CardReader.js

Comment on lines 279 to 284
it('Should return 400 when both _id and alias are missing', async () => {
setTokenStatus(true);
const result = await test.sendPostRequestWithToken(token,
EDIT_API_PATH, {});
expect(result).to.have.status(BAD_REQUEST);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

this test is redundant

expect(updatedCard.alias).to.equal(NEW_ALIAS);
});
});

Copy link
Contributor

Choose a reason for hiding this comment

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

very impressive how thorough these tests are :)

Copy link
Collaborator

@evanugarte evanugarte left a comment

Choose a reason for hiding this comment

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

can there be some screenshots of the new ui

Comment on lines +220 to +223
const decoded = decodeToken(req);
if (!decoded) {
return res.sendStatus(UNAUTHORIZED);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we realized this doesnt work anymore, need to merge #1877 first

ill work on it

@adarshm11
Copy link
Contributor

can there be some screenshots of the new ui

image image

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.

3 participants