Skip to content

Conversation

@godaralokesh29
Copy link
Member

No description provided.

@m-siya
Copy link
Member

m-siya commented Feb 6, 2025

For addition to UI, post images of before and after in PR

@m-siya
Copy link
Member

m-siya commented Feb 6, 2025

UI needs to be improved.

Remove the 'Or Upload CSV'. Add a toggle instead to switch between single member creation and multi member by csv upload

@dvishal485
Copy link
Member

dvishal485 commented Feb 6, 2025

Add a toggle instead

Refer to new role page in frontend repo for this. Toggles switches are present there, reuse it.

Also please go through the comments and review notes here.
Quoting the comment here as well. (dtutimes/nix-backend-v2#127 (comment))

MainWebsiteRole and the Role in database are two different concepts.

MainWebsiteRole is basically the role visible to the general public on our main website
While Role is an internal thing which may vary dynamically.

This is required as suppose a person with designation (main website role) Developer can have different roles in the society, some may have the role of superuser, while other person may have some other role (say foo).

This helps to create different views, and permission levels according to the structure of society while putting people in the same team group.


Another example,

I'm one of the Coordinator of the society (main website role) but I've the role of Superuser, as superuser have the access to all the routes and endpoints required for technical maintenance.
Yet, another person may have the same designation (main website role) of Coordinator, yet have some lower level of permission, and hence a different role with less permission, say the role named Illustrator.


What can you do here?

Directly assume the parameter received is ObjectId of required role, and add that user accordingly.

In the frontend, you fetch all the available roles in the "Add User(s)" page, and give option to user in a dropdown menu to select users role.

For multiple users addition (via CSV), you can follow one of two approaches (or can come up with some other of your own as well)

  1. Frontend should read CSV and replace role name given with their ObjectId before sending the API request.
  2. Allow Backend to accept role with role name (string) and map strings back to role_id (ObjectId).

Preference: Follow the 1st approach, as it can help to detect error in CSV early.

Additional note for frontend part: Make sure user can download a "sample CSV" (with headers and maybe a dummy user entry), so making the CSV file is intuitive.

@godaralokesh29
Copy link
Member Author

image
ObjectIDs given to Roles
Toggle between Single Member and Multimember
UI imporved

Copy link
Member

@dvishal485 dvishal485 left a comment

Choose a reason for hiding this comment

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

The PR looks good, great work :)
Just one minor change is required, since roles can change overtime, make sure not to hardcode them.

Comment on lines 10 to 21
const roleMap: { [key: string]: string } = {
"Superhuman": "64b1f0d8e4a0c12345678901",
"Npc": "64b1f0d8e4a0c12345678902",
"Coordinator": "64b1f0d8e4a0c12345678903",
"Columnist": "64b1f0d8e4a0c12345678904",
"Developer": "64b1f0d8e4a0c12345678905",
"Designer": "64b1f0d8e4a0c12345678906",
"Illustrator": "64b1f0d8e4a0c12345678907",
"Alumni": "64b1f0d8e4a0c12345678908",
"Photographer": "64b1f0d8e4a0c12345678909",
"Editor": "64b1f0d8e4a0c12345678910",
};
Copy link
Member

Choose a reason for hiding this comment

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

Please do not hardcode this, our nix portal is very dynamic. a role which exists today may not exists tomorrow. Take reference from here which fetches the available roles.

const fetchRoles = () => {
const rolesEndpoint = "/role";
API.get(rolesEndpoint)
.then((rolesResponse) => {
setRolesList(rolesResponse.data.data);
setLoading(false);
})
.catch((error) => {
setLoading(false);
setError(error);
});
};
useEffect(() => {
fetchRoles();
}, []);

The roles name as well as id can be accessed as with fields role_name and role_id. For instance -

<div key={role.role_id}>
<Collapsible
label={
role.role_name.charAt(0).toUpperCase() +
role.role_name.slice(1).toLowerCase()
}
>

Comment on lines 138 to 142
const sampleData = [
["name", "email", "role"],
["John Doe", "john.doe@example.com", "Developer"],
["Jane Smith", "jane.smith@example.com", "Designer"],
];
Copy link
Member

@dvishal485 dvishal485 Apr 22, 2025

Choose a reason for hiding this comment

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

Make sample data have a valid entry for each role fetched earlier. Like -

  const sampleData = ["name", "email", "role"] + (for role in roles) {
    ["john", "john@doe.com", role.role_name]
  }

Ofc this is a pseudo code for explanation.

@dvishal485 dvishal485 changed the base branch from main to dev April 22, 2025 09:04
@godaralokesh29
Copy link
Member Author

Screenshot 2025-08-23 134450 Screenshot 2025-08-23 134940

Updates

  • Role IDs are now dynamically fetched from /role API instead of being hardcoded.
  • CSV export now includes sample data for each role.

Raman-pro and others added 4 commits September 3, 2025 18:07
* adjusted the update member to use the new bulk auth route

* reconfigured .env and .gitignore like before

* Added support for to add role in /signup and /post-add-user

* added .env and well as formatted the code
@godaralokesh29
Copy link
Member Author

godaralokesh29 commented Sep 6, 2025

All the newly added Routes are working fine and fixed the Toast errors and also prevly there were same sample IDs being generated but now all IDs generated in "sample.csv" are unique ( just for testing purposes this was something necessary)
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.

5 participants