feat: tags fixes
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// src/api/CategoriesApi.js
|
||||
export default class CategoriesApi {
|
||||
constructor(token) {
|
||||
this.baseUrl = 'https://inventory-bff.dream-views.com/api/v1/Tags';
|
||||
this.tagUrl = 'https://inventory-bff.dream-views.com/api/v1/Tag'; // <— singular
|
||||
this.tagTypeUrl = 'https://inventory-bff.dream-views.com/api/v1/TagType';
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@@ -13,8 +14,9 @@ export default class CategoriesApi {
|
||||
};
|
||||
}
|
||||
|
||||
// TAGS
|
||||
async getAll() {
|
||||
const res = await fetch(`${this.baseUrl}/GetAll`, {
|
||||
const res = await fetch(`${this.tagUrl}/GetAll`, {
|
||||
method: 'GET',
|
||||
headers: this.headers(false),
|
||||
});
|
||||
@@ -22,8 +24,8 @@ export default class CategoriesApi {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async create(payload) {
|
||||
const res = await fetch(`${this.baseUrl}/Create`, {
|
||||
async create(payload) { // CreateTagRequest
|
||||
const res = await fetch(`${this.tagUrl}/Create`, {
|
||||
method: 'POST',
|
||||
headers: this.headers(),
|
||||
body: JSON.stringify(payload),
|
||||
@@ -32,8 +34,8 @@ export default class CategoriesApi {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async update(payload) {
|
||||
const res = await fetch(`${this.baseUrl}/Update`, {
|
||||
async update(payload) { // UpdateTagRequest
|
||||
const res = await fetch(`${this.tagUrl}/Update`, {
|
||||
method: 'PUT',
|
||||
headers: this.headers(),
|
||||
body: JSON.stringify(payload),
|
||||
@@ -42,8 +44,18 @@ export default class CategoriesApi {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async changeStatus(payload) { // { id, status }
|
||||
const res = await fetch(`${this.tagUrl}/ChangeStatus`, {
|
||||
method: 'PATCH',
|
||||
headers: this.headers(),
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
if (!res.ok) throw new Error(`ChangeStatus error ${res.status}: ${await res.text()}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async delete(payload) {
|
||||
const res = await fetch(`${this.baseUrl}/Delete`, {
|
||||
const res = await fetch(`${this.tagUrl}/Delete`, {
|
||||
method: 'DELETE',
|
||||
headers: this.headers(),
|
||||
body: JSON.stringify(payload),
|
||||
@@ -51,4 +63,14 @@ export default class CategoriesApi {
|
||||
if (!res.ok) throw new Error(`Delete error ${res.status}: ${await res.text()}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// TAG TYPES (para <select> de typeId)
|
||||
async getAllTypes() {
|
||||
const res = await fetch(`${this.tagTypeUrl}/GetAll`, {
|
||||
method: 'GET',
|
||||
headers: this.headers(false),
|
||||
});
|
||||
if (!res.ok) throw new Error(`GetAllTypes error ${res.status}: ${await res.text()}`);
|
||||
return res.json();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user