diff --git a/web/sections/HomePanel.tsx b/web/sections/HomePanel.tsx index 9a3cbe9..8bcdd90 100644 --- a/web/sections/HomePanel.tsx +++ b/web/sections/HomePanel.tsx @@ -92,13 +92,18 @@ export const HomePanel = () => { } }; - const saveContent = () => - send('content', () => - clientRef.current.patch<{ data: Home }>('/fofos-admin/home', { - hero_url: heroUrl.trim() || null, - intro_text: intro.trim() || null, - }), - ); + /* + One PATCH per card, carrying only that card's field. + + `take()` on the server treats an absent key as "leave it alone", so sending the whole object from + either card would have each one saving the other's unsaved edits. Two cards, two independent + saves, and a half-finished intro cannot ride along with a hero somebody meant to change. + */ + const saveIntro = () => + send('intro', () => clientRef.current.patch<{ data: Home }>('/fofos-admin/home', { intro_text: intro.trim() || null })); + + const saveHero = () => + send('hero', () => clientRef.current.patch<{ data: Home }>('/fofos-admin/home', { hero_url: heroUrl.trim() || null })); const add = () => send('add', async () => { @@ -137,15 +142,23 @@ export const HomePanel = () => { ); } - const contentDirty = heroUrl.trim() !== (home.hero.url ?? '') || intro.trim() !== (home.intro_text ?? ''); + const introDirty = intro.trim() !== (home.intro_text ?? ''); + const heroDirty = heroUrl.trim() !== (home.hero.url ?? ''); return (
The video or image across the top of the page.
+The paragraph under the hero.
The video or image across the top of the page.
+Intro
- {/* HTML in and HTML out — it is what the site's database already holds and renders. */} -{error}
}