diff --git a/src/api/apiClient.tsx b/src/api/apiClient.tsx index 00060bd..f70709d 100644 --- a/src/api/apiClient.tsx +++ b/src/api/apiClient.tsx @@ -1,7 +1,7 @@ import axios, { type AxiosRequestConfig, type Method, type AxiosResponse } from 'axios' const apiClient = axios.create({ - baseURL: 'https://auth.api.sitblueprint.com/api', + baseURL: 'https://dev.api.sitblueprint.com/api/v1', headers: { Accept: 'application/json', 'Content-type': 'application/json' diff --git a/src/api/lib/users.tsx b/src/api/lib/users.tsx index 9beecd3..46e8632 100644 --- a/src/api/lib/users.tsx +++ b/src/api/lib/users.tsx @@ -2,11 +2,12 @@ import { type AxiosResponse, AxiosError } from 'axios' import request from '../apiClient' import type { User } from '../../types/index' -const API_NAME = 'User Management' +const API_NAME = 'Blueprint Backend API' +const BASE = '/user/' export const getAllUsers = async (): Promise => { try { - const response = await request('GET', '/v1/users/all') + const response = await request('GET', BASE + 'all') return response } catch (error) { if (error instanceof AxiosError) { @@ -17,9 +18,9 @@ export const getAllUsers = async (): Promise => { } } -export const getUser = async (username: string): Promise => { +export const getUser = async (userId: string): Promise => { try { - const response = await request('GET', `/v1/users/user?username=${username}`) + const response = await request('GET', BASE + `user?userId=${userId}`) return response } catch (error) { if (error instanceof AxiosError) { @@ -32,7 +33,7 @@ export const getUser = async (username: string): Promise => { export const addUser = async (user: User): Promise => { try { - const response = await request('POST', '/v1/users/user', JSON.stringify(user)) + const response = await request('POST', BASE + 'user', JSON.stringify(user)) return response } catch (error) { if (error instanceof AxiosError) { @@ -43,9 +44,9 @@ export const addUser = async (user: User): Promise => { } } -export const updateUser = async (username: string, user: User): Promise => { +export const updateUser = async (user: User): Promise => { try { - const response = await request('PUT', `/v1/users/user?username=${username}`, JSON.stringify(user)) + const response = await request('PUT', BASE + 'user', JSON.stringify(user)) return response } catch (error) { if (error instanceof AxiosError) { @@ -56,22 +57,9 @@ export const updateUser = async (username: string, user: User): Promise => { +export const deleteUser = async (userId: string): Promise => { try { - const response = await request('DELETE', `/v1/users/user?username=${username}`) - return response - } catch (error) { - if (error instanceof AxiosError) { - console.error(`${API_NAME} Error: ${error.message}`, error.response?.data) - throw new Error(`${API_NAME} Error: ${error.response?.status} ${error.response?.data?.error}`) - } - throw new Error('Unknown Error') - } -} - -export const getMemberSizeWeeklyChange = async (): Promise => { - try { - const response = await request('GET', '/v1/users/memberSizeWeeklyChange') + const response = await request('DELETE', BASE + `userId?=${userId}`) return response } catch (error) { if (error instanceof AxiosError) {