trithuc-mvc-react 2.6.1 → 2.6.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 +19 -10
  2. package/package.json +1 -1
package/api/index.js CHANGED
@@ -66,15 +66,24 @@ export const getDatasFromTable = async ({ tableName, page, pageSize, data }) =>
66
66
  };
67
67
 
68
68
  export const getDataFromTable = async ({ tableName, id }) => {
69
- try {
70
- const url = apiUrl ? `${getBaseUrl()}/${apiUrl}/${tableName}` : `${getBaseUrl()}/Admin/${tableName}/GetDetail`;
71
-
72
- const res = await api.get(url, {
73
- params: {
74
- id
75
- }
76
- });
77
- return res.data;
69
+ try {
70
+ if (!apiUrl) {
71
+ const url = `${getBaseUrl()}/Admin/${tableName}/GetDetail`;
72
+ const res = await api.get(url, {
73
+ params: {
74
+ id
75
+ }
76
+ });
77
+ return res.data;
78
+ }else{
79
+ const url = `${getBaseUrl()}/${apiUrl}/${tableName}/${id}`;
80
+ const res = await api.get(url, {
81
+ params: {
82
+ id
83
+ }
84
+ });
85
+ return res.data;
86
+ }
78
87
  } catch (error) {
79
88
  console.error("Error fetching data:", error);
80
89
  throw error;
@@ -123,7 +132,7 @@ export const saveDataToTable = async ({ tableName, data }) => {
123
132
  });
124
133
  return res.data;
125
134
  } else {
126
- if (!data.Id) {
135
+ if (!data.Id || data.Id === "0") {
127
136
  // Khi không có ID, thực hiện POST đến apiUrl
128
137
  const res = await api.post(`${getBaseUrl()}/${apiUrl}/${tableName}`, data);
129
138
  return res.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"