rewrite website
This commit is contained in:
19
src/app/admin/settings/actions.ts
Normal file
19
src/app/admin/settings/actions.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user