mirror of
https://github.com/Steffo99/festa.git
synced 2025-01-09 15:29: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 { 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}/>
|
||||
|
||||
<span>
|
||||
{props.text ?? t("genericError")}
|
||||
{props.text}
|
||||
</span>
|
||||
</p>
|
||||
<pre>
|
||||
|
|
|
@ -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}/>
|
||||
|
||||
<span>
|
||||
{props.text ?? t("genericError")}
|
||||
{props.text}
|
||||
</span>
|
||||
|
||||
<code lang="json">
|
||||
|
|
|
@ -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}
|
||||
</>
|
||||
}
|
|
@ -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/>
|
||||
|
|
|
@ -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:"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue