Skip to content

Commit

Permalink
Merge development and solve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
anagperal committed Oct 3, 2024
2 parents 416f097 + 49a6927 commit 0c1b32a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 9 additions & 7 deletions src/webapp/pages/event-tracker/EventTrackerPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import React, { useCallback, useEffect } from "react";
import styled from "styled-components";
import { Box, Button } from "@material-ui/core";
import { useParams } from "react-router-dom";
Expand Down Expand Up @@ -55,6 +55,12 @@ export const EventTrackerPage: React.FC = React.memo(() => {

const { dateRangeFilter } = useMapFilters();

const goToRiskSummaryForm = useCallback(() => {
goTo(RouteName.CREATE_FORM, {
formType: "risk-assessment-summary",
});
}, [goTo]);

useEffect(() => {
if (eventTrackerDetails) changeCurrentEventTrackerId(eventTrackerDetails);
}, [changeCurrentEventTrackerId, eventTrackerDetails, id]);
Expand Down Expand Up @@ -106,9 +112,7 @@ export const EventTrackerPage: React.FC = React.memo(() => {
color="primary"
startIcon={<EditOutlined />}
onClick={() => {
goTo(RouteName.CREATE_FORM, {
formType: "risk-assessment-summary",
});
goToRiskSummaryForm();
}}
>
{i18n.t("Create Risk Assessment")}
Expand All @@ -119,9 +123,7 @@ export const EventTrackerPage: React.FC = React.memo(() => {
color="secondary"
startIcon={<AddCircleOutline />}
onClick={() => {
goTo(RouteName.CREATE_FORM, {
formType: "risk-assessment-summary",
});
goToRiskSummaryForm();
}}
>
{i18n.t("Add new Assessment")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import { applyRulesInFormState } from "./applyRulesInFormState";
export function updateAndValidateFormState(
prevFormState: FormState,
updatedField: FormFieldState,
configirableForm: ConfigurableForm
configurableForm: ConfigurableForm
): FormState {
const updatedForm = updateFormStateAndApplySideEffects(prevFormState, updatedField);

const hasUpdatedFieldAnyRule =
configirableForm.rules.filter(rule => rule.fieldId === updatedField.id).length > 0;
configurableForm.rules.filter(rule => rule.fieldId === updatedField.id).length > 0;

const updatedFormWithRulesApplied = hasUpdatedFieldAnyRule
? applyRulesInFormState(updatedForm, updatedField, configirableForm.rules)
? applyRulesInFormState(updatedForm, updatedField, configurableForm.rules)
: updatedForm;

const fieldValidationErrors = validateFormState(
updatedFormWithRulesApplied,
updatedField,
configirableForm
configurableForm
);

const updatedFormStateWithErrors = updateFormStateWithFieldErrors(
Expand Down

0 comments on commit 0c1b32a

Please sign in to comment.