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 { api } from "../api/client";
|
||||
import { showError } from "../banner";
|
||||
import { ExpectedVsActualChart } from "../components/charts/ExpectedVsActualChart";
|
||||
import { formatMinutesSeconds } from "../components/PaceField";
|
||||
import { RawDataModal } from "../components/RawDataModal";
|
||||
@@ -164,7 +165,6 @@ export function Activities() {
|
||||
const [kinds, setKinds] = useState<WorkoutKind[]>([]);
|
||||
const [profile, setProfile] = useState<Profile | null>(null);
|
||||
const [filterKindId, setFilterKindId] = useState<string>("");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [resolvingId, setResolvingId] = useState<number | null>(null);
|
||||
const [rawDataItem, setRawDataItem] = useState<ReviewQueueItem | null>(null);
|
||||
|
||||
@@ -211,7 +211,7 @@ export function Activities() {
|
||||
setItems((prev) => [...prev, ...page.items]);
|
||||
setNextCursor(page.next_cursor);
|
||||
} catch (e) {
|
||||
if (gen === generationRef.current) setError(String(e));
|
||||
if (gen === generationRef.current) showError(String(e));
|
||||
} finally {
|
||||
setLoadingMore(false);
|
||||
inFlightRef.current = null;
|
||||
@@ -240,7 +240,7 @@ export function Activities() {
|
||||
if (filter === "") setGrandTotal(page.total);
|
||||
})
|
||||
.catch((e) => {
|
||||
if (gen === generationRef.current) setError(String(e));
|
||||
if (gen === generationRef.current) showError(String(e));
|
||||
})
|
||||
.finally(() => {
|
||||
if (gen === generationRef.current) setInitialLoading(false);
|
||||
@@ -249,8 +249,8 @@ export function Activities() {
|
||||
|
||||
useEffect(() => {
|
||||
loadFirstPage("");
|
||||
api.listWorkoutKinds().then(setKinds).catch((e) => setError(String(e)));
|
||||
api.getProfile().then(setProfile).catch((e) => setError(String(e)));
|
||||
api.listWorkoutKinds().then(setKinds).catch((e) => showError(String(e)));
|
||||
api.getProfile().then(setProfile).catch((e) => showError(String(e)));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
@@ -289,7 +289,7 @@ export function Activities() {
|
||||
.filter((i) => matchesFilter(i, filterKindId)),
|
||||
);
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
showError(String(e));
|
||||
} finally {
|
||||
setResolvingId(null);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ export function Activities() {
|
||||
.filter((i) => matchesFilter(i, filterKindId)),
|
||||
);
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
showError(String(e));
|
||||
} finally {
|
||||
setResolvingId(null);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ export function Activities() {
|
||||
.filter((i) => matchesFilter(i, filterKindId)),
|
||||
);
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
showError(String(e));
|
||||
} finally {
|
||||
setResolvingId(null);
|
||||
}
|
||||
@@ -341,8 +341,6 @@ export function Activities() {
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
{error && <p className="error">{error}</p>}
|
||||
|
||||
{grandTotal > 0 && (
|
||||
<div className="filter-pills">
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user