trithuc-mvc-react 2.7.0 → 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
+ };
@@ -211,7 +211,10 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
211
211
  };
212
212
 
213
213
  const handleChangeRowsPerPage = (event) => {
214
- setRowsPerPage(parseInt(event.target.value, 10));
214
+ const newRowsPerPage = parseInt(event.target.value, 10); // Chuyển đổi giá trị thành số nguyên
215
+ // Lưu giá trị mới vào localStorage với khóa tùy chỉnh theo tableName
216
+ localStorage.setItem(`${tableName}rowsPerPage`, newRowsPerPage);
217
+ setRowsPerPage(newRowsPerPage);
215
218
  setPage(0);
216
219
  };
217
220
  const handleDeleteMultiple = () => {
@@ -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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"