Skip to content

Commit

Permalink
feat: Add toast when user completes supplementary form
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Sep 10, 2023
1 parent 49240bf commit 9226a34
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions domains/DataCollection/Forms/SupplementaryForm/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Make this render but switch between forms
import surveyingUserFailsafe from "@app/domains/DataCollection/Forms/utils";
import { AlertContext } from "@context/alert.context";
import PopupError from "@impacto-design-system/Base/PopupError";
import ErrorPicker from "@impacto-design-system/Extensions/FormikFields/ErrorPicker";
import PaperInputPicker from "@impacto-design-system/Extensions/FormikFields/PaperInputPicker";
Expand All @@ -10,7 +11,7 @@ import I18n from "@modules/i18n";
import { layout, theme } from "@modules/theme";
import { isEmpty } from "@modules/utils";
import { Formik } from "formik";
import React, { useEffect, useState } from "react";
import React, { useContext, useEffect, useState } from "react";
import { ActivityIndicator, Platform, View } from "react-native";
import { Button, Text } from "react-native-paper";

Expand Down Expand Up @@ -38,6 +39,7 @@ const SupplementaryForm = ({
const [submitting, setSubmitting] = useState(false);
const [loopsAdded, setLoopsAdded] = useState(0);
const [submissionError, setSubmissionError] = useState(false);
const { alert } = useContext(AlertContext);

const toRoot = () => {
navigation.navigate("Root");
Expand Down Expand Up @@ -124,17 +126,17 @@ const SupplementaryForm = ({
}, 1000);
};

postSupplementaryForm(postParams).then(
() => {
submitAction();
},
(error) => {
console.log(error); // eslint-disable-line
// perhaps an alert to let the user know there was an error
setSubmitting(false);
setSubmissionError(true);
}
);
try {
const supplementaryForm = await postSupplementaryForm(postParams);
console.log(supplementaryForm);
alert(` ${I18n.t("forms.successfullySubmitted")}`);
submitAction();
} catch (e) {
console.log(error); // eslint-disable-line
// perhaps an alert to let the user know there was an error
setSubmitting(false);
setSubmissionError(true);
}
}}
validationSchema={validationSchema}
// only validate on submit, errors persist after fixing
Expand Down

0 comments on commit 9226a34

Please sign in to comment.