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

Enrollment Check-in: Add SMS Opt-in question #2371

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
60 changes: 28 additions & 32 deletions src/services/checkIn.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { AuthError, NotFoundError } from "./error";
import http from "./http";
import http from './http';

/**
* these holds prevent a student from checking in
*/
type MajorHolds = {
RegistrarHold: boolean;
HighSchoolTranscriptHold: boolean;
HighSchoolHold: boolean;
FinancialHold: boolean;
MedicalHold: boolean;
MustRegisterForClasses: boolean;
Expand All @@ -20,6 +19,8 @@ type MinorHolds = {
MajorHold: boolean;
};

type Holds = MajorHolds & MinorHolds;

type EmergencyContact = {
/** the sequence number of the contact, (1, 2, or 3) */
SEQ_NUMBER: number;
Expand All @@ -34,54 +35,49 @@ type EmergencyContact = {
MobilePhoneIN: boolean;
};

type PersonalPhone = {
type PhoneInfo = {
PersonalPhone: number;
MakePrivate: boolean;
NoPhone: boolean;
SMSOptedIn: boolean;
};

type Demographic = {
/** whether or not a student is Hispanic/Latino or prefers not to say */
Ethnicity: number;
Race: Race;
};
// type Demographic = {
// /** whether or not a student is Hispanic/Latino or prefers not to say */
// Ethnicity: number;
// Race: Race;
// };

export enum Race {
NativeAmerican = "Native American or Alaskan Native",
Asian = "Asian",
Black = "Black or African American",
Hawaiian = "Native Hawaiian or Other Pacific Islander",
White = "White",
NativeAmerican = 'Native American or Alaskan Native',
Asian = 'Asian',
Black = 'Black or African American',
Hawaiian = 'Native Hawaiian or Other Pacific Islander',
White = 'White',
}

type EnrollmentCheckin = {
Holds: string;
NewStudent: number;
} & PersonalPhone &
MajorHolds &
MinorHolds &
Demographic;
// type EnrollmentCheckin = {
// Holds: string;
// NewStudent: number;
// } & MajorHolds &
// MinorHolds &
// Demographic;

const getStatus = (): Promise<boolean> => http.get<boolean>(`checkIn/status`);

const markCompleted = (): Promise<void> => http.put(`checkIn/status`);

const getHolds = (): Promise<EnrollmentCheckin> => http.get(`checkIn/holds`);
const getHolds = (): Promise<Holds> => http.get(`checkIn/holds`);

const getEmergencyContacts = (
username: string
): Promise<EmergencyContact[] | void> =>
const getEmergencyContacts = (username: string): Promise<EmergencyContact[] | void> =>
http.get(`profiles/emergency-contact/${username}/`);

const submitPhone = (data: EnrollmentCheckin): Promise<EnrollmentCheckin> =>
http.put(`checkIn/cellphone`, data);
const submitPhone = (data: PhoneInfo): Promise<void> => http.put(`checkIn/cellphone`, data);

const submitContact = (data: EmergencyContact): Promise<EmergencyContact> =>
http.post(`checkIn/emergencycontact`, data);

const submitDemographic = (
data: EnrollmentCheckin
): Promise<EnrollmentCheckin> => http.put(`checkIn/demographic`, data);
// const submitDemographic = (data: EnrollmentCheckin): Promise<EnrollmentCheckin> =>
// http.put(`checkIn/demographic`, data);

const checkInService = {
getStatus,
Expand All @@ -90,7 +86,7 @@ const checkInService = {
getEmergencyContacts,
submitPhone,
submitContact,
submitDemographic,
// submitDemographic,
};

export default checkInService;
28 changes: 25 additions & 3 deletions src/views/EnrollmentCheckIn/components/UpdatePhone/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import {
Checkbox,
FormControl,
FormControlLabel,
FormLabel,
Grid,
Input,
InputLabel,
Radio,
RadioGroup,
Typography,
} from '@mui/material';
import { forwardRef } from 'react';
Expand All @@ -29,7 +32,7 @@ const UpdatePhone = ({ phoneInfo, handleChangePhoneInfo, handleCheckPhoneInfo })
</Grid>
<Grid item>
<FormControl>
<InputLabel htmlFor="formatted-text-mask-input"> Phone Number </InputLabel>
<InputLabel htmlFor="formatted-text-mask-input">Phone Number</InputLabel>
<Input
id="formatted-text-mask-input"
name="PersonalPhone"
Expand All @@ -41,14 +44,33 @@ const UpdatePhone = ({ phoneInfo, handleChangePhoneInfo, handleCheckPhoneInfo })
/>
</FormControl>
</Grid>
<Grid item>
<FormControl>
<FormLabel>Do you give permission for Gordon College to text you?</FormLabel>
<RadioGroup
row
value={phoneInfo.SMSOptedIn}
onChange={handleChangePhoneInfo}
name="SMSOptedIn"
>
<FormControlLabel value={true} control={<Radio />} label="Yes" />
<FormControlLabel value={false} control={<Radio />} label="No" />
</RadioGroup>
<Typography>
By checking yes, you agree to receive text messages from Gordon College. Message & data
rates may apply. Message frequency varies. Reply HELP for help or STOP to cancel. View
Terms of Service and Privacy Policy https://www.gordon.edu/webprivacy.cfm.
</Typography>
</FormControl>
</Grid>
<Grid item>
<FormControl>
<FormControlLabel
control={
<Checkbox
checked={phoneInfo.MakePrivate}
disabled={phoneInfo.NoPhone}
name={'MakePrivate'}
name="MakePrivate"
onChange={handleCheckPhoneInfo}
/>
}
Expand All @@ -58,7 +80,7 @@ const UpdatePhone = ({ phoneInfo, handleChangePhoneInfo, handleCheckPhoneInfo })
control={
<Checkbox
checked={phoneInfo.NoPhone}
name={'NoPhone'}
name="NoPhone"
onChange={handleCheckPhoneInfo}
/>
}
Expand Down
10 changes: 7 additions & 3 deletions src/views/EnrollmentCheckIn/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const EnrollmentCheckIn = (props) => {
PersonalPhone: '',
MakePrivate: false,
NoPhone: false,
SMSOptedIn: undefined,
});

const [privacyAgreements, setPrivacyAgreements] = useState({
Expand Down Expand Up @@ -145,17 +146,18 @@ const EnrollmentCheckIn = (props) => {
PersonalPhone: profile.MobilePhone,
MakePrivate: Boolean(profile.IsMobilePhonePrivate),
NoPhone: false,
SMSOptedIn: undefined,
});
}
} else {
setActiveStep(5);
}
}
// We only want to stop loading now if the profile has already been loaded.
setLoading(loadingProfile);
setLoading(false);
};
loadData();
}, [profile, loadingProfile]);
}, [profile]);

useEffect(() => {
navigate('/enrollmentcheckin', { replace: true, state: { step: activeStep } });
Expand Down Expand Up @@ -252,7 +254,9 @@ const EnrollmentCheckIn = (props) => {
checkInService.submitContact(emergencyContact1);
checkInService.submitContact(emergencyContact2);
checkInService.submitContact(emergencyContact3);
checkInService.submitPhone(phoneInfo);
if (!phoneInfo.NoPhone) {
checkInService.submitPhone(phoneInfo);
}
// checkInService.submitDemographic(formatDemographic(demographic));
checkInService.markCompleted(profile.ID);
setActiveStep(5);
Expand Down
Loading