mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
25 lines
708 B
TypeScript
25 lines
708 B
TypeScript
import { useTranslation } from "react-i18next";
|
|
import { useActionData } from "react-router";
|
|
import type { Namespace } from "~/modules/i18n/resources.server";
|
|
import styles from "./FormErrors.module.css";
|
|
|
|
export function FormErrors({ namespace }: { namespace: Namespace }) {
|
|
const { t } = useTranslation(["common", namespace]);
|
|
const actionData = useActionData<{ errors?: string[] }>();
|
|
|
|
if (!actionData?.errors || actionData.errors.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
<h4>{t("common:forms.errors.title")}:</h4>
|
|
<ol>
|
|
{actionData.errors.map((error) => (
|
|
<li key={error}>{t(`${namespace}:${error}` as any)}</li>
|
|
))}
|
|
</ol>
|
|
</div>
|
|
);
|
|
}
|