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

Add Advisor Role #588

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
13 changes: 13 additions & 0 deletions backend/scripts/add-advisor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { memberCollection, approvedMemberCollection } from '../src/firebase';

const addAdvisor = async (collection) => {
const docs = await collection.listDocuments();
docs.forEach(async (doc) => {
await doc.update({
isAdvisor: false
});
});
};

addAdvisor(memberCollection);
addAdvisor(approvedMemberCollection);
1 change: 1 addition & 0 deletions common-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface IdolMember {
readonly subteams: readonly string[];
readonly formerSubteams?: readonly string[] | null;
readonly role: Role;
readonly isAdvisor: boolean;
readonly roleDescription: RoleDescription;
}

Expand Down
Binary file modified frontend/public/sample_csv.zip
Binary file not shown.
38 changes: 37 additions & 1 deletion frontend/src/components/Admin/AddUser/AddUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default function AddUser(): JSX.Element {
pronouns: '',
email: '',
role: '' as Role,
isAdvisor: false,
graduation: '',
major: '',
doubleMajor: '',
Expand Down Expand Up @@ -149,6 +150,16 @@ export default function AddUser(): JSX.Element {
return;
}

// Check that no tpms are also advisors
if (member.role === 'tpm' && member.isAdvisor) {
Emitters.generalError.emit({
headerMsg: 'Invalid Role!',
contentMsg:
'TPM advisor is not a valid role. Please select a different role if this member is returning as an advisor.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe add "Note that previous TPMs may become dev advisors."

Also, just sanity checking: business advisor, and PM advisor are both a thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ops Leads say so. I'm waiting to hear back from the other role leads about this too. We can probably double check during leads sync.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok! Let's leave it then!

});
return;
}

MembersAPI.setMember({
...member,
netid: getNetIDFromEmail(member.email),
Expand Down Expand Up @@ -194,6 +205,7 @@ export default function AddUser(): JSX.Element {
? m.formerSubteams.split(', ')
: currMember.formerSubteams,
role: m.role || currMember.role,
isAdvisor: m.isAdvisor || currMember.isAdvisor,
roleDescription: getRoleDescriptionFromRoleID(m.role)
} as IdolMember;
MembersAPI.updateMember(updatedMember);
Expand All @@ -216,6 +228,7 @@ export default function AddUser(): JSX.Element {
subteams: m.subteam ? [m.subteam] : [],
formerSubteams: m.formerSubteams ? m.formerSubteams.split(', ') : [],
role: m.role || ('' as Role),
isAdvisor: m.isAdvisor || false,
roleDescription: getRoleDescriptionFromRoleID(m.role)
} as IdolMember;
MembersAPI.setMember(updatedMember);
Expand Down Expand Up @@ -244,7 +257,7 @@ export default function AddUser(): JSX.Element {
const json = await csvtojson().fromString(csv);
const errors = json
.map((m) => {
const [email, role, subteam] = [m.email, m.role, m.subteam];
const [email, role, subteam, isAdvisor] = [m.email, m.role, m.subteam, m.isAdvisor];
const formerSubteams: string[] = m.formerSubteams ? m.formerSubteams.split(', ') : [];
const err = [];
if (!email) {
Expand All @@ -265,6 +278,9 @@ export default function AddUser(): JSX.Element {
if (formerSubteams.includes(subteam)) {
err.push('subteam cannot be in former subteams');
}
if (isAdvisor && role === 'tpm') {
err.push('tpm advisor is not a valid role');
}
return err.length > 0 ? `Row ${json.indexOf(m) + 1}: ${err.join(', ')}` : '';
})
.filter((err) => err.length > 0);
Expand Down Expand Up @@ -445,6 +461,26 @@ export default function AddUser(): JSX.Element {
}}
value={state.currentSelectedMember.role || ''}
/>
<Form.Field
control={Select}
label="Advisor"
options={[
{ key: true, text: 'Yes', value: true },
{ key: false, text: 'No', value: false }
]}
placeholder="Advisor"
disabled={state.currentSelectedMember.role === 'tpm'} // no tpm advisor
onChange={(
event: React.ChangeEvent<HTMLInputElement>,
data: HTMLInputElement
) => {
setCurrentlySelectedMember((currentSelectedMember) => ({
...currentSelectedMember,
isAdvisor: Boolean(data.value)
}));
}}
value={state.currentSelectedMember.isAdvisor || false}
/>
</Form.Group>
<Form.Group widths="equal">
<Form.Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const UserProfile: React.FC = () => {
lastName,
pronouns,
role: userRole,
isAdvisor: userInfoBeforeEdit?.isAdvisor ?? false,
roleDescription: getRoleDescriptionFromRoleID(userRole),
graduation,
major,
Expand Down
Loading