sendou.ink/app/components/FormErrors.tsx
Kalle 323a1ea5e3 Remove useTranslation wrapper Closes #1595
This broke after upgrading deps and couldn't figure it out with a quick look.

It just makes it a bit more convenient when adding new pages & debugging
but not really that necessary so decided to delete it for now.
2023-12-07 20:33:59 +02:00

28 lines
718 B
TypeScript

import { useActionData } from "@remix-run/react";
import type { CustomTypeOptions } from "react-i18next";
import { useTranslation } from "react-i18next";
export function FormErrors({
namespace,
}: {
namespace: keyof CustomTypeOptions["resources"];
}) {
const { t } = useTranslation(["common", namespace]);
const actionData = useActionData<{ errors?: string[] }>();
if (!actionData?.errors || actionData.errors.length === 0) {
return null;
}
return (
<div className="form-errors">
<h4>{t("common:forms.errors.title")}:</h4>
<ol>
{actionData.errors.map((error) => (
<li key={error}>{t(`${namespace}:${error}` as any)}</li>
))}
</ol>
</div>
);
}