Skip to content

Commit

Permalink
Hides the exemption rationale note when not required by exemption tas…
Browse files Browse the repository at this point in the history
…k. Multiline and required when present.
  • Loading branch information
GrahamS-Quartech committed Jul 12, 2024
1 parent b6244eb commit c6fd4d7
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions react-app/src/components/projects/AddProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AddProject = () => {
Description: '',
Assessed: 0,
NetBook: 0,
Estimated: 0,
Market: 0,
Appraised: 0,
ProgramCost: 0,
SalesCost: 0,
Expand Down Expand Up @@ -75,6 +75,8 @@ const AddProject = () => {
}
}, [lookupData, exemptionTask, formMethods]);
const watch = formMethods.watch('Tasks');
const exemptionWasRequested =
watch.find((a) => a.TaskId === exemptionTask.Id)?.IsCompleted === true;
return (
<Box
display={'flex'}
Expand Down Expand Up @@ -231,12 +233,19 @@ const AddProject = () => {
</Grid>
))}
<Grid item xs={12}>
<TextFormField
disabled={watch.find((a) => a.TaskId === exemptionTask.Id)?.IsCompleted != true}
fullWidth
name={'ExemptionNote'}
label={'Exemption rationale note'}
/>
{exemptionWasRequested && (
<TextFormField
fullWidth
name={'ExemptionNote'}
label={'Exemption rationale note'}
required
multiline
minRows={2}
rules={{
required: 'Rationale required when requesting exemption.',
}}
/>
)}
</Grid>
</Grid>
<Typography variant="h5">Approval</Typography>
Expand Down Expand Up @@ -282,7 +291,9 @@ const AddProject = () => {
{ MonetaryTypeId: salesCostType.Id, Value: formValues.SalesCost },
],
Tasks: formValues.Tasks.filter((a) => a.IsCompleted),
Notes: [{ NoteTypeId: exemptionNote.Id, Note: formValues.ExemptionNote }],
Notes: exemptionWasRequested
? [{ NoteTypeId: exemptionNote.Id, Note: formValues.ExemptionNote }]
: undefined,
},
projectProperties,
).then((response) => {
Expand Down

0 comments on commit c6fd4d7

Please sign in to comment.