diff --git a/components/HumanDate.tsx b/components/HumanDate.tsx
new file mode 100644
index 0000000..19f57bc
--- /dev/null
+++ b/components/HumanDate.tsx
@@ -0,0 +1,24 @@
+import { useTranslation } from "next-i18next"
+
+type HumanDateProps = {
+ date: Date
+}
+
+
+export function HumanDate({date}: HumanDateProps) {
+ const {t} = useTranslation()
+
+ if(Number.isNaN(date.getTime())) {
+ return (
+
+ {t("dateNaN")}
+
+ )
+ }
+
+ return (
+
+ )
+}
\ No newline at end of file
diff --git a/components/editable/EditableDateRange.tsx b/components/editable/EditableDateRange.tsx
index e8b5d3e..14deda5 100644
--- a/components/editable/EditableDateRange.tsx
+++ b/components/editable/EditableDateRange.tsx
@@ -4,6 +4,7 @@ import { EditingContext } from "../../contexts/editing"
import { useDefinedContext } from "../../utils/definedContext"
import { FestaIcon } from "../extensions/FestaIcon"
import { FormDateRange } from "../form/FormDateRange"
+import { HumanDate } from "../HumanDate"
type EditableDateRangeProps = {
@@ -15,44 +16,56 @@ type EditableDateRangeProps = {
export function EditableDateRange(props: EditableDateRangeProps) {
const [editing,] = useDefinedContext(EditingContext)
- const startDate = props.startProps
+ if(editing) {
+ return (
+
+ }
+ start={
+
+ }
+ connector={
+
+ }
+ end={
+
+ }
+ />
+ )
+ }
- return editing ? (
-
- }
- start={
-
- }
- connector={
-
- }
- end={
-
- }
- />
- ) : (
+ const startTime = Date.parse(props.startProps.value!)
+ const endTime = Date.parse(props.endProps.value!)
+
+ if(Number.isNaN(startTime) && Number.isNaN(endTime)) {
+ return null
+ }
+
+ const startDate = new Date(startTime)
+ const endDate = new Date(endTime)
+
+ return (
}
start={
- new Date(Date.parse(props.startProps.value!)).toLocaleString()
+
}
connector={
}
end={
- new Date(Date.parse(props.endProps.value!)).toLocaleString()
+
}
/>
)
diff --git a/pages/events/[slug].tsx b/pages/events/[slug].tsx
index dcadb45..c1fb356 100644
--- a/pages/events/[slug].tsx
+++ b/pages/events/[slug].tsx
@@ -51,8 +51,8 @@ export default function PageEventDetail({event}: PageEventDetailProps) {
const [title, setTitle] = useState(event.name)
const [description, setDescription] = useState(event.description)
const [postcard, setPostcard] = useState(event.postcard)
- const [startingAt, setStartingAt] = useState(event.startingAt?.toISOString() ?? null)
- const [endingAt, setEndingAt] = useState(event.endingAt?.toISOString() ?? null)
+ const [startingAt, setStartingAt] = useState(event.startingAt?.toISOString() ?? "")
+ const [endingAt, setEndingAt] = useState(event.endingAt?.toISOString() ?? "")
const setPostcardBlob = useCallback(
(e: ChangeEvent) => {
@@ -105,11 +105,11 @@ export default function PageEventDetail({event}: PageEventDetailProps) {
daterange={
) => setStartingAt(e.target.value)
}}
endProps={{
- value: endingAt ?? undefined,
+ value: endingAt ?? "",
onChange: (e: ChangeEvent) => setEndingAt(e.target.value)
}}
/>
diff --git a/public/locales/it-IT/common.json b/public/locales/it-IT/common.json
index d3a29ce..811ecb5 100644
--- a/public/locales/it-IT/common.json
+++ b/public/locales/it-IT/common.json
@@ -31,5 +31,6 @@
"eventDetailsTitlePlaceholder": "Titolo",
"eventDetailsDescriptionPlaceholder": "Descrizione evento",
"eventDetailsPostcardPlaceholder": "Cartolina",
- "workInProgress": "Questa pagina è ancora in sviluppo e potrebbe contenere errori o testo inaspettato."
+ "workInProgress": "Questa pagina è ancora in sviluppo e potrebbe contenere errori o testo inaspettato.",
+ "dateNaN": "Non specificata"
}