Merge pull request #528 from lpmi-13/set_present_as_end_date

update Project data model to use "Present" if no end date selected
This commit is contained in:
Amruth Pillai
2021-07-13 10:40:26 +05:30
committed by GitHub
2 changed files with 12 additions and 5 deletions
+10 -3
View File
@@ -10,7 +10,8 @@ import ModalEvents from '../../constants/ModalEvents';
const initialValues = {
title: '',
link: '',
date: '',
startDate: '',
endDate: '',
summary: '',
};
@@ -20,7 +21,13 @@ const ProjectModal = () => {
const schema = Yup.object().shape({
title: Yup.string().required(t('shared.forms.validation.required')),
link: Yup.string().url(t('shared.forms.validation.url')),
date: Yup.date().max(new Date()),
startDate: Yup.date(),
endDate: Yup.date().when(
'startDate',
(startDate, yupSchema) =>
startDate &&
yupSchema.min(startDate, t('shared.forms.validation.dateRange')),
),
summary: Yup.string(),
});
@@ -54,7 +61,7 @@ const ProjectModal = () => {
type="date"
label={t('shared.forms.startDate')}
placeholder="6th August 2018"
{...getFieldProps(formik, schema, 'date')}
{...getFieldProps(formik, schema, 'startDate')}
/>
<Input
+2 -2
View File
@@ -17,12 +17,12 @@ const ProjectItem = ({ item, language }) => {
</a>
)}
</div>
{item.date && (
{item.startDate && (
<h6 className="text-xs font-medium text-right">
(
{formatDateRange(
{
startDate: item.date,
startDate: item.startDate,
endDate: item.endDate,
language,
},