Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const PRONOUN_PLACEHOLDER = 'Pronouns';
export const GENDER_LABEL = 'Gender';
export const GENDER_PLACEHOLDER = 'Gender';
export const PHONE_NUMBER_LABEL = 'Phone number';
export const BIRTH_DATE_LABEL = 'Birth date';
export const AGE_LABEL = 'Age';
export const FIRST_NAME_LABEL = 'First name';
export const LAST_NAME_LABEL = 'Last name';

Expand Down
4 changes: 2 additions & 2 deletions src/config/userTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface IAccount {
password: string;
// The user's phone number
phoneNumber: string;
// The birthdate
birthDate: string;
// The user's age
age: string;
// The preferred pronoun
pronoun: string;
// The database id (if new, leave blank / make '')
Expand Down
23 changes: 12 additions & 11 deletions src/features/Account/ManageAccountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const ManageAccountForm: React.FC<IManageAccountProps> = (props) => {
const [accountDetails, setAccountDetails] = useState<IAccount>({
accountType:
(getValueFromQuery('accountType') as UserType) || UserType.UNKNOWN,
birthDate: '',
age: '',
confirmed: false,
email: getNestedAttr(props, ['location', 'state', 'email']) || '',
firstName: '',
Expand Down Expand Up @@ -101,7 +101,10 @@ const ManageAccountForm: React.FC<IManageAccountProps> = (props) => {
try {
const response = await Account.getSelf();
const newAccountDetails = response.data.data;
newAccountDetails.birthDate = date2input(newAccountDetails.birthDate);

// Changed birthdate to age
//newAccountDetails.age = date2input(newAccountDetails.age);

setAccountDetails(newAccountDetails);
} catch (e) {
// If can't find self's account, shouldn't be logged in. Redirect to home page
Expand All @@ -121,7 +124,7 @@ const ManageAccountForm: React.FC<IManageAccountProps> = (props) => {
accountId: string = ''
): IAccount => ({
accountType: UserType.UNKNOWN,
birthDate: input2date(values.birthDate),
age: values.age,
confirmed: false,
email: values.email,
firstName: values.firstName,
Expand Down Expand Up @@ -246,15 +249,13 @@ const ManageAccountForm: React.FC<IManageAccountProps> = (props) => {
</Flex>
<FastField
component={FormikElements.FormattedNumber}
label={CONSTANTS.BIRTH_DATE_LABEL}
placeholder="MM/DD/YYYY"
format="##/##/####"
name={'birthDate'}
label={CONSTANTS.AGE_LABEL}
format="##"
name={'age'}
required={true}
value={fp.values.birthDate}
disabled={props.mode === ManageAccountModes.EDIT}
value={fp.values.age}
/>
<ErrorMessage component={FormikElements.Error} name="birthDate" />
<ErrorMessage component={FormikElements.Error} name="age" />
<FastField
name={'email'}
label={CONSTANTS.EMAIL_LABEL}
Expand Down Expand Up @@ -357,7 +358,7 @@ const ManageAccountForm: React.FC<IManageAccountProps> = (props) => {
gender: accountDetails.gender,
dietaryRestrictions: accountDetails.dietaryRestrictions,
phoneNumber: accountDetails.phoneNumber,
birthDate: accountDetails.birthDate,
age: accountDetails.age,
}}
onSubmit={handleSubmit}
validationSchema={getValidationSchema(
Expand Down
19 changes: 5 additions & 14 deletions src/features/Account/validationSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { array, object, string } from 'yup';
import { array, object, string, number } from 'yup';

const getValidationSchema = (isCreate: boolean) => {
const password = isCreate
Expand All @@ -25,19 +25,10 @@ const getValidationSchema = (isCreate: boolean) => {
return !value || value.length === 11;
}
),
birthDate: string()
.test('validDate', 'Must be valid date', (value) => {
if (!value || value.length !== 8) {
return false;
} else {
// Assume MMDDYYYY
const month = parseInt(value.substr(0, 2), 10);
const day = parseInt(value.substr(2, 2), 10);
const year = parseInt(value.substr(4, 4), 10);
return month <= 12 && day <= 31 && year >= 1901 && year <= 2018;
}
})
.required('Required'),
age: number()
.required('Required')
.min(0, 'Age must be a positive number') // Minimum age
.max(100, 'Age must be less than or equal to 100'), // Maximum age
});
};

Expand Down
6 changes: 3 additions & 3 deletions src/features/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class SearchContainer extends React.Component<{}, ISearchState> {
headers.forEach((header) => {
tempHeaders.push(header.label);
});
const csvData: string[] = [tempHeaders.join('\t')];
const csvData: string[] = [tempHeaders.join(',')];
this.filter().forEach((result) => {
if (result.selected) {
const row: string[] = [];
Expand All @@ -286,10 +286,10 @@ class SearchContainer extends React.Component<{}, ISearchState> {
}
row.push(value);
});
csvData.push(row.join('\t'));
csvData.push(row.join(','));
}
});
fileDownload(csvData.join('\n'), 'hackerData.tsv', 'text/tsv');
fileDownload(csvData.join('\n'), 'hackerData.csv', 'text/csv');
}

private async triggerSearch(): Promise<void> {
Expand Down
4 changes: 3 additions & 1 deletion src/features/SingleHacker/SingleHackerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import ViewPDFComponent from '../../shared/Elements/ViewPDF';
import { Form, StyledSelect } from '../../shared/Form';
import ValidationErrorGenerator from '../../shared/Form/validationErrorGenerator';
import theme from '../../shared/Styles/theme';

//date2age is currently unused
import { date2age, getOptionsFromEnum } from '../../util';

import SHField from './SingleHackerField';
Expand Down Expand Up @@ -134,7 +136,7 @@ const SingleHackerView: React.FC<IHackerViewProps> = (props) => {
justifyContent="space-between"
alignItems="center"
>
<SHField label="Age" text={date2age(account.birthDate)} />
<SHField label="Age" text={account.age} />
<SHField
label="Shirt Size"
text={hacker.application.accommodation.shirtSize}
Expand Down