Archived
Campuses frontend, docs and e2e (1.43.0)
Site settings -> Campuses tab; campus picker in the event editor; campus filter and badges on the events list, public events page (remembered, starts on home campus) and reports/dashboards; /campus/<slug> pages and sitemap; home campus on the profile; "Everyone at a campus" in email and WhatsApp broadcasts. Help, FEATURES, SETTINGS, API docs, protocol doc (campusCount), handover and roadmap updated; campuses seeded for e2e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ApiImage } from "@/components/shared/ApiImage";
|
||||
import { Calendar, MapPin } from "lucide-react";
|
||||
import { ContactButton } from "@/components/events/ContactButton";
|
||||
import { CampusBadge } from "@/components/shared/CampusFilter";
|
||||
|
||||
type Event = {
|
||||
id: string;
|
||||
@@ -24,6 +25,7 @@ import { ContactButton } from "@/components/events/ContactButton";
|
||||
scheduleType?: "single" | "sessions";
|
||||
sessions?: EventSession[];
|
||||
registrationClosesAt?: string;
|
||||
campus?: { id: string; name: string; slug: string; colour: string | null } | null;
|
||||
};
|
||||
|
||||
import { formatDateTimeRange } from "@/lib/date";
|
||||
@@ -66,6 +68,7 @@ export const EventCard = ({ event }: { event: Event }) => {
|
||||
)}
|
||||
<div className="p-4">
|
||||
<h3 className="text-lg font-semibold hover:underline">{event.title}</h3>
|
||||
<CampusBadge campus={event.campus} className="mt-1" />
|
||||
<p className="text-sm text-gray-500 flex items-center gap-1.5 mt-1">
|
||||
<Calendar className="w-3.5 h-3.5 shrink-0" />
|
||||
{dateRange}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { CalendarX } from "lucide-react";
|
||||
import { EventCard } from "@/components/events/EventCard";
|
||||
import { CampusFilter } from "@/components/shared/CampusFilter";
|
||||
import { useCampuses } from "@/hooks/useCampuses";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
|
||||
type GridEvent = React.ComponentProps<typeof EventCard>["event"] & { campusId?: string | null };
|
||||
|
||||
// The visitor's campus choice, kept in this browser (like the cookie choice).
|
||||
const STORAGE_KEY = "hope_events_campus";
|
||||
|
||||
function readStored(): string | null {
|
||||
try { return localStorage.getItem(STORAGE_KEY); } catch { return null; }
|
||||
}
|
||||
function store(value: string) {
|
||||
try { localStorage.setItem(STORAGE_KEY, value); } catch { /* private window etc. */ }
|
||||
}
|
||||
|
||||
/**
|
||||
* The public events grid with a campus filter (while campuses are on). A campus shows its own
|
||||
* events plus church-wide ones. Starts on the visitor's last choice, else their home campus.
|
||||
*/
|
||||
export function EventsGrid({ events }: { events: GridEvent[] }) {
|
||||
const { enabled, campuses } = useCampuses();
|
||||
const { user } = useAuth();
|
||||
const [campus, setCampus] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
const stored = readStored();
|
||||
const start = stored ?? user?.homeCampusId ?? "";
|
||||
// Only a campus that still exists (an archived one falls back to every campus).
|
||||
setCampus(start && campuses.some(c => c.id === start) ? start : "");
|
||||
}, [enabled, campuses, user?.homeCampusId]);
|
||||
|
||||
const choose = (value: string) => { setCampus(value); store(value); };
|
||||
const shown = enabled && campus ? events.filter(e => !e.campusId || e.campusId === campus) : events;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-6">
|
||||
<CampusFilter value={campus} onChange={choose} id="events-campus" />
|
||||
</div>
|
||||
{shown.length === 0 ? (
|
||||
<div className="text-center py-16 border rounded-xl bg-gray-50">
|
||||
<CalendarX className="w-8 h-8 text-gray-300 mx-auto mb-2" />
|
||||
<p className="text-gray-500 text-sm">{events.length ? "No events at this campus right now — try another campus." : "No events available right now — check back soon."}</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-6 md:grid-cols-3 sm:grid-cols-2">
|
||||
{shown.map(event => <EventCard key={event.id} event={event} />)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user