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 4 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.
23 changes: 23 additions & 0 deletions 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 @@ -194,6 +195,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 +218,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 @@ -445,6 +448,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