Ongoing workout session data is persistent now
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { User, UserRole, UserProfile } from '../types';
|
||||
import { api, setAuthToken, removeAuthToken } from './api';
|
||||
|
||||
export const getUsers = (): any[] => {
|
||||
// Not used in frontend anymore
|
||||
return [];
|
||||
export const getUsers = async (): Promise<{ success: boolean; users?: User[]; error?: string }> => {
|
||||
try {
|
||||
const res = await api.get('/auth/users');
|
||||
return res;
|
||||
} catch (e) {
|
||||
return { success: false, error: 'Failed to fetch users' };
|
||||
}
|
||||
};
|
||||
|
||||
export const login = async (email: string, password: string): Promise<{ success: boolean; user?: User; error?: string }> => {
|
||||
@@ -43,11 +47,21 @@ export const createUser = async (email: string, password: string): Promise<{ suc
|
||||
};
|
||||
|
||||
export const deleteUser = async (userId: string) => {
|
||||
// Admin only, not implemented in frontend UI yet
|
||||
try {
|
||||
const res = await api.delete(`/auth/users/${userId}`);
|
||||
return res;
|
||||
} catch (e) {
|
||||
return { success: false, error: 'Failed to delete user' };
|
||||
}
|
||||
};
|
||||
|
||||
export const toggleBlockUser = (userId: string, block: boolean) => {
|
||||
// Admin only
|
||||
export const toggleBlockUser = async (userId: string, block: boolean) => {
|
||||
try {
|
||||
const res = await api.patch(`/auth/users/${userId}/block`, { block });
|
||||
return res;
|
||||
} catch (e) {
|
||||
return { success: false, error: 'Failed to update user status' };
|
||||
}
|
||||
};
|
||||
|
||||
export const adminResetPassword = (userId: string, newPass: string) => {
|
||||
|
||||
Reference in New Issue
Block a user