Skip to content

Commit

Permalink
Mark locations where useFormArrayWithEmptyCheck needs to be used
Browse files Browse the repository at this point in the history
- Add changelog
  • Loading branch information
tnagorra committed Oct 8, 2024
1 parent 583da9b commit df80c4f
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-carrots-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"go-web-app": patch
---

Fix contact details in Field Report being always required when filled once
1 change: 1 addition & 0 deletions app/src/views/CountryProfileOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export function Component() {
return undefined;
}

// FIXME: this sort will mutate the data
const orderedMonth = month.sort(
(a, b) => compareNumber(monthToOrderMap[a], monthToOrderMap[b]),
);
Expand Down
1 change: 1 addition & 0 deletions app/src/views/Emergencies/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export function Component() {
const numAffectedCalculated = sumSafe(
(events?.map(
(event) => {
// FIXME: this sort will mutate the data
const latestFieldReport = event.field_reports.sort(
(a, b) => (
new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
Expand Down
1 change: 1 addition & 0 deletions app/src/views/FieldReportForm/ActionsFields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function ActionsFields(props: Props) {

const actionsError = getErrorObject(error?.actions_taken);

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setActionValue,
} = useFormArray<'actions_taken', ActionValue>(
Expand Down
1 change: 1 addition & 0 deletions app/src/views/FieldReportForm/EarlyActionsFields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function EarlyActionFields(props: Props) {

const actionsError = getErrorObject(error?.actions_taken);

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setActionValue,
} = useFormArray<'actions_taken', ActionValue>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function ComponentInput(props: Props) {
[error],
);

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setQuestionValue,
} = useFormArray<'question_responses', NonNullable<Value['question_responses']>[number]>(
Expand Down Expand Up @@ -150,6 +151,7 @@ function ComponentInput(props: Props) {

const groupedQuestions = useMemo(
() => listToGroupList(
// FIXME: this sort will mutate the data
questions?.sort((q1, q2) => compareNumber(q1.question_num, q2.question_num)),
(question) => question.question_group ?? NO_GROUP,
),
Expand Down
1 change: 1 addition & 0 deletions app/src/views/PerAssessmentForm/AreaInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function AreaInput(props: Props) {
}),
);

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setQuestionResponseValue,
} = useFormArray('component_responses', setFieldValue);
Expand Down
1 change: 1 addition & 0 deletions app/src/views/PerAssessmentForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export function Component() {
formContentRef.current?.scrollIntoView();
}, []);

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setAreaResponsesValue,
} = useFormArray('area_responses', setFieldValue);
Expand Down
1 change: 1 addition & 0 deletions app/src/views/PerPrioritizationForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export function Component() {
},
});

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setComponentValue,
removeValue: removeComponentValue,
Expand Down
3 changes: 3 additions & 0 deletions app/src/views/PerWorkPlanForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export function Component() {
[value?.prioritized_action_responses],
);

// FIXME: Not sure if this is required
const customComponentResponseMapping = useMemo(
() => (
listToMap(
Expand Down Expand Up @@ -211,13 +212,15 @@ export function Component() {
},
});

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setComponentValue,
} = useFormArray<'prioritized_action_responses', NonNullable<PartialWorkPlan['prioritized_action_responses']>[number]>(
'prioritized_action_responses',
setFieldValue,
);

// FIXME: We might need to use useFormArrayWithEmptyCheck
const {
setValue: setCustomComponentValue,
removeValue: removeCustomComponentValue,
Expand Down

0 comments on commit df80c4f

Please sign in to comment.