refactor(frontend): migrate Activities.tsx to the banner system
Every load/classify/unlock failure now calls showError instead of setting local error state; the inline error paragraph is removed.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { api } from "../api/client";
|
import { api } from "../api/client";
|
||||||
|
import { showError } from "../banner";
|
||||||
import { ExpectedVsActualChart } from "../components/charts/ExpectedVsActualChart";
|
import { ExpectedVsActualChart } from "../components/charts/ExpectedVsActualChart";
|
||||||
import { formatMinutesSeconds } from "../components/PaceField";
|
import { formatMinutesSeconds } from "../components/PaceField";
|
||||||
import { RawDataModal } from "../components/RawDataModal";
|
import { RawDataModal } from "../components/RawDataModal";
|
||||||
@@ -164,7 +165,6 @@ export function Activities() {
|
|||||||
const [kinds, setKinds] = useState<WorkoutKind[]>([]);
|
const [kinds, setKinds] = useState<WorkoutKind[]>([]);
|
||||||
const [profile, setProfile] = useState<Profile | null>(null);
|
const [profile, setProfile] = useState<Profile | null>(null);
|
||||||
const [filterKindId, setFilterKindId] = useState<string>("");
|
const [filterKindId, setFilterKindId] = useState<string>("");
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
const [resolvingId, setResolvingId] = useState<number | null>(null);
|
const [resolvingId, setResolvingId] = useState<number | null>(null);
|
||||||
const [rawDataItem, setRawDataItem] = useState<ReviewQueueItem | null>(null);
|
const [rawDataItem, setRawDataItem] = useState<ReviewQueueItem | null>(null);
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ export function Activities() {
|
|||||||
setItems((prev) => [...prev, ...page.items]);
|
setItems((prev) => [...prev, ...page.items]);
|
||||||
setNextCursor(page.next_cursor);
|
setNextCursor(page.next_cursor);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (gen === generationRef.current) setError(String(e));
|
if (gen === generationRef.current) showError(String(e));
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingMore(false);
|
setLoadingMore(false);
|
||||||
inFlightRef.current = null;
|
inFlightRef.current = null;
|
||||||
@@ -240,7 +240,7 @@ export function Activities() {
|
|||||||
if (filter === "") setGrandTotal(page.total);
|
if (filter === "") setGrandTotal(page.total);
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (gen === generationRef.current) setError(String(e));
|
if (gen === generationRef.current) showError(String(e));
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (gen === generationRef.current) setInitialLoading(false);
|
if (gen === generationRef.current) setInitialLoading(false);
|
||||||
@@ -249,8 +249,8 @@ export function Activities() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadFirstPage("");
|
loadFirstPage("");
|
||||||
api.listWorkoutKinds().then(setKinds).catch((e) => setError(String(e)));
|
api.listWorkoutKinds().then(setKinds).catch((e) => showError(String(e)));
|
||||||
api.getProfile().then(setProfile).catch((e) => setError(String(e)));
|
api.getProfile().then(setProfile).catch((e) => showError(String(e)));
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ export function Activities() {
|
|||||||
.filter((i) => matchesFilter(i, filterKindId)),
|
.filter((i) => matchesFilter(i, filterKindId)),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(String(e));
|
showError(String(e));
|
||||||
} finally {
|
} finally {
|
||||||
setResolvingId(null);
|
setResolvingId(null);
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ export function Activities() {
|
|||||||
.filter((i) => matchesFilter(i, filterKindId)),
|
.filter((i) => matchesFilter(i, filterKindId)),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(String(e));
|
showError(String(e));
|
||||||
} finally {
|
} finally {
|
||||||
setResolvingId(null);
|
setResolvingId(null);
|
||||||
}
|
}
|
||||||
@@ -327,7 +327,7 @@ export function Activities() {
|
|||||||
.filter((i) => matchesFilter(i, filterKindId)),
|
.filter((i) => matchesFilter(i, filterKindId)),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(String(e));
|
showError(String(e));
|
||||||
} finally {
|
} finally {
|
||||||
setResolvingId(null);
|
setResolvingId(null);
|
||||||
}
|
}
|
||||||
@@ -341,8 +341,6 @@ export function Activities() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
{error && <p className="error">{error}</p>}
|
|
||||||
|
|
||||||
{grandTotal > 0 && (
|
{grandTotal > 0 && (
|
||||||
<div className="filter-pills">
|
<div className="filter-pills">
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user