feat: enhance delete method to support request body and add removePoolMembers API
This commit is contained in:
parent
55bfead4a8
commit
bc7ff54380
@ -154,8 +154,15 @@ export class ApiClient {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
static async delete(endpoint: string, token?: string): Promise<Response> {
|
static async delete(endpoint: string, token?: string, data?: any): Promise<Response> {
|
||||||
return this.makeRequest(endpoint, { method: 'DELETE' }, token)
|
return this.makeRequest(
|
||||||
|
endpoint,
|
||||||
|
{
|
||||||
|
method: 'DELETE',
|
||||||
|
body: data ? JSON.stringify(data) : undefined,
|
||||||
|
},
|
||||||
|
token
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,6 +372,16 @@ export class AdminAPI {
|
|||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async removePoolMembers(token: string, poolId: string | number, userIds: Array<string | number>) {
|
||||||
|
const endpoint = API_ENDPOINTS.ADMIN_POOL_MEMBERS.replace(':id', String(poolId))
|
||||||
|
const response = await ApiClient.delete(endpoint, token, { userIds })
|
||||||
|
if (!response.ok) {
|
||||||
|
const error = await response.json().catch(() => ({ message: 'Failed to remove pool members' }))
|
||||||
|
throw new Error(error.message || 'Failed to remove pool members')
|
||||||
|
}
|
||||||
|
return response.json()
|
||||||
|
}
|
||||||
|
|
||||||
static async updateUserStatus(token: string, userId: string, status: string) {
|
static async updateUserStatus(token: string, userId: string, status: string) {
|
||||||
const endpoint = API_ENDPOINTS.ADMIN_UPDATE_USER_STATUS.replace(':id', userId)
|
const endpoint = API_ENDPOINTS.ADMIN_UPDATE_USER_STATUS.replace(':id', userId)
|
||||||
const response = await ApiClient.patch(endpoint, { status }, token)
|
const response = await ApiClient.patch(endpoint, { status }, token)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user