@zauru-sdk/hooks 1.0.50 → 1.0.52
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/dist/alerts.d.ts +1 -1
- package/dist/{alerts.js → cjs/alerts.js} +13 -9
- package/dist/{automaticNumbers.js → cjs/automaticNumbers.js} +20 -16
- package/dist/cjs/catalogs.js +267 -0
- package/dist/{components → cjs/components}/Alert.js +18 -15
- package/dist/cjs/components/index.js +17 -0
- package/dist/cjs/index.js +26 -0
- package/dist/{onlineStatus.js → cjs/onlineStatus.js} +8 -4
- package/dist/cjs/profiles.js +64 -0
- package/dist/{receptions.js → cjs/receptions.js} +67 -52
- package/dist/{session.js → cjs/session.js} +19 -15
- package/dist/{templates.js → cjs/templates.js} +20 -16
- package/dist/{useWindowDimensions.js → cjs/useWindowDimensions.js} +8 -4
- package/dist/esm/alerts.js +37 -0
- package/dist/esm/automaticNumbers.js +57 -0
- package/dist/esm/catalogs.js +267 -0
- package/dist/esm/components/Alert.js +100 -0
- package/dist/esm/components/index.js +17 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/onlineStatus.js +31 -0
- package/dist/esm/profiles.js +64 -0
- package/dist/esm/receptions.js +348 -0
- package/dist/esm/session.js +55 -0
- package/dist/esm/templates.js +58 -0
- package/dist/esm/useWindowDimensions.js +31 -0
- package/dist/receptions.d.ts +2 -2
- package/package.json +14 -19
- package/.eslintrc.cjs +0 -83
- package/CHANGELOG.md +0 -232
- package/dist/catalogs.js +0 -230
- package/dist/components/index.js +0 -1
- package/dist/index.js +0 -10
- package/dist/profiles.js +0 -57
- package/src/alerts.ts +0 -43
- package/src/automaticNumbers.ts +0 -74
- package/src/catalogs.ts +0 -557
- package/src/components/Alert.tsx +0 -149
- package/src/components/index.ts +0 -1
- package/src/index.ts +0 -11
- package/src/onlineStatus.ts +0 -34
- package/src/profiles.ts +0 -103
- package/src/receptions.ts +0 -548
- package/src/session.ts +0 -69
- package/src/templates.ts +0 -84
- package/src/useWindowDimensions.ts +0 -34
- package/tsconfig.json +0 -26
package/src/session.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useFetcher } from "@remix-run/react";
|
|
2
|
-
import {
|
|
3
|
-
setSessionValue,
|
|
4
|
-
useAppDispatch,
|
|
5
|
-
useAppSelector,
|
|
6
|
-
} from "@zauru-sdk/redux";
|
|
7
|
-
import { useEffect, useState } from "react";
|
|
8
|
-
import { showAlert } from "./index.js";
|
|
9
|
-
|
|
10
|
-
export type SERVER_CONFIG_TYPES =
|
|
11
|
-
| "sessionAttribute"
|
|
12
|
-
| "environment"
|
|
13
|
-
| "sessionVariable";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @param attribute
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
export const useGetSessionAttribute = (
|
|
21
|
-
name: string,
|
|
22
|
-
type: SERVER_CONFIG_TYPES
|
|
23
|
-
): string => {
|
|
24
|
-
const fetcher = useFetcher<any>();
|
|
25
|
-
const dispatch = useAppDispatch();
|
|
26
|
-
const sessionData = useAppSelector((state) => state.session[name]);
|
|
27
|
-
const [data, setData] = useState<string>(sessionData);
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (fetcher.data?.title) {
|
|
31
|
-
showAlert({
|
|
32
|
-
description: fetcher.data?.description,
|
|
33
|
-
title: fetcher.data?.title,
|
|
34
|
-
type: fetcher.data?.type,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}, [fetcher.data]);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
41
|
-
const receivedData = fetcher.data as { data: string };
|
|
42
|
-
if (receivedData) {
|
|
43
|
-
setData(receivedData.data);
|
|
44
|
-
dispatch(
|
|
45
|
-
setSessionValue({
|
|
46
|
-
name: name,
|
|
47
|
-
data: receivedData.data,
|
|
48
|
-
})
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}, [fetcher, dispatch, name]);
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (!sessionData) {
|
|
56
|
-
try {
|
|
57
|
-
fetcher.load(`/api/session?name=${name}&type=${type}`);
|
|
58
|
-
} catch (ex) {
|
|
59
|
-
showAlert({
|
|
60
|
-
type: "error",
|
|
61
|
-
title: `Ocurrió un error al cargar la variable de configuración: ${name}.`,
|
|
62
|
-
description: "Error: " + ex,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}, []);
|
|
67
|
-
|
|
68
|
-
return data;
|
|
69
|
-
};
|
package/src/templates.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { useFetcher } from "@remix-run/react";
|
|
2
|
-
import {
|
|
3
|
-
TEMPLATE_NAMES,
|
|
4
|
-
templateFetchStart,
|
|
5
|
-
templateFetchSuccess,
|
|
6
|
-
useAppDispatch,
|
|
7
|
-
useAppSelector,
|
|
8
|
-
} from "@zauru-sdk/redux";
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
|
-
import { showAlert } from "./index.js";
|
|
11
|
-
|
|
12
|
-
type ProfileType<T> = {
|
|
13
|
-
data: T;
|
|
14
|
-
loading: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type ConfigProps = {
|
|
18
|
-
online?: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const useGetTemplateObject = <T>(
|
|
22
|
-
TEMPLATE_NAME: TEMPLATE_NAMES,
|
|
23
|
-
config: ConfigProps = { online: false }
|
|
24
|
-
): ProfileType<T> => {
|
|
25
|
-
const fetcher = useFetcher<any>();
|
|
26
|
-
const dispatch = useAppDispatch();
|
|
27
|
-
const objectData = useAppSelector((state) => state.templates[TEMPLATE_NAME]);
|
|
28
|
-
const [data, setData] = useState<ProfileType<T>>({
|
|
29
|
-
data: Object.keys(objectData?.data).length
|
|
30
|
-
? (objectData?.data as T)
|
|
31
|
-
: ({} as T),
|
|
32
|
-
loading: objectData.loading,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (fetcher.data?.title) {
|
|
37
|
-
showAlert({
|
|
38
|
-
description: fetcher.data?.description,
|
|
39
|
-
title: fetcher.data?.title,
|
|
40
|
-
type: fetcher.data?.type,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}, [fetcher.data]);
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
47
|
-
const receivedData = fetcher.data as { [key: string]: T };
|
|
48
|
-
if (receivedData) {
|
|
49
|
-
setData({ data: receivedData[TEMPLATE_NAME], loading: false });
|
|
50
|
-
dispatch(
|
|
51
|
-
templateFetchSuccess({
|
|
52
|
-
name: TEMPLATE_NAME,
|
|
53
|
-
data: receivedData[TEMPLATE_NAME],
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, [fetcher, dispatch, TEMPLATE_NAME]);
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (Object.keys(objectData?.data).length <= 0 || config?.online) {
|
|
62
|
-
try {
|
|
63
|
-
setData({ ...data, loading: true });
|
|
64
|
-
dispatch(templateFetchStart(TEMPLATE_NAME));
|
|
65
|
-
fetcher.load(`/api/templates?object=${TEMPLATE_NAME}`);
|
|
66
|
-
} catch (ex) {
|
|
67
|
-
showAlert({
|
|
68
|
-
type: "error",
|
|
69
|
-
title: `Ocurrió un error al cargar el object de templates: ${TEMPLATE_NAME}.`,
|
|
70
|
-
description: "Error: " + ex,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}, []);
|
|
75
|
-
|
|
76
|
-
return data;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const useGetReceptionTemplate = (
|
|
80
|
-
config?: ConfigProps
|
|
81
|
-
): {
|
|
82
|
-
loading: boolean;
|
|
83
|
-
data: string;
|
|
84
|
-
} => useGetTemplateObject<string>("receptionTemplate", config);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
function getWindowDimensions() {
|
|
4
|
-
if (typeof window !== "undefined") {
|
|
5
|
-
const { innerWidth: width } = window;
|
|
6
|
-
return width;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Devolver un valor predeterminado si window no está definido
|
|
10
|
-
return 1000;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const useWindowDimensions = () => {
|
|
14
|
-
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (typeof window !== "undefined") {
|
|
18
|
-
const handleResize = () => {
|
|
19
|
-
setWindowDimensions(getWindowDimensions());
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Use window load event to ensure accurate window size on initial load
|
|
23
|
-
window.addEventListener("load", handleResize);
|
|
24
|
-
window.addEventListener("resize", handleResize);
|
|
25
|
-
|
|
26
|
-
return () => {
|
|
27
|
-
window.removeEventListener("load", handleResize);
|
|
28
|
-
window.removeEventListener("resize", handleResize);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
return windowDimensions;
|
|
34
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": ["env.d.ts", "**/*.ts", "**/*.tsx"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
6
|
-
"isolatedModules": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"jsx": "react-jsx",
|
|
9
|
-
"module": "ESNext",
|
|
10
|
-
"moduleResolution": "Bundler",
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"target": "ES2022",
|
|
13
|
-
"strict": true,
|
|
14
|
-
"allowJs": true,
|
|
15
|
-
"skipLibCheck": true,
|
|
16
|
-
"forceConsistentCasingInFileNames": true,
|
|
17
|
-
"baseUrl": ".",
|
|
18
|
-
"outDir": "./dist",
|
|
19
|
-
"rootDir": "./src",
|
|
20
|
-
"declaration": true,
|
|
21
|
-
"declarationDir": "./dist",
|
|
22
|
-
"paths": {
|
|
23
|
-
"~/*": ["./app/*"]
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|