mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-05-04 21:32:40 +02:00
Add settings page with profile, notifications, and admin sections
- Add sidebar navigation to settings page - Add profile section for name management and password change - Add admin section for user management and registration toggle - Add profile API endpoints (GET/PUT /profile, PUT /profile/password) - Add admin API endpoints (users CRUD, system settings) - Add system_settings table for registration control - Add name and is_admin columns to users table - First registered user automatically becomes admin - Check registration status on register/login page Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0c8ce22cc1
commit
f46c6ad9d4
8 changed files with 1129 additions and 133 deletions
|
|
@ -38,6 +38,9 @@ export const authApi = {
|
|||
|
||||
login: (email: string, password: string) =>
|
||||
api.post('/auth/login', { email, password }),
|
||||
|
||||
getRegistrationStatus: () =>
|
||||
api.get<{ registration_enabled: boolean }>('/auth/registration-status'),
|
||||
};
|
||||
|
||||
// Products API
|
||||
|
|
@ -139,4 +142,45 @@ export const settingsApi = {
|
|||
api.post<{ message: string }>('/settings/notifications/test/discord'),
|
||||
};
|
||||
|
||||
// Profile API
|
||||
export interface UserProfile {
|
||||
id: number;
|
||||
email: string;
|
||||
name: string | null;
|
||||
is_admin: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export const profileApi = {
|
||||
get: () => api.get<UserProfile>('/profile'),
|
||||
|
||||
update: (data: { name?: string }) =>
|
||||
api.put<UserProfile>('/profile', data),
|
||||
|
||||
changePassword: (currentPassword: string, newPassword: string) =>
|
||||
api.put<{ message: string }>('/profile/password', {
|
||||
current_password: currentPassword,
|
||||
new_password: newPassword,
|
||||
}),
|
||||
};
|
||||
|
||||
// Admin API
|
||||
export interface SystemSettings {
|
||||
registration_enabled: string;
|
||||
}
|
||||
|
||||
export const adminApi = {
|
||||
getUsers: () => api.get<UserProfile[]>('/admin/users'),
|
||||
|
||||
deleteUser: (id: number) => api.delete(`/admin/users/${id}`),
|
||||
|
||||
setUserAdmin: (id: number, isAdmin: boolean) =>
|
||||
api.put(`/admin/users/${id}/admin`, { is_admin: isAdmin }),
|
||||
|
||||
getSettings: () => api.get<SystemSettings>('/admin/settings'),
|
||||
|
||||
updateSettings: (data: { registration_enabled?: boolean }) =>
|
||||
api.put<SystemSettings>('/admin/settings', data),
|
||||
};
|
||||
|
||||
export default api;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue