-
Notifications
You must be signed in to change notification settings - Fork 27
Add edit alias functionality for OfficeAccessCard (#1900) #1909
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
base: dev
Are you sure you want to change the base?
Conversation
- 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.
src/Pages/CardReader/CardReader.js
Outdated
setCards(prevCards => | ||
prevCards.map(card => | ||
card._id === cardId | ||
? { ...card, alias: editedAlias.trim() } | ||
: card |
There was a problem hiding this comment.
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
src/Pages/Overview/SVG.js
Outdated
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> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
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
test/api/OfficeAccessCard.js
Outdated
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); | ||
}); |
There was a problem hiding this comment.
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); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
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 :)
There was a problem hiding this 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
const decoded = decodeToken(req); | ||
if (!decoded) { | ||
return res.sendStatus(UNAUTHORIZED); | ||
} |
There was a problem hiding this comment.
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
-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.