trithuc-mvc-react 2.7.1 → 2.7.2
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.
package/api/index.js
CHANGED
|
@@ -198,3 +198,24 @@ export const uploadFile = async (formData) => {
|
|
|
198
198
|
return res.data;
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
|
+
|
|
202
|
+
export const huongDan = async ({data}) => {
|
|
203
|
+
if (!apiUrl) {
|
|
204
|
+
return [];
|
|
205
|
+
} else {
|
|
206
|
+
const res = await api.get(
|
|
207
|
+
`${getBaseUrl()}/${apiUrl}/HuongDanSuDung/Dropdownlist`,
|
|
208
|
+
{
|
|
209
|
+
params: {
|
|
210
|
+
...data
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
headers: {
|
|
215
|
+
"Content-Type": "application/json-patch+json" // Đảm bảo Content-Type là đúng
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
return res.data;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { Tooltip, IconButton } from "@mui/material";
|
|
3
|
+
import { LightbulbOutlined } from "@mui/icons-material";
|
|
4
|
+
import { huongDan } from "../../api";
|
|
5
|
+
|
|
6
|
+
const HuongDanButton = ({ tableName, size = "small" }) => {
|
|
7
|
+
const [dataAvailable, setDataAvailable] = useState(false);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const fetchData = async () => {
|
|
11
|
+
try {
|
|
12
|
+
const data = { TableName: tableName };
|
|
13
|
+
const response = await huongDan({ data });
|
|
14
|
+
if (response?.data[0]) {
|
|
15
|
+
setDataAvailable(true);
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error("Error fetching guide data", error);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
fetchData();
|
|
23
|
+
}, [tableName]);
|
|
24
|
+
|
|
25
|
+
const handleHuongDan = () => {
|
|
26
|
+
window.open(`/huong-dan-su-dung/::${tableName}`, "_blank").focus();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (!dataAvailable) {
|
|
30
|
+
return null; // Không hiển thị nút nếu không có dữ liệu
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Tooltip title="Hướng dẫn">
|
|
35
|
+
<IconButton variant="outlined" color="primary" size={size} onClick={handleHuongDan}>
|
|
36
|
+
<LightbulbOutlined fontSize="inherit" />
|
|
37
|
+
</IconButton>
|
|
38
|
+
</Tooltip>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default HuongDanButton;
|
|
@@ -5,7 +5,7 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
5
5
|
import { DataTableContext } from "./context";
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
import DataTable from "./DataTable";
|
|
8
|
-
import { Add, Refresh } from "@mui/icons-material";
|
|
8
|
+
import { Add, Lightbulb, LightbulbCircle, LightbulbCircleOutlined, LightbulbOutlined, Refresh } from "@mui/icons-material";
|
|
9
9
|
|
|
10
10
|
import { FormProvider, useForm } from "react-hook-form";
|
|
11
11
|
import EditorDialog from "./EditorDialog";
|
|
@@ -14,6 +14,7 @@ import ViewDetailDialog from "./ViewDetailDialog";
|
|
|
14
14
|
import ExportExcelButton from "./ExportExcelButton";
|
|
15
15
|
import { FilterGod } from "./FilterGod";
|
|
16
16
|
import { usePermission } from "../../hooks";
|
|
17
|
+
import HuongDanButton from "./HuongDanButton";
|
|
17
18
|
|
|
18
19
|
DataManagement.propTypes = {
|
|
19
20
|
columns: PropTypes.array,
|
|
@@ -177,6 +178,7 @@ function DataManagement({
|
|
|
177
178
|
<Stack direction="row" justifyContent={"space-between"} sx={{ mb: upXL ? 2 : 1, ...slotProps?.header?.sx }}>
|
|
178
179
|
<Typography variant="h4">{title}</Typography>
|
|
179
180
|
<Stack direction="row" spacing={1}>
|
|
181
|
+
<HuongDanButton tableName={tableName} size={elementSize} />
|
|
180
182
|
<Tooltip title="Làm mới">
|
|
181
183
|
<IconButton
|
|
182
184
|
variant="outlined"
|