Skip to content

Commit

Permalink
changes made:
Browse files Browse the repository at this point in the history
1. remove unused import
2. combine and update error messages
  • Loading branch information
prachigarg19 committed Oct 20, 2023
1 parent 6d34fde commit 74ca710
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,5 @@
"topProject": "Top Project",
"top_project_standards_fulfilled": "The project inspection revealed that this project fulfilled at least 12 of the 19 Top Project <2>standards.</2>",
"standardsLink": "https://www.plant-for-the-planet.org/standards/",
"wrongEmailEntered": "Email id incorrect!"
"enterValidEmail": "Please enter a valid email"
}
12 changes: 6 additions & 6 deletions src/Donations/Components/ContactsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { ContactDetails } from "@planet-sdk/common";
import { AddressCandidate, GeocodeSuggestion } from "src/Common/Types/arcgis";
import GiftIcon from "public/assets/icons/GiftIcon";
import { euCountries } from "src/Utils/countryUtils";
import { z } from "zod";
import { isEmailValid } from "src/Utils/isEmailValid";

interface FormData extends ContactDetails {
Expand Down Expand Up @@ -300,11 +299,12 @@ function ContactsForm(): ReactElement {
/>
)}
/>
{errors.email && errors.email.type === "required" && (
<span className={"form-errors"}>{t("emailRequired")}</span>
)}
{errors.email && errors.email.type === "emailInvalid" && (
<span className={"form-errors"}>{t("wrongEmailEntered")}</span>
{errors.email && (
<span className={"form-errors"}>
{errors.email.type === "required"
? t("emailRequired")
: t("enterValidEmail")}
</span>
)}
{/* {errors.email && errors.email.type === "validate" && (
<span className={"form-errors"}>{t("useSameEmail")}</span>
Expand Down
19 changes: 7 additions & 12 deletions src/Donations/Micros/GiftForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,13 @@ export default function GiftForm(): ReactElement {
/>
)}
/>
{errors.recipientEmail &&
errors.recipientEmail.type === "required" && (
<span className={"form-errors"}>
{t("emailRequired")}
</span>
)}
{errors.recipientEmail &&
errors.recipientEmail.type === "emailInvalid" && (
<span className={"form-errors"}>
{t("wrongEmailEntered")}
</span>
)}
{errors.recipientEmail && (
<span className={"form-errors"}>
{errors.recipientEmail.type === "required"
? t("emailRequired")
: t("enterValidEmail")}
</span>
)}
</div>
<div className={"form-field mt-30"}>
<Controller
Expand Down
11 changes: 5 additions & 6 deletions src/Donations/Micros/OnBehalf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ const OnBehalf: FC = () => {
)}
/>
{errors.email && errors.email.type === "required" && (
<span className={"form-errors"}>{t("emailRequired")}</span>
)}
{errors.email && errors.email.type === "emailInvalid" && (
<span className={"form-errors"}>
{t("inValidField", {
fieldName: "Email",
})}
{errors.email.type === "required"
? t("emailRequired")
: t("inValidField", {
fieldName: "Email",
})}
</span>
)}
</Grid>
Expand Down

0 comments on commit 74ca710

Please sign in to comment.