api: reconfigered api handling
This commit is contained in:
@@ -1,47 +1,28 @@
|
||||
import { View, Image, Text, TouchableOpacity } from "react-native";
|
||||
import styles from "@/app/stackStyles/participantStyles";
|
||||
import Ionicons from "@expo/vector-icons/Ionicons";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { usePersonContext } from "@/contexts/PersonContext";
|
||||
import * as WebBrowser from "expo-web-browser";
|
||||
import {
|
||||
ScrollView,
|
||||
GestureHandlerRootView,
|
||||
} from "react-native-gesture-handler";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { Image, Text, TouchableOpacity, View } from "react-native";
|
||||
|
||||
import { useShowContext } from "@/contexts/ShowContext";
|
||||
import {
|
||||
GestureHandlerRootView,
|
||||
ScrollView,
|
||||
} from "react-native-gesture-handler";
|
||||
|
||||
export default function ParticipantScreen() {
|
||||
const { getPersonAppearances, isLoading, getError } = usePersonContext();
|
||||
const [appearances, setAppearances] = useState<
|
||||
|
||||
const [appearances,] = useState<
|
||||
{
|
||||
showId: number;
|
||||
seasons: number[];
|
||||
}[]
|
||||
>([]);
|
||||
const { shows, error, loading } = useShowContext();
|
||||
const { participantId, name, season } = useLocalSearchParams();
|
||||
const numericId = Array.isArray(participantId)
|
||||
? Number(participantId[0])
|
||||
: Number(participantId);
|
||||
const { shows} = useShowContext();
|
||||
const { name } = useLocalSearchParams();
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
(async () => {
|
||||
if (!numericId || Number.isNaN(numericId)) return;
|
||||
const data = await getPersonAppearances(numericId);
|
||||
if (!active) return;
|
||||
const grouped = data.showIds.map((id) => ({
|
||||
showId: id,
|
||||
seasons: data.byShow[id],
|
||||
partners: data.partnersByShow[id] || [],
|
||||
}));
|
||||
setAppearances(grouped as any);
|
||||
})();
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [numericId, getPersonAppearances]);
|
||||
|
||||
|
||||
const resolved = useMemo(
|
||||
() =>
|
||||
@@ -88,21 +69,9 @@ export default function ParticipantScreen() {
|
||||
|
||||
<View style={styles.performedShowsSection}>
|
||||
<Text style={styles.performedShowsTitle}>Auftritte:</Text>
|
||||
{isLoading(numericId) && (
|
||||
<Text style={{ color: "white", marginTop: 8 }}>Lädt...</Text>
|
||||
)}
|
||||
{getError(numericId) && (
|
||||
<Text style={{ color: "red", marginTop: 8 }}>
|
||||
{getError(numericId)}
|
||||
</Text>
|
||||
)}
|
||||
{!isLoading(numericId) &&
|
||||
resolved.length === 0 &&
|
||||
!getError(numericId) && (
|
||||
<Text style={{ color: "gray", marginTop: 8 }}>
|
||||
Keine Einträge.
|
||||
</Text>
|
||||
)}
|
||||
|
||||
|
||||
|
||||
<ScrollView
|
||||
horizontal
|
||||
showsHorizontalScrollIndicator={false}
|
||||
|
||||
Reference in New Issue
Block a user