feat: enhance admin settings handling and update RightSidebar to use dynamic node description

This commit is contained in:
Christopher
2026-01-22 05:08:15 -08:00
parent 52883ba380
commit bb1d31c1e7
2 changed files with 20 additions and 10 deletions
+8 -5
View File
@@ -163,13 +163,14 @@ export default function AdminPage() {
}
};
const handleSaveSettings = async () => {
const handleSaveSettings = async (override?: typeof nodeSettings) => {
const payload = override ?? nodeSettings;
setSavingSettings(true);
try {
const res = await fetch('/api/admin/node', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(nodeSettings),
body: JSON.stringify(payload),
});
if (res.ok) {
alert('Settings saved!');
@@ -204,10 +205,12 @@ export default function AdminPage() {
throw new Error(data.error || 'Upload failed');
}
setNodeSettings((prev) => ({
...prev,
const nextSettings = {
...nodeSettings,
bannerUrl: data.media?.url || data.url,
}));
};
setNodeSettings(nextSettings);
await handleSaveSettings(nextSettings);
} catch (error) {
console.error('Banner upload failed', error);
setBannerUploadError('Upload failed. Please try again.');
+12 -5
View File
@@ -3,21 +3,28 @@
import { useState, useEffect } from 'react';
export function RightSidebar() {
const fallbackDescription = process.env.NEXT_PUBLIC_NODE_DESCRIPTION || 'A federated social network node.';
const [nodeInfo, setNodeInfo] = useState({
name: process.env.NEXT_PUBLIC_NODE_NAME || 'Synapsis Node',
description: 'A federated social network designed as global communication infrastructure. Signal over noise. Identity that is truly yours.',
description: fallbackDescription,
longDescription: '',
rules: '',
bannerUrl: '',
});
useEffect(() => {
fetch('/api/node')
fetch('/api/node', { cache: 'no-store' })
.then(res => res.json())
.then(data => {
if (data.name) {
setNodeInfo(prev => ({ ...prev, ...data }));
}
setNodeInfo(prev => ({
...prev,
...data,
name: data?.name ?? prev.name,
description: data?.description ?? prev.description,
longDescription: data?.longDescription ?? prev.longDescription,
rules: data?.rules ?? prev.rules,
bannerUrl: data?.bannerUrl ?? prev.bannerUrl,
}));
})
.catch(() => { });
}, []);