Implemented. Sign in, then open Experience or Skills to:
- Add, edit, and delete experience entries and project links. - Manage skill categories and individual skill labels. - Edit the skills introduction and “How I work” text. Changes save directly to Supabase—no code edits or Git push needed. Existing content is preserved.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useAdmin } from "./components/AdminSession";
|
||||
|
||||
export default function usePortfolioResource(fetchContent) {
|
||||
const { sessionRevision } = useAdmin();
|
||||
const [attempt, setAttempt] = useState(0);
|
||||
const [state, setState] = useState({ data: null, loading: true, error: "" });
|
||||
const reload = useCallback(() => setAttempt((value) => value + 1), []);
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
setState((current) => ({ ...current, loading: true, error: "" }));
|
||||
fetchContent(controller.signal).then((data) => {
|
||||
if (!controller.signal.aborted) setState({ data, loading: false, error: "" });
|
||||
}).catch((error) => {
|
||||
if (!controller.signal.aborted) setState((current) => ({ ...current, loading: false, error: error.message }));
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, [fetchContent, sessionRevision, attempt]);
|
||||
useEffect(() => {
|
||||
if (!state.error) return;
|
||||
window.addEventListener("online", reload);
|
||||
window.addEventListener("focus", reload);
|
||||
return () => { window.removeEventListener("online", reload); window.removeEventListener("focus", reload); };
|
||||
}, [state.error, reload]);
|
||||
const setData = useCallback((update) => setState((current) => ({ ...current, data: typeof update === "function" ? update(current.data) : update, error: "" })), []);
|
||||
return { ...state, reload, setData };
|
||||
}
|
||||
Reference in New Issue
Block a user