fix more type things
This commit is contained in:
@ -20,6 +20,7 @@ export const EventItem = ({
|
||||
size?: "small" | "medium" | "large";
|
||||
}) => {
|
||||
const nextOccurrence = getClosestOccurrence(event);
|
||||
const numOccurrences = event?.occurrences?.length ?? 0;
|
||||
|
||||
return (
|
||||
<li
|
||||
@ -42,9 +43,10 @@ export const EventItem = ({
|
||||
<h1 className={styles.title}>{event.title}</h1>
|
||||
{mode === "list" && nextOccurrence && (
|
||||
<p className={styles.details}>
|
||||
{event.occurrences.length === 1 &&
|
||||
{numOccurrences === 1 &&
|
||||
nextOccurrence?.start &&
|
||||
formatDate(nextOccurrence.start, commonDateFormat)}
|
||||
{event.occurrences.length > 1 && nextOccurrence && (
|
||||
{numOccurrences > 1 && nextOccurrence?.start && (
|
||||
<span>
|
||||
<em>Neste:</em>{" "}
|
||||
{formatDate(nextOccurrence.start, commonDateFormat)}
|
||||
@ -52,7 +54,9 @@ export const EventItem = ({
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{mode === "calendar" && event.occurrence?.start && (
|
||||
{mode === "calendar" &&
|
||||
"occurrence" in event &&
|
||||
event.occurrence?.start && (
|
||||
<p className={styles.details}>
|
||||
{formatDate(event.occurrence?.start, "'kl.' HH:mm")}
|
||||
</p>
|
||||
|
@ -6,7 +6,7 @@ export const FeaturedEvents = ({ events }: { events: EventFragment[] }) => {
|
||||
return (
|
||||
<ul className={styles.eventList}>
|
||||
{events.map((event) => (
|
||||
<EventItem key={event.id} event={event} />
|
||||
<EventItem key={event.id} event={event} mode="list" />
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
|
@ -95,8 +95,8 @@ function isDefined<T>(val: T | undefined | null): val is T {
|
||||
|
||||
interface EventsByDate {
|
||||
[yearMonth: string]: {
|
||||
[week: number]: {
|
||||
[day: number]: SingularEvent[];
|
||||
[week: string]: {
|
||||
[day: string]: SingularEvent[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user