Skip to content

Commit

Permalink
Merge pull request #80 from Etherna/feature/EWEB-90-antihill-page
Browse files Browse the repository at this point in the history
fix localized labels
  • Loading branch information
mattiaz9 authored Nov 4, 2024
2 parents a6acbd1 + 97ffc9c commit 25e11f5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions apps/web/src/components/landing/product-subscription-form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react"
import { useTranslation } from "react-i18next"
import axios from "axios"

import { SpinnerLight } from "@/components/assets/animated"
Expand All @@ -8,7 +7,6 @@ import { Alert } from "@/components/common/alert"
import { Button } from "@/components/common/button"
import { cn } from "@/utils/classnames"
import { userLocale } from "@/utils/lang"
import { routes } from "@/utils/routes"
import { validateEmail } from "@/utils/validation"

import type { InputHTMLAttributes } from "react"
Expand All @@ -19,7 +17,6 @@ export function ProductSubscriptionForm() {
const [isSubmitting, setIsSubmitting] = useState(false)
const [error, setError] = useState<string>()
const [isSuccess, setIsSuccess] = useState(false)
const { t } = useTranslation("landing")

const sendFormRequest = async () => {
setIsSubmitting(true)
Expand All @@ -28,12 +25,12 @@ export function ProductSubscriptionForm() {
// fields validation
if (firstName.length < 2) {
setIsSubmitting(false)
setError(t("subcribeErrorName"))
setError("Please enter your name.")
return
}
if (email.length === 0 || !validateEmail(email)) {
setIsSubmitting(false)
setError(t("subcribeErrorEmail"))
setError("Please enter a valid email address.")
return
}

Expand All @@ -54,7 +51,7 @@ export function ProductSubscriptionForm() {
setFirstName("")
} catch (err) {
console.error(err)
setError(t("subcribeErrorDescription"))
setError("An error occurred. Please try again.")
setIsSubmitting(false)
}
}
Expand All @@ -65,15 +62,15 @@ export function ProductSubscriptionForm() {
<NewsletterFormField
type="text"
className="w-full rounded-md lg:max-w-full"
placeholder={t("namePlaceholder")}
placeholder={"Your name"}
autoComplete="name"
value={firstName}
onChange={e => setFirstName(e.target.value)}
/>
<NewsletterFormField
type="email"
className="w-full rounded-md lg:max-w-full"
placeholder={t("emailPlaceholder")}
placeholder={"Your main email"}
autoComplete="email"
inputMode="email"
value={email}
Expand All @@ -93,7 +90,7 @@ export function ProductSubscriptionForm() {

{error && (
<div className="my-4 w-full max-w-4xl">
<Alert type="danger" title={t("subcribeErrorTitle")} onClose={() => setError(undefined)}>
<Alert type="danger" title={"Subscription error"} onClose={() => setError(undefined)}>
{error}
</Alert>
</div>
Expand Down

0 comments on commit 25e11f5

Please sign in to comment.