@zauru-sdk/components 6.3.2 → 6.4.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.4.0](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.3.2...@zauru-sdk/components@6.4.0) (2026-09-16)
7
+
8
+
9
+ ### Features
10
+
11
+ * extraer login, logout, home e index a factories del SDK ([83312db](https://github.com/intuitiva/zauru-typescript-sdk/commit/83312db6778188df9852aa2afbf7d45ae3782b47))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [6.3.2](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.3.1...@zauru-sdk/components@6.3.2) (2026-09-16)
7
18
 
8
19
  **Note:** Version bump only for package @zauru-sdk/components
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from "react";
2
+ export type ZauruHomePageProps = {
3
+ title: string;
4
+ includeAgency?: boolean;
5
+ extra?: ReactNode;
6
+ };
7
+ export declare function ZauruHomePage({ title, includeAgency, extra, }: ZauruHomePageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { ZauruHomeLayoutColor } from "./ZauruLoginPage.js";
2
+ export type ZauruIndexPageProps = {
3
+ title: string;
4
+ description?: string;
5
+ color?: ZauruHomeLayoutColor;
6
+ };
7
+ export declare function ZauruIndexPage({ title, description, color, }: ZauruIndexPageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { cleanLocalStorage } from "@zauru-sdk/redux";
2
+ export type ZauruHomeLayoutColor = "green" | "blue" | "red" | "purple" | "yellow";
3
+ export type ZauruLoginPageProps = {
4
+ cleanLocalStorageArgs?: Parameters<typeof cleanLocalStorage>[0];
5
+ color?: ZauruHomeLayoutColor;
6
+ };
7
+ export declare function ZauruLoginPage({ cleanLocalStorageArgs, color, }: ZauruLoginPageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { ZauruHomeLayoutColor } from "./ZauruLoginPage.js";
2
+ export type ZauruLogoutPageProps = {
3
+ requireOnline?: boolean;
4
+ beforeLogout?: () => boolean | void;
5
+ color?: ZauruHomeLayoutColor;
6
+ };
7
+ export declare function ZauruLogoutPage({ requireOnline, beforeLogout, color, }: ZauruLogoutPageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ export type ZauruReloadCatalogItem = {
2
+ name: string;
3
+ loading: boolean;
4
+ };
5
+ export type ZauruReloadCatalogsPageProps = {
6
+ items: ZauruReloadCatalogItem[];
7
+ };
8
+ export declare function ZauruReloadCatalogsPage({ items, }: ZauruReloadCatalogsPageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export * from "./zauruRouteErrorBoundary.js";
2
+ export * from "./ZauruLoginPage.js";
3
+ export * from "./ZauruLogoutPage.js";
4
+ export * from "./ZauruHomePage.js";
5
+ export * from "./ZauruIndexPage.js";
6
+ export * from "./ZauruReloadCatalogsPage.js";
@@ -0,0 +1,4 @@
1
+ export declare function zauruRouteErrorBoundary(from: string): {
2
+ (): import("react/jsx-runtime").JSX.Element;
3
+ displayName: string;
4
+ };
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { useGetAgencyProfile, useGetUserProfile } from "@zauru-sdk/hooks";
4
+ import { getInitialProfileInfo } from "@zauru-sdk/utils";
5
+ import { LabelArray } from "../Titles/LabelArray.js";
6
+ import { ZauruTable } from "../Table/ZauruTable.js";
7
+ import { Container } from "../Containers/Container.js";
8
+ import { DoubleContainer } from "../Containers/DoubleContainer.js";
9
+ import { MainContainer } from "../Containers/MainContainer.js";
10
+ import { SubContainer } from "../Containers/SubContainer.js";
11
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
12
+ import { LoadingWindow } from "../Skeletons/LoadingWindow.js";
13
+ export function ZauruHomePage({ title, includeAgency = true, extra, }) {
14
+ try {
15
+ const [isClient, setIsClient] = useState(false);
16
+ const { data: userProfile } = useGetUserProfile();
17
+ const { data: agencyProfile, loading: loadingAgencyProfile } = useGetAgencyProfile();
18
+ useEffect(() => {
19
+ setIsClient(true);
20
+ }, []);
21
+ const { profileLabelInfo, membershipsInfo } = getInitialProfileInfo(userProfile);
22
+ const conditionalRowStyles = [
23
+ {
24
+ when: (row) => row.odd,
25
+ style: {
26
+ backgroundColor: "white",
27
+ "&:hover": {
28
+ cursor: "pointer",
29
+ },
30
+ },
31
+ },
32
+ {
33
+ when: (row) => row.entityId === userProfile?.profile?.selected_entity_id,
34
+ style: () => ({ backgroundColor: "lightgreen" }),
35
+ },
36
+ ];
37
+ const columns = [
38
+ {
39
+ name: "Entidad",
40
+ selector: (row) => row.entity,
41
+ },
42
+ {
43
+ name: "Contrato Expira",
44
+ selector: (row) => row.contractExpiration,
45
+ width: "10rem",
46
+ },
47
+ {
48
+ name: "Pagado hasta",
49
+ selector: (row) => row.nextPay,
50
+ width: "10rem",
51
+ },
52
+ ];
53
+ if (!isClient) {
54
+ return _jsx(LoadingWindow, { description: "Cargando home..." });
55
+ }
56
+ const pageTitle = includeAgency
57
+ ? loadingAgencyProfile || !agencyProfile
58
+ ? "Cargando..."
59
+ : `${title} (${agencyProfile?.name ?? "Usuario sin agencia asignada"})`
60
+ : title;
61
+ const profileAndMemberships = (_jsxs(_Fragment, { children: [_jsx(SubContainer, { title: "Perfil", children: _jsx(LabelArray, { info: profileLabelInfo }) }), _jsx(SubContainer, { title: "Suscripciones", children: _jsx(ZauruTable, { columns: columns, conditionalRowStyles: conditionalRowStyles, data: membershipsInfo }) })] }));
62
+ return (_jsx(MainContainer, { children: extra ? (_jsxs(DoubleContainer, { title: pageTitle, children: [profileAndMemberships, extra] })) : (_jsx(Container, { title: pageTitle, children: profileAndMemberships })) }));
63
+ }
64
+ catch (error) {
65
+ return (_jsx(ErrorLayout, { from: "/home/index.tsx", error: error, isRootLevel: false }));
66
+ }
67
+ }
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
3
+ import { HomeLayout } from "../Layouts/homeLayout/index.js";
4
+ export function ZauruIndexPage({ title, description = "Inicie sesión para poder continuar.", color, }) {
5
+ try {
6
+ return _jsx(HomeLayout, { title: title, description: description, color: color });
7
+ }
8
+ catch (error) {
9
+ return _jsx(ErrorLayout, { from: "/index.tsx", error: error, isRootLevel: false });
10
+ }
11
+ }
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useFetcher } from "@remix-run/react";
3
+ import { useEffect, useState } from "react";
4
+ import { useValidateNotifications } from "@zauru-sdk/hooks";
5
+ import { cleanLocalStorage, profileFetchSuccess, useAppDispatch, } from "@zauru-sdk/redux";
6
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
7
+ import { HomeLayout } from "../Layouts/homeLayout/index.js";
8
+ import { LoadingWindow } from "../Skeletons/LoadingWindow.js";
9
+ export function ZauruLoginPage({ cleanLocalStorageArgs, color, }) {
10
+ try {
11
+ const fetcher = useFetcher();
12
+ const dispatch = useAppDispatch();
13
+ const [isClient, setIsClient] = useState(false);
14
+ useValidateNotifications({ fetcher });
15
+ useEffect(() => {
16
+ if (fetcher.data?.employeeProfile) {
17
+ dispatch(profileFetchSuccess({
18
+ name: "agencyProfile",
19
+ data: fetcher.data.agencyProfile,
20
+ }));
21
+ dispatch(profileFetchSuccess({
22
+ name: "employeeProfile",
23
+ data: fetcher.data.employeeProfile,
24
+ }));
25
+ dispatch(profileFetchSuccess({
26
+ name: "userProfile",
27
+ data: fetcher.data.userProfile,
28
+ }));
29
+ dispatch(profileFetchSuccess({
30
+ name: "oauthProfile",
31
+ data: fetcher.data.oauthProfile,
32
+ }));
33
+ fetcher.submit({
34
+ action: "redirect",
35
+ cookie: fetcher.data?.cookie,
36
+ }, { method: "post" });
37
+ }
38
+ }, [fetcher.data]);
39
+ useEffect(() => {
40
+ setIsClient(true);
41
+ }, []);
42
+ useEffect(() => {
43
+ cleanLocalStorage(cleanLocalStorageArgs);
44
+ fetcher.submit({ action: "login" }, { method: "post" });
45
+ }, []);
46
+ if (!isClient) {
47
+ return _jsx(LoadingWindow, {});
48
+ }
49
+ return (_jsx(HomeLayout, { loading: true, color: color, title: fetcher.data?.title ? "Error al inciar sesión!" : "Iniciando sesión....", description: fetcher.data?.description ??
50
+ "Cargando (Perfil zauru, perfil oauth, agencia, membresías, webapptables)..." }));
51
+ }
52
+ catch (error) {
53
+ console.log(error);
54
+ return (_jsx(ErrorLayout, { from: "/login/index.tsx", error: error, isRootLevel: false }));
55
+ }
56
+ }
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useFetcher, useNavigate } from "@remix-run/react";
3
+ import { useEffect } from "react";
4
+ import { showAlert, useIsOnline } from "@zauru-sdk/hooks";
5
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
6
+ import { HomeLayout } from "../Layouts/homeLayout/index.js";
7
+ export function ZauruLogoutPage({ requireOnline = true, beforeLogout, color, }) {
8
+ try {
9
+ const fetcher = useFetcher();
10
+ const navigate = useNavigate();
11
+ const isOnline = useIsOnline();
12
+ useEffect(() => {
13
+ if (beforeLogout?.() === false) {
14
+ return;
15
+ }
16
+ if (requireOnline && !isOnline) {
17
+ showAlert({
18
+ title: "No es posible cerrar sesión",
19
+ description: "No hay conexión a internet",
20
+ type: "error",
21
+ });
22
+ navigate("/home");
23
+ return;
24
+ }
25
+ fetcher.submit({ action: "logout" }, { method: "post" });
26
+ }, []);
27
+ return (_jsx(HomeLayout, { color: color, title: "Cerrando sesi\u00F3n", description: "Espere mientras se cierra su sesi\u00F3n..." }));
28
+ }
29
+ catch (error) {
30
+ return (_jsx(ErrorLayout, { from: "/logout/index.tsx", error: error, isRootLevel: false }));
31
+ }
32
+ }
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
4
+ import { LoadingWindow } from "../Skeletons/LoadingWindow.js";
5
+ export function ZauruReloadCatalogsPage({ items, }) {
6
+ try {
7
+ const [isClient, setIsClient] = useState(false);
8
+ useEffect(() => {
9
+ setIsClient(true);
10
+ }, []);
11
+ if (!isClient) {
12
+ return _jsx(LoadingWindow, {});
13
+ }
14
+ const loading = items.some((item) => item.loading);
15
+ return (_jsx(LoadingWindow, { description: loading
16
+ ? "Cargando catálogos..."
17
+ : "Catálogos cargados correctamente ✅", loadingItems: items }));
18
+ }
19
+ catch (error) {
20
+ return (_jsx(ErrorLayout, { from: "/reload-catalogs", error: error, isRootLevel: false }));
21
+ }
22
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./zauruRouteErrorBoundary.js";
2
+ export * from "./ZauruLoginPage.js";
3
+ export * from "./ZauruLogoutPage.js";
4
+ export * from "./ZauruHomePage.js";
5
+ export * from "./ZauruIndexPage.js";
6
+ export * from "./ZauruReloadCatalogsPage.js";
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
3
+ export function zauruRouteErrorBoundary(from) {
4
+ function ZauruRouteErrorBoundary() {
5
+ return _jsx(ErrorLayout, { from: from });
6
+ }
7
+ ZauruRouteErrorBoundary.displayName = `ZauruRouteErrorBoundary(${from})`;
8
+ return ZauruRouteErrorBoundary;
9
+ }
package/dist/esm/index.js CHANGED
@@ -24,4 +24,5 @@ export * from "./WithTooltip/index.js";
24
24
  export * from "./Wizards/index.js";
25
25
  export * from "./Zendesk/index.js";
26
26
  export * from "./HOC/ValidateEmployeeAccess/index.js";
27
+ export * from "./Routes/index.js";
27
28
  export * from "./SidePanel/index.js";
package/dist/index.d.ts CHANGED
@@ -24,4 +24,5 @@ export * from "./WithTooltip/index.js";
24
24
  export * from "./Wizards/index.js";
25
25
  export * from "./Zendesk/index.js";
26
26
  export * from "./HOC/ValidateEmployeeAccess/index.js";
27
+ export * from "./Routes/index.js";
27
28
  export * from "./SidePanel/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/components",
3
- "version": "6.3.2",
3
+ "version": "6.4.0",
4
4
  "description": "Componentes reutilizables en las WebApps de Zauru.",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -49,7 +49,7 @@
49
49
  "@zauru-sdk/icons": "^6.0.0",
50
50
  "@zauru-sdk/redux": "^6.5.9",
51
51
  "@zauru-sdk/types": "^6.16.0",
52
- "@zauru-sdk/utils": "^6.14.0",
52
+ "@zauru-sdk/utils": "^6.15.0",
53
53
  "browser-image-compression": "^2.0.2",
54
54
  "framer-motion": "^12.0.0",
55
55
  "jsonwebtoken": "^9.0.2",
@@ -62,5 +62,5 @@
62
62
  "styled-components": "^5.3.5",
63
63
  "zod": "^3.23.8"
64
64
  },
65
- "gitHead": "b0d95fcc90a6789ba2bf4bdcb0f54070c7583e85"
65
+ "gitHead": "7ccc6b0a3d1c426f8b62579a64a0bb0be73d2fcd"
66
66
  }
@@ -0,0 +1,113 @@
1
+ import { useEffect, useState, type ReactNode } from "react";
2
+ import { useGetAgencyProfile, useGetUserProfile } from "@zauru-sdk/hooks";
3
+ import { getInitialProfileInfo } from "@zauru-sdk/utils";
4
+ import { LabelArray } from "../Titles/LabelArray.js";
5
+ import { ZauruTable } from "../Table/ZauruTable.js";
6
+ import { Container } from "../Containers/Container.js";
7
+ import { DoubleContainer } from "../Containers/DoubleContainer.js";
8
+ import { MainContainer } from "../Containers/MainContainer.js";
9
+ import { SubContainer } from "../Containers/SubContainer.js";
10
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
11
+ import { LoadingWindow } from "../Skeletons/LoadingWindow.js";
12
+
13
+ export type ZauruHomePageProps = {
14
+ title: string;
15
+ includeAgency?: boolean;
16
+ extra?: ReactNode;
17
+ };
18
+
19
+ export function ZauruHomePage({
20
+ title,
21
+ includeAgency = true,
22
+ extra,
23
+ }: ZauruHomePageProps) {
24
+ try {
25
+ const [isClient, setIsClient] = useState(false);
26
+ const { data: userProfile } = useGetUserProfile();
27
+ const { data: agencyProfile, loading: loadingAgencyProfile } =
28
+ useGetAgencyProfile();
29
+
30
+ useEffect(() => {
31
+ setIsClient(true);
32
+ }, []);
33
+
34
+ const { profileLabelInfo, membershipsInfo } =
35
+ getInitialProfileInfo(userProfile);
36
+
37
+ const conditionalRowStyles = [
38
+ {
39
+ when: (row: { odd: any; entityId: any }) => row.odd,
40
+ style: {
41
+ backgroundColor: "white",
42
+ "&:hover": {
43
+ cursor: "pointer",
44
+ },
45
+ },
46
+ },
47
+ {
48
+ when: (row: { entityId: any }) =>
49
+ row.entityId === userProfile?.profile?.selected_entity_id,
50
+ style: () => ({ backgroundColor: "lightgreen" }),
51
+ },
52
+ ];
53
+
54
+ const columns: any = [
55
+ {
56
+ name: "Entidad",
57
+ selector: (row: any) => row.entity,
58
+ },
59
+ {
60
+ name: "Contrato Expira",
61
+ selector: (row: any) => row.contractExpiration,
62
+ width: "10rem",
63
+ },
64
+ {
65
+ name: "Pagado hasta",
66
+ selector: (row: any) => row.nextPay,
67
+ width: "10rem",
68
+ },
69
+ ];
70
+
71
+ if (!isClient) {
72
+ return <LoadingWindow description="Cargando home..." />;
73
+ }
74
+
75
+ const pageTitle = includeAgency
76
+ ? loadingAgencyProfile || !agencyProfile
77
+ ? "Cargando..."
78
+ : `${title} (${agencyProfile?.name ?? "Usuario sin agencia asignada"})`
79
+ : title;
80
+
81
+ const profileAndMemberships = (
82
+ <>
83
+ <SubContainer title="Perfil">
84
+ <LabelArray info={profileLabelInfo} />
85
+ </SubContainer>
86
+ <SubContainer title="Suscripciones">
87
+ <ZauruTable
88
+ columns={columns}
89
+ conditionalRowStyles={conditionalRowStyles}
90
+ data={membershipsInfo}
91
+ />
92
+ </SubContainer>
93
+ </>
94
+ );
95
+
96
+ return (
97
+ <MainContainer>
98
+ {extra ? (
99
+ <DoubleContainer title={pageTitle}>
100
+ {profileAndMemberships}
101
+ {extra}
102
+ </DoubleContainer>
103
+ ) : (
104
+ <Container title={pageTitle}>{profileAndMemberships}</Container>
105
+ )}
106
+ </MainContainer>
107
+ );
108
+ } catch (error: any) {
109
+ return (
110
+ <ErrorLayout from="/home/index.tsx" error={error} isRootLevel={false} />
111
+ );
112
+ }
113
+ }
@@ -0,0 +1,21 @@
1
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
2
+ import { HomeLayout } from "../Layouts/homeLayout/index.js";
3
+ import type { ZauruHomeLayoutColor } from "./ZauruLoginPage.js";
4
+
5
+ export type ZauruIndexPageProps = {
6
+ title: string;
7
+ description?: string;
8
+ color?: ZauruHomeLayoutColor;
9
+ };
10
+
11
+ export function ZauruIndexPage({
12
+ title,
13
+ description = "Inicie sesión para poder continuar.",
14
+ color,
15
+ }: ZauruIndexPageProps) {
16
+ try {
17
+ return <HomeLayout title={title} description={description} color={color} />;
18
+ } catch (error: any) {
19
+ return <ErrorLayout from="/index.tsx" error={error} isRootLevel={false} />;
20
+ }
21
+ }
@@ -0,0 +1,100 @@
1
+ import { useFetcher } from "@remix-run/react";
2
+ import { useEffect, useState } from "react";
3
+ import { useValidateNotifications } from "@zauru-sdk/hooks";
4
+ import {
5
+ cleanLocalStorage,
6
+ profileFetchSuccess,
7
+ useAppDispatch,
8
+ } from "@zauru-sdk/redux";
9
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
10
+ import { HomeLayout } from "../Layouts/homeLayout/index.js";
11
+ import { LoadingWindow } from "../Skeletons/LoadingWindow.js";
12
+
13
+ export type ZauruHomeLayoutColor = "green" | "blue" | "red" | "purple" | "yellow";
14
+
15
+ export type ZauruLoginPageProps = {
16
+ cleanLocalStorageArgs?: Parameters<typeof cleanLocalStorage>[0];
17
+ color?: ZauruHomeLayoutColor;
18
+ };
19
+
20
+ export function ZauruLoginPage({
21
+ cleanLocalStorageArgs,
22
+ color,
23
+ }: ZauruLoginPageProps) {
24
+ try {
25
+ const fetcher = useFetcher<any>();
26
+ const dispatch = useAppDispatch();
27
+ const [isClient, setIsClient] = useState(false);
28
+
29
+ useValidateNotifications({ fetcher });
30
+
31
+ useEffect(() => {
32
+ if (fetcher.data?.employeeProfile) {
33
+ dispatch(
34
+ profileFetchSuccess({
35
+ name: "agencyProfile",
36
+ data: fetcher.data.agencyProfile,
37
+ }),
38
+ );
39
+ dispatch(
40
+ profileFetchSuccess({
41
+ name: "employeeProfile",
42
+ data: fetcher.data.employeeProfile,
43
+ }),
44
+ );
45
+ dispatch(
46
+ profileFetchSuccess({
47
+ name: "userProfile",
48
+ data: fetcher.data.userProfile,
49
+ }),
50
+ );
51
+ dispatch(
52
+ profileFetchSuccess({
53
+ name: "oauthProfile",
54
+ data: fetcher.data.oauthProfile,
55
+ }),
56
+ );
57
+
58
+ fetcher.submit(
59
+ {
60
+ action: "redirect",
61
+ cookie: fetcher.data?.cookie,
62
+ },
63
+ { method: "post" },
64
+ );
65
+ }
66
+ }, [fetcher.data]);
67
+
68
+ useEffect(() => {
69
+ setIsClient(true);
70
+ }, []);
71
+
72
+ useEffect(() => {
73
+ cleanLocalStorage(cleanLocalStorageArgs);
74
+ fetcher.submit({ action: "login" }, { method: "post" });
75
+ }, []);
76
+
77
+ if (!isClient) {
78
+ return <LoadingWindow />;
79
+ }
80
+
81
+ return (
82
+ <HomeLayout
83
+ loading
84
+ color={color}
85
+ title={
86
+ fetcher.data?.title ? "Error al inciar sesión!" : "Iniciando sesión...."
87
+ }
88
+ description={
89
+ fetcher.data?.description ??
90
+ "Cargando (Perfil zauru, perfil oauth, agencia, membresías, webapptables)..."
91
+ }
92
+ />
93
+ );
94
+ } catch (error: any) {
95
+ console.log(error);
96
+ return (
97
+ <ErrorLayout from="/login/index.tsx" error={error} isRootLevel={false} />
98
+ );
99
+ }
100
+ }
@@ -0,0 +1,52 @@
1
+ import { useFetcher, useNavigate } from "@remix-run/react";
2
+ import { useEffect } from "react";
3
+ import { showAlert, useIsOnline } from "@zauru-sdk/hooks";
4
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
5
+ import { HomeLayout } from "../Layouts/homeLayout/index.js";
6
+ import type { ZauruHomeLayoutColor } from "./ZauruLoginPage.js";
7
+
8
+ export type ZauruLogoutPageProps = {
9
+ requireOnline?: boolean;
10
+ beforeLogout?: () => boolean | void;
11
+ color?: ZauruHomeLayoutColor;
12
+ };
13
+
14
+ export function ZauruLogoutPage({
15
+ requireOnline = true,
16
+ beforeLogout,
17
+ color,
18
+ }: ZauruLogoutPageProps) {
19
+ try {
20
+ const fetcher = useFetcher();
21
+ const navigate = useNavigate();
22
+ const isOnline = useIsOnline();
23
+
24
+ useEffect(() => {
25
+ if (beforeLogout?.() === false) {
26
+ return;
27
+ }
28
+ if (requireOnline && !isOnline) {
29
+ showAlert({
30
+ title: "No es posible cerrar sesión",
31
+ description: "No hay conexión a internet",
32
+ type: "error",
33
+ });
34
+ navigate("/home");
35
+ return;
36
+ }
37
+ fetcher.submit({ action: "logout" }, { method: "post" });
38
+ }, []);
39
+
40
+ return (
41
+ <HomeLayout
42
+ color={color}
43
+ title="Cerrando sesión"
44
+ description="Espere mientras se cierra su sesión..."
45
+ />
46
+ );
47
+ } catch (error: any) {
48
+ return (
49
+ <ErrorLayout from="/logout/index.tsx" error={error} isRootLevel={false} />
50
+ );
51
+ }
52
+ }
@@ -0,0 +1,45 @@
1
+ import { useEffect, useState } from "react";
2
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
3
+ import { LoadingWindow } from "../Skeletons/LoadingWindow.js";
4
+
5
+ export type ZauruReloadCatalogItem = {
6
+ name: string;
7
+ loading: boolean;
8
+ };
9
+
10
+ export type ZauruReloadCatalogsPageProps = {
11
+ items: ZauruReloadCatalogItem[];
12
+ };
13
+
14
+ export function ZauruReloadCatalogsPage({
15
+ items,
16
+ }: ZauruReloadCatalogsPageProps) {
17
+ try {
18
+ const [isClient, setIsClient] = useState(false);
19
+
20
+ useEffect(() => {
21
+ setIsClient(true);
22
+ }, []);
23
+
24
+ if (!isClient) {
25
+ return <LoadingWindow />;
26
+ }
27
+
28
+ const loading = items.some((item) => item.loading);
29
+
30
+ return (
31
+ <LoadingWindow
32
+ description={
33
+ loading
34
+ ? "Cargando catálogos..."
35
+ : "Catálogos cargados correctamente ✅"
36
+ }
37
+ loadingItems={items}
38
+ />
39
+ );
40
+ } catch (error: any) {
41
+ return (
42
+ <ErrorLayout from="/reload-catalogs" error={error} isRootLevel={false} />
43
+ );
44
+ }
45
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./zauruRouteErrorBoundary.js";
2
+ export * from "./ZauruLoginPage.js";
3
+ export * from "./ZauruLogoutPage.js";
4
+ export * from "./ZauruHomePage.js";
5
+ export * from "./ZauruIndexPage.js";
6
+ export * from "./ZauruReloadCatalogsPage.js";
@@ -0,0 +1,9 @@
1
+ import { ErrorLayout } from "../Layouts/errorLayout/index.js";
2
+
3
+ export function zauruRouteErrorBoundary(from: string) {
4
+ function ZauruRouteErrorBoundary() {
5
+ return <ErrorLayout from={from} />;
6
+ }
7
+ ZauruRouteErrorBoundary.displayName = `ZauruRouteErrorBoundary(${from})`;
8
+ return ZauruRouteErrorBoundary;
9
+ }
package/src/index.ts CHANGED
@@ -24,4 +24,5 @@ export * from "./WithTooltip/index.js";
24
24
  export * from "./Wizards/index.js";
25
25
  export * from "./Zendesk/index.js";
26
26
  export * from "./HOC/ValidateEmployeeAccess/index.js";
27
+ export * from "./Routes/index.js";
27
28
  export * from "./SidePanel/index.js";