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

Remove as2 #618

Merged
merged 10 commits into from
Mar 29, 2022
25 changes: 22 additions & 3 deletions src/components/Modals/Onboarding/Onboarding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import OnboardingBasic from '@/components/Modals/Onboarding/OnboardingBasic.vue'
import OnboardingTransfer from '@/components/Modals/Onboarding/OnboardingTransfer.vue';
import OnboardingReview from '@/components/Modals/Onboarding/OnboardingReview.vue';
import { setAppOnboardingData, populateSemesters } from '@/global-firestore-data';
import { getMajorFullName, getMinorFullName, getGradFullName } from '@/utilities';
import { getMajorFullName, getMinorFullName, getGradFullName, SeasonOrdinal } from '@/utilities';
import timeline1Text from '@/assets/images/timeline1text.svg';
import timeline2Text from '@/assets/images/timeline2text.svg';
import timeline3Text from '@/assets/images/timeline3text.svg';
Expand Down Expand Up @@ -213,10 +213,11 @@ export default defineComponent({
},
methods: {
submitOnboarding() {
const revised = this.setASCollegeReqs();
this.clearTransferCreditIfGraduate();
setAppOnboardingData(this.name, this.onboarding);
setAppOnboardingData(this.name, revised);
// indicates first time user onboarding
if (!this.isEditingProfile) populateSemesters(this.onboarding);
if (!this.isEditingProfile) populateSemesters(revised);
this.$emit('onboard');
},
goBack() {
Expand Down Expand Up @@ -297,6 +298,24 @@ export default defineComponent({
this.cancel();
}
},
// determine which AS reqs to set depending on user's starting semester
// AS1 for students entering before Fall 2020, AS2 for students after
setASCollegeReqs() {
const revised = { ...this.onboarding };
if (revised.college === 'AS') {
const year = Number.parseInt(revised.entranceYear, 10);
const season: FirestoreSemesterSeason =
revised.entranceSem === '' ? 'Fall' : revised.entranceSem; // default to fall if not provided
if (year < 2020) {
revised.college = 'AS1';
} else if (year === 2020 && SeasonOrdinal[season] < SeasonOrdinal.Fall) {
revised.college = 'AS1';
} else {
revised.college = 'AS2';
}
}
return revised;
},
},
});
</script>
Expand Down
33 changes: 25 additions & 8 deletions src/components/Modals/Onboarding/OnboardingBasic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<script lang="ts">
import { PropType, defineComponent } from 'vue';
import reqsData from '@/requirements/typed-requirement-json';
import { clickOutside, getCurrentYear, yearRange } from '@/utilities';
import { clickOutside, getCollegeFullName, getCurrentYear, yearRange } from '@/utilities';
import OnboardingBasicMultiDropdown from './OnboardingBasicMultiDropdown.vue';
import OnboardingBasicSingleDropdown from './OnboardingBasicSingleDropdown.vue';

Expand All @@ -193,7 +193,10 @@ export default defineComponent({
components: { OnboardingBasicMultiDropdown, OnboardingBasicSingleDropdown },
props: {
userName: { type: Object as PropType<FirestoreUserName>, required: true },
onboardingData: { type: Object as PropType<AppOnboardingData>, required: true },
onboardingData: {
type: Object as PropType<AppOnboardingData>,
required: true,
},
isEditingProfile: { type: Boolean, required: true },
},
emits: {
Expand Down Expand Up @@ -227,6 +230,12 @@ export default defineComponent({
if (majorAcronyms.length === 0) majorAcronyms.push('');
if (minorAcronyms.length === 0) minorAcronyms.push('');

// convert AS1/AS2 acronym in firebase to AS for the frontend
let collegeAcronym = this.onboardingData.college ?? '';
if (collegeAcronym === 'AS1' || collegeAcronym === 'AS2') {
collegeAcronym = 'AS';
}

// if sem has not been previously filled out, choice is automatically is "Fall"/"Spring" for new users, old users have no data
let { gradSem } = this.onboardingData;
let { entranceSem } = this.onboardingData;
Expand All @@ -244,7 +253,7 @@ export default defineComponent({
gradSem,
entranceYear: this.onboardingData.entranceYear,
entranceSem,
collegeAcronym: this.onboardingData.college ? this.onboardingData.college : '',
collegeAcronym,
majorAcronyms,
minorAcronyms,
gradAcronym: this.onboardingData.grad ? this.onboardingData.grad : '',
Expand All @@ -255,16 +264,20 @@ export default defineComponent({
},
computed: {
colleges(): Readonly<Record<string, string>> {
return Object.fromEntries(
Object.entries(reqsData.college).map(([key, { name }]) => [key, name])
);
const base = Object.entries(reqsData.college)
.filter(college => !college[0].startsWith('AS'))
.map(([key, { name }]) => [key, name]);
base.push(['AS', getCollegeFullName('AS')]);
base.sort((c1, c2) => c1[1].localeCompare(c2[1]));
return Object.fromEntries(base);
},
majors(): Readonly<Record<string, string>> {
const majors: Record<string, string> = {};
const majorJSON = reqsData.major;
const acr = this.collegeAcronym !== 'AS' ? this.collegeAcronym : 'AS2';
Object.keys(majorJSON).forEach(key => {
// only show majors for schools the user is in
if (majorJSON[key].schools.includes(this.collegeAcronym)) {
if (majorJSON[key].schools.includes(acr)) {
majors[key] = majorJSON[key].name;
}
});
Expand Down Expand Up @@ -330,7 +343,11 @@ export default defineComponent({
this.majorAcronyms.filter(it => it !== ''),
this.minorAcronyms.filter(it => it !== ''),
this.gradAcronym,
{ firstName: this.firstName, middleName: this.middleName, lastName: this.lastName }
{
firstName: this.firstName,
middleName: this.middleName,
lastName: this.lastName,
}
);
},
// Clear a major if a new college is selected and the major is not in it
Expand Down
7 changes: 6 additions & 1 deletion src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ export function getCurrentYear(): number {
export const yearRange = 6;

export function getCollegeFullName(acronym: string | undefined): string {
// Return empty string if college is not in requirementJSON
// return Arts and Sciences for AS, AS1, or AS2
if (acronym && acronym.startsWith('AS')) {
return 'Arts and Sciences';
}
const college = acronym ? requirementJSON.college[acronym] : null;

// Return empty string if college is not in requirementJSON
return college ? college.name : '';
}

Expand Down