trithuc-mvc-react 2.7.2 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/api/index.js +30 -8
  2. package/package.json +1 -1
package/api/index.js CHANGED
@@ -139,19 +139,41 @@ export const saveDataToTable = async ({ tableName, data }) => {
139
139
  }
140
140
  }
141
141
  };
142
- export const changeStatusDataToTable = async ({ tableName, id }) => {
142
+ export const changeStatusDataToTable = async ({ tableName, id, fieldName }) => {
143
143
  if (!apiUrl) {
144
144
  const res = await api.post(`${getBaseUrl()}/Admin/${tableName}/ChangeStatus`, {
145
145
  id
146
146
  });
147
147
  return res.data;
148
148
  } else {
149
- const res = await api.post(`${getBaseUrl()}/${apiUrl}/${tableName}/ChangeStatus`, id, {
150
- headers: {
151
- "Content-Type": "application/json-patch+json" // Đảm bảo Content-Type là đúng
149
+ try {
150
+ if (fieldName) {
151
+ const res = await api.post(
152
+ `${getBaseUrl()}/${apiUrl ? `${apiUrl}/` : "Admin/"}${tableName}/ChangeStatus`,
153
+ {
154
+ id,
155
+ fieldName
156
+ },
157
+ {
158
+ headers: {
159
+ "Content-Type": "application/json-patch+json" // Đảm bảo Content-Type là đúng
160
+ }
161
+ }
162
+ );
163
+ return res.data;
164
+ } else {
165
+ const res = await api.post(`${getBaseUrl()}/${apiUrl ? `${apiUrl}/` : "Admin/"}${tableName}/ChangeStatus`, id, {
166
+ headers: {
167
+ "Content-Type": "application/json-patch+json" // Đảm bảo Content-Type là đúng
168
+ }
169
+ });
170
+ return res.data;
152
171
  }
153
- });
154
- return res.data;
172
+ } catch (error) {
173
+ console.error("Error changing status:", error);
174
+ // Xử lý lỗi tùy thuộc vào nhu cầu của bạn, có thể ném ra hoặc trả về giá trị mặc định
175
+ throw error; // Hoặc return { success: false, message: error.message };
176
+ }
155
177
  }
156
178
  };
157
179
 
@@ -199,7 +221,7 @@ export const uploadFile = async (formData) => {
199
221
  }
200
222
  };
201
223
 
202
- export const huongDan = async ({data}) => {
224
+ export const huongDan = async ({ data }) => {
203
225
  if (!apiUrl) {
204
226
  return [];
205
227
  } else {
@@ -218,4 +240,4 @@ export const huongDan = async ({data}) => {
218
240
  );
219
241
  return res.data;
220
242
  }
221
- };
243
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"