Skip to content

Commit 9a86444

Browse files
authored
Merge pull request #261 from swiftss-org/feature/fix-validation
Feature/fix validation
2 parents 4071c4a + 48b4d60 commit 9a86444

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/pages/EpisodeDetails/components/ExpandableContainer/components/Discharge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const Discharge: FC<{
197197
</CheckBoxWrapper>
198198
<Field
199199
name="infection"
200-
initialValue={discharge?.discharge_duration}
200+
initialValue={discharge?.infection}
201201
parse={(value) => value}
202202
>
203203
{(props) => {
@@ -207,7 +207,7 @@ const Discharge: FC<{
207207
<TextField
208208
id="infection"
209209
disabled
210-
label={'Infection'}
210+
label={'Post-operative complications'}
211211
required={canSubmit}
212212
styleType="outlined"
213213
size="md"

src/pages/EpisodeDetails/utils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ export const dischargeFormValidation = (values: {
2424
errors.date = 'Discharge date cannot be set in the future.';
2525
}
2626

27+
// aware_of_mesh is actually the "Antibiotics given on discharge" field
2728
if (!values.aware_of_mesh && typeof values.aware_of_mesh !== 'object') {
2829
errors.aware_of_mesh = REQUIRED_FIELD_MSG;
2930
} else {
30-
console.log(values)
31-
32-
if (!values.discharge_duration && typeof values.discharge_duration !== 'object') {
33-
errors.discharge_duration = REQUIRED_FIELD_MSG;
31+
if (values.aware_of_mesh.value === 0) {
32+
if (!values.discharge_duration && typeof values.discharge_duration !== 'object') {
33+
errors.discharge_duration = REQUIRED_FIELD_MSG;
34+
}
3435
}
3536
}
3637

3738
if (values.infection === undefined || values.infection?.length == 0) {
38-
const errorMessage = "Please record the post-operative complication above. if there wasn't any then select the option 'None'";
39+
const errorMessage = "Please record the post-operative complication above. If there wasn't any then select the option 'None'";
3940
errors.infection = errorMessage;
4041
}
4142
return errors;

0 commit comments

Comments
 (0)