sysone-api-mapper 1.0.0
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/.babelrc +4 -0
- package/README.md +93 -0
- package/axiosInstance.js +5 -0
- package/config/dist/index.js +2 -0
- package/config/dist/index.js.LICENSE.txt +1 -0
- package/config/webpack.dev.js +38 -0
- package/config/webpack.prod.js +41 -0
- package/index.js +5 -0
- package/package.json +30 -0
- package/services.js +105 -0
- package/servicesData.js +1013 -0
- package/src/components/notificationToast.js +37 -0
- package/src/contexts/actionsContext.js +54 -0
- package/src/contexts/translationContext.js +29 -0
- package/src/server.js +20 -0
- package/test/script.js +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { notification } from "antd";
|
|
3
|
+
|
|
4
|
+
const TYPE = {
|
|
5
|
+
SUCCESS: "success",
|
|
6
|
+
ERROR: "error",
|
|
7
|
+
INFO: "info",
|
|
8
|
+
WARNING: "warning",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const openNotificationWithIcon = (type, message, description, subErrors) => {
|
|
12
|
+
return notification[type]({
|
|
13
|
+
message,
|
|
14
|
+
style: {
|
|
15
|
+
minHeight:
|
|
16
|
+
description || (subErrors && subErrors.length > 0) ? "0" : "70px",
|
|
17
|
+
},
|
|
18
|
+
description: (
|
|
19
|
+
<>
|
|
20
|
+
{description ? (
|
|
21
|
+
<>
|
|
22
|
+
<div style={{ fontSize: "13px" }}>{description}</div>
|
|
23
|
+
<br />
|
|
24
|
+
</>
|
|
25
|
+
) : null}
|
|
26
|
+
|
|
27
|
+
{subErrors?.map((e, idx) => (
|
|
28
|
+
<React.Fragment key={`sub_error_${idx}`}>
|
|
29
|
+
<div style={{ fontSize: "16px" }}>- {e}</div>
|
|
30
|
+
<br />
|
|
31
|
+
</React.Fragment>
|
|
32
|
+
))}
|
|
33
|
+
</>
|
|
34
|
+
),
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export { openNotificationWithIcon, TYPE };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
const ActionsContext = createContext();
|
|
4
|
+
|
|
5
|
+
export function useActions() {
|
|
6
|
+
return useContext(ActionsContext);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ActionsProvider({ initialData, children }) {
|
|
10
|
+
const [actions, setActions] = useState([]);
|
|
11
|
+
const [ready, setReady] = useState(false);
|
|
12
|
+
|
|
13
|
+
let actns = [];
|
|
14
|
+
const extractActions = (menus) => {
|
|
15
|
+
menus.map((m) => {
|
|
16
|
+
if (m.actions) {
|
|
17
|
+
actns = [
|
|
18
|
+
...actns,
|
|
19
|
+
...m.actions.map((a) => {
|
|
20
|
+
return {
|
|
21
|
+
code: a.code,
|
|
22
|
+
name: a.name,
|
|
23
|
+
path: a.path,
|
|
24
|
+
menuCode: m.code,
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
if (m.menus) extractActions(m.menus);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return actns;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
extractActions(initialData.menus);
|
|
37
|
+
setActions(actns);
|
|
38
|
+
setReady(true);
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
const hasAction = (key) => {
|
|
42
|
+
const menuCode = key.split(".")[0];
|
|
43
|
+
const actionCode = key.split(".")[1];
|
|
44
|
+
return actions.some(
|
|
45
|
+
(el) => el.menuCode === menuCode && el.code === actionCode
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ActionsContext.Provider value={{ actions, hasAction, ready }}>
|
|
51
|
+
{children}
|
|
52
|
+
</ActionsContext.Provider>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const TranslationContext = createContext();
|
|
4
|
+
|
|
5
|
+
export function useTranslation() {
|
|
6
|
+
return useContext(TranslationContext);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function TranslationProvider({ initialData, children }) {
|
|
10
|
+
const [translations, setTranslationes] = useState(initialData);
|
|
11
|
+
|
|
12
|
+
const t = (key, ...args) => {
|
|
13
|
+
if (!translations) return key;
|
|
14
|
+
let translation =
|
|
15
|
+
translations.find(
|
|
16
|
+
(el) => el.code.toLowerCase().trim() === key.toLowerCase().trim()
|
|
17
|
+
)?.content || key;
|
|
18
|
+
args.forEach(
|
|
19
|
+
(a, index) => (translation = translation.replace(`#${index}#`, a))
|
|
20
|
+
);
|
|
21
|
+
return translation;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<TranslationContext.Provider value={{ translations, t }}>
|
|
26
|
+
{children}
|
|
27
|
+
</TranslationContext.Provider>
|
|
28
|
+
);
|
|
29
|
+
}
|
package/src/server.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const express = require("express");
|
|
2
|
+
const cors = require("cors");
|
|
3
|
+
require("dotenv").config();
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
const port = process.env.PORT || 3000;
|
|
7
|
+
|
|
8
|
+
// Middleware
|
|
9
|
+
app.use(cors());
|
|
10
|
+
app.use(express.json());
|
|
11
|
+
|
|
12
|
+
// Ruta raíz
|
|
13
|
+
app.get("/", (req, res) => {
|
|
14
|
+
res.json({ message: "Hello World!" });
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Iniciar el servidor
|
|
18
|
+
app.listen(port, () => {
|
|
19
|
+
console.log(`Server is running on http://localhost:${port}`);
|
|
20
|
+
});
|
package/test/script.js
ADDED
|
File without changes
|