weiterer fortschritt mit tamagui und dem neuen mobile event admin

This commit is contained in:
Codex Agent
2025-12-10 20:01:47 +01:00
parent 73e550ee87
commit 7b01a77083
26 changed files with 761 additions and 139 deletions

View File

@@ -22,6 +22,8 @@ const EventContext = React.createContext<EventContextValue | undefined>(undefine
export function EventProvider({ children }: { children: React.ReactNode }) {
const { status } = useAuth();
const [manualEvents, setManualEvents] = React.useState<TenantEvent[]>([]);
const [manualAttempted, setManualAttempted] = React.useState(false);
const [storedSlug, setStoredSlug] = React.useState<string | null>(() => {
if (typeof window === 'undefined') {
return null;
@@ -51,8 +53,28 @@ export function EventProvider({ children }: { children: React.ReactNode }) {
initialData: [],
});
const events = React.useMemo(() => (authReady ? fetchedEvents : []), [authReady, fetchedEvents]);
const isLoading = authReady ? queryLoading : status === 'loading';
const events = React.useMemo(
() => (authReady ? (manualEvents.length ? manualEvents : fetchedEvents) : []),
[authReady, fetchedEvents, manualEvents]
);
const isLoading = authReady ? queryLoading || (!manualAttempted && manualEvents.length === 0 && fetchedEvents.length === 0) : status === 'loading';
React.useEffect(() => {
if (!authReady || manualAttempted || queryLoading) {
return;
}
if (fetchedEvents.length > 0 && !isError) {
return;
}
setManualAttempted(true);
getEvents({ force: true })
.then((list) => {
setManualEvents(list ?? []);
})
.catch(() => {
setManualEvents([]);
});
}, [authReady, fetchedEvents.length, isError, manualAttempted, queryLoading]);
React.useEffect(() => {
if (!events.length || typeof window === 'undefined') {