mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-20 14:12:01 -05:00
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.
28 lines
718 B
TypeScript
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>
|
|
);
|
|
}
|