From ebcf6a193af7608825dd26fa84366a38a01082c3 Mon Sep 17 00:00:00 2001 From: yoution Date: Sun, 14 Feb 2021 00:44:42 +0800 Subject: [PATCH 1/2] fix: issue-84 --- src/routes/JobDetails/index.jsx | 4 ++-- src/routes/JobForm/index.jsx | 2 +- src/routes/JobForm/utils.js | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/routes/JobDetails/index.jsx b/src/routes/JobDetails/index.jsx index 293d9269..16990483 100644 --- a/src/routes/JobDetails/index.jsx +++ b/src/routes/JobDetails/index.jsx @@ -64,8 +64,8 @@ const JobDetails = ({ teamId, jobId }) => { }> {formatDate(job.startDate)} - }> - {formatDate(job.endDate)} + }> + {job.duration || "TBD"} }> {job.resourceType} diff --git a/src/routes/JobForm/index.jsx b/src/routes/JobForm/index.jsx index 2ca9ea19..92a6987e 100644 --- a/src/routes/JobForm/index.jsx +++ b/src/routes/JobForm/index.jsx @@ -66,7 +66,7 @@ const JobForm = ({ teamId, jobId }) => { description: values.description, title: values.title, startDate: values.startDate, - endDate: values.endDate, + duration: values.duration, numPositions: values.numPositions, resourceType: values.resourceType, rateType: values.rateType, diff --git a/src/routes/JobForm/utils.js b/src/routes/JobForm/utils.js index 365c64e9..55f61f6e 100644 --- a/src/routes/JobForm/utils.js +++ b/src/routes/JobForm/utils.js @@ -14,7 +14,7 @@ const CREATE_JOB_ROWS = [ { type: FORM_ROW_TYPE.SINGLE, fields: ["description"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["numPositions"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["skills"] }, - { type: FORM_ROW_TYPE.GROUP, fields: ["startDate", "endDate"] }, + { type: FORM_ROW_TYPE.GROUP, fields: ["startDate", "duration"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["resourceType"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["rateType"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["workload"] }, @@ -26,7 +26,7 @@ const EDIT_JOB_ROWS = [ { type: FORM_ROW_TYPE.SINGLE, fields: ["description"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["numPositions"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["skills"] }, - { type: FORM_ROW_TYPE.GROUP, fields: ["startDate", "endDate"] }, + { type: FORM_ROW_TYPE.GROUP, fields: ["startDate", "duration"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["resourceType"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["rateType"] }, { type: FORM_ROW_TYPE.SINGLE, fields: ["workload"] }, @@ -79,10 +79,11 @@ export const getEditJobConfig = (skillOptions, onSubmit) => { placeholder: "Start Date", }, { - label: "End Date", - type: FORM_FIELD_TYPE.DATE, - name: "endDate", - placeholder: "End Date", + label: "Duration", + type: FORM_FIELD_TYPE.NUMBER, + name: "duration", + minValue: 1, + placeholder: "Duration", }, { label: "Resource Type", @@ -163,10 +164,11 @@ export const getCreateJobConfig = (skillOptions, onSubmit) => { placeholder: "Start Date", }, { - label: "End Date", - type: FORM_FIELD_TYPE.DATE, - name: "endDate", - placeholder: "End Date", + label: "Duration", + type: FORM_FIELD_TYPE.NUMBER, + name: "duration", + minValue: 1, + placeholder: "Duration", }, { label: "Resource Type", From affa385f013398c05f065ccb063680f7212b7aee Mon Sep 17 00:00:00 2001 From: yoution Date: Wed, 17 Feb 2021 12:10:16 +0800 Subject: [PATCH 2/2] fix: delete duration --- src/components/FormField/index.jsx | 1 + src/components/TextInput/index.jsx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/FormField/index.jsx b/src/components/FormField/index.jsx index e7b281cc..857cda80 100644 --- a/src/components/FormField/index.jsx +++ b/src/components/FormField/index.jsx @@ -46,6 +46,7 @@ const FormField = ({ field, isGroupField }) => { = props.minValue) { props.onChange(event.target.value); } else { - props.onChange(props.minValue); + if (props.isRequired) { + props.onChange(props.minValue); + } else { + // can delete the number + props.onChange(""); + } } } else { props.onChange(event.target.value);