1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2025-01-10 07:49:45 +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 { faCircleExclamation } from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "next-i18next";
import { FestaIcon } from "./FestaIcon"; import { FestaIcon } from "./FestaIcon";
type ErrorBlockProps = { type ErrorBlockProps = {
error: JSON, error: JSON,
text?: string text: string
} }
export function ErrorBlock(props: ErrorBlockProps) { export function ErrorBlock(props: ErrorBlockProps) {
const {t} = useTranslation()
return ( return (
<div className="error error-block negative"> <div className="error error-block negative">
@ -16,7 +14,7 @@ export function ErrorBlock(props: ErrorBlockProps) {
<FestaIcon icon={faCircleExclamation}/> <FestaIcon icon={faCircleExclamation}/>
&nbsp; &nbsp;
<span> <span>
{props.text ?? t("genericError")} {props.text}
</span> </span>
</p> </p>
<pre> <pre>

View file

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

View file

@ -49,6 +49,6 @@ export function EventCreate() {
disabled={!name} disabled={!name}
/> />
</form> </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 { faAsterisk } from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "next-i18next";
import { FestaIcon } from "./FestaIcon"; import { FestaIcon } from "./FestaIcon";
type LoadingProps = { type LoadingProps = {
@ -7,8 +6,6 @@ type LoadingProps = {
} }
export function Loading(props: LoadingProps) { export function Loading(props: LoadingProps) {
const {t} = useTranslation()
return ( return (
<span> <span>
<FestaIcon icon={faAsterisk} spin/> <FestaIcon icon={faAsterisk} spin/>

View file

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