mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-21 05:15:13 +02:00
feat: implement user management settings page with user editing functionality
This commit is contained in:
33
web/src/routes/dashboard/settings/+page.ts
Normal file
33
web/src/routes/dashboard/settings/+page.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {env} from '$env/dynamic/public';
|
||||
import type {PageLoad} from './$types';
|
||||
|
||||
export const load: PageLoad = async ({params, fetch}) => {
|
||||
try {
|
||||
const users = await fetch(env.PUBLIC_API_URL + "/users/all", {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (!users.ok) {
|
||||
console.error(`Failed to fetch users: ${users.statusText}`);
|
||||
return {
|
||||
users: null,
|
||||
};
|
||||
}
|
||||
|
||||
const usersData = await users.json();
|
||||
console.log('Fetched users:', usersData);
|
||||
|
||||
return {
|
||||
users: usersData,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching users:', error);
|
||||
return {
|
||||
users: null,
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user