chore: add edit form
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// src/api/userApi.js
|
||||
export default class UserApi {
|
||||
constructor(token) {
|
||||
this.baseUrl = 'https://thalos-bff.dream-views.com/api/v1/User';
|
||||
@@ -32,4 +31,40 @@ export default class UserApi {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// === CREATE a user ===
|
||||
async createUser(userData) {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/Create`, {
|
||||
method: 'POST',
|
||||
headers: this.getHeaders(),
|
||||
body: JSON.stringify(userData),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to create user: ${response.status}`);
|
||||
}
|
||||
return await response.json();
|
||||
} catch (err) {
|
||||
console.error('Error creating user:', err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// === UPDATE a user ===
|
||||
async updateUser(userData) {
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/Update`, {
|
||||
method: 'PUT',
|
||||
headers: this.getHeaders(),
|
||||
body: JSON.stringify(userData),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to update user: ${response.status}`);
|
||||
}
|
||||
return await response.json();
|
||||
} catch (err) {
|
||||
console.error('Error updating user:', err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user