- implementing hobby, language and reference sections

- dynamic template selection
This commit is contained in:
Amruth Pillai
2020-07-09 10:41:16 +05:30
parent 9045e2983d
commit 9e98da038c
38 changed files with 470 additions and 187 deletions

View File

@ -1,3 +1,6 @@
import { get } from 'lodash';
import moment from 'moment';
export const getModalText = (isEditMode, type) => {
return isEditMode ? `Edit ${type}` : `Add ${type}`;
};
@ -8,7 +11,7 @@ export const transformCollectionSnapshot = (snapshot, setData) => {
setData(data);
};
export const handleKeyDown = (event, action) => {
export const handleKeyUp = (event, action) => {
(event.which === 13 || event.which === 32) && action();
};
@ -16,3 +19,15 @@ export const isFileImage = (file) => {
const acceptedImageTypes = ['image/jpeg', 'image/png'];
return file && acceptedImageTypes.includes(file.type);
};
export const formatDateRange = (x) =>
`${moment(x.startDate).format('MMMM Y')}${
moment(x.endDate).isValid() ? moment(x.endDate).format('MMMM Y') : 'Present'
}`;
export const getFieldProps = (formik, schema, name) => ({
touched: get(formik, `touched.${name}`, false),
error: get(formik, `errors.${name}`, ''),
isRequired: get(schema, `fields.${name}._exclusive.required`),
...formik.getFieldProps(name),
});