Files
website/src/app/admin/settings/actions.ts
2025-10-13 21:04:21 +02:00

20 lines
533 B
TypeScript

import { actions } from 'astro:actions';
import { actionErrorPopup } from '@util/action.ts';
export async function updateSettings(changes: { [k: string]: string | null }) {
const { error } = await actions.settings.setSettings({
settings: Object.entries(changes).reduce(
(prev, curr) => {
prev.push({ name: curr[0], value: curr[1] });
return prev;
},
[] as { name: string; value: string | null }[]
)
});
if (error) {
actionErrorPopup(error);
return false;
}
return true;
}