mirror of
https://github.com/Steffo99/festa.git
synced 2025-01-09 23:39:44 +00:00
Enforce required text
prop in Error components
This commit is contained in:
parent
6b3a27736e
commit
ee08aea776
5 changed files with 6 additions and 13 deletions
|
@ -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}/>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
{props.text ?? t("genericError")}
|
{props.text}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
|
|
|
@ -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}/>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
{props.text ?? t("genericError")}
|
{props.text}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<code lang="json">
|
<code lang="json">
|
||||||
|
|
|
@ -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}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
|
@ -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/>
|
||||||
|
|
|
@ -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:"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue