1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-10-16 15:07:27 +00:00

Enforce required text prop in Error components

This commit is contained in:
Steffo 2022-06-02 04:34:40 +02:00
parent 6b3a27736e
commit ee08aea776
Signed by: steffo
GPG key ID: 6965406171929D01
5 changed files with 6 additions and 13 deletions

View file

@ -1,14 +1,12 @@
import { faCircleExclamation } from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "next-i18next";
import { FestaIcon } from "./FestaIcon";
type ErrorBlockProps = {
error: JSON,
text?: string
text: string
}
export function ErrorBlock(props: ErrorBlockProps) {
const {t} = useTranslation()
return (
<div className="error error-block negative">
@ -16,7 +14,7 @@ export function ErrorBlock(props: ErrorBlockProps) {
<FestaIcon icon={faCircleExclamation}/>
&nbsp;
<span>
{props.text ?? t("genericError")}
{props.text}
</span>
</p>
<pre>

View file

@ -1,5 +1,4 @@
import { faCircleExclamation } from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "next-i18next";
import { FestaIcon } from "./FestaIcon";
type ErrorInlineProps = {
@ -8,14 +7,12 @@ type ErrorInlineProps = {
}
export function ErrorInline(props: ErrorInlineProps) {
const {t} = useTranslation()
return (
<span className="error error-inline negative">
<FestaIcon icon={faCircleExclamation}/>
&nbsp;
<span>
{props.text ?? t("genericError")}
{props.text}
</span>
&nbsp;
<code lang="json">

View file

@ -49,6 +49,6 @@ export function EventCreate() {
disabled={!name}
/>
</form>
{createEvent.error ? <ErrorBlock error={createEvent.error}/> : null}
{createEvent.error ? <ErrorBlock error={createEvent.error} text={t("eventListCreateError")}/> : null}
</>
}

View file

@ -1,5 +1,4 @@
import { faAsterisk } from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "next-i18next";
import { FestaIcon } from "./FestaIcon";
type LoadingProps = {
@ -7,8 +6,6 @@ type LoadingProps = {
}
export function Loading(props: LoadingProps) {
const {t} = useTranslation()
return (
<span>
<FestaIcon icon={faAsterisk} spin/>

View file

@ -20,5 +20,6 @@
"eventListCreateFirst": "Inserisci il nome del tuo primo evento qui sotto!",
"eventListCreateEventNameLabel": "Nome evento",
"eventListCreateSubmitLabel": "Crea",
"eventListCreateRunning": "Creazione in corso..."
"eventListCreateRunning": "Creazione in corso...",
"eventListCreateError": "Si è verificato il seguente errore nella creazione del tuo evento:"
}