@chimera-pe/react-saas 0.0.2 → 0.0.4
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/react-saas.js +528 -0
- package/dist/react-saas.umd.cjs +1 -0
- package/package.json +25 -21
- package/dist/react-saas.es.js +0 -29053
- package/dist/react-saas.umd.js +0 -336
- package/src/Constantes.js +0 -2
- package/src/api/inicializarApi.jsx +0 -9
- package/src/api/loginApi.jsx +0 -30
- package/src/components/Cargando.jsx +0 -15
- package/src/components/Error.jsx +0 -31
- package/src/components/Idioma.jsx +0 -48
- package/src/components/Inicializar.jsx +0 -64
- package/src/components/Login.jsx +0 -202
- package/src/components/MainRouter.jsx +0 -35
- package/src/components/Notificacion.jsx +0 -36
- package/src/components/SaasApp.jsx +0 -30
- package/src/components/Tema.jsx +0 -59
- package/src/components/index.jsx +0 -9
- package/src/hooks/index.jsx +0 -7
- package/src/hooks/useCheckLogin.jsx +0 -24
- package/src/hooks/useNotificar.jsx +0 -12
- package/src/i18n/es.jsx +0 -22
- package/src/i18n/index.jsx +0 -7
- package/src/index.js +0 -12
- package/src/redux/index.jsx +0 -17
- package/src/redux/inicializarSlice.jsx +0 -57
- package/src/redux/loginSlice.jsx +0 -94
- package/src/redux/notificacionSlice.jsx +0 -20
- package/src/redux/store.jsx +0 -15
- package/src/redux/uiSlice.jsx +0 -24
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {createSlice,createAsyncThunk} from "@reduxjs/toolkit";
|
|
2
|
-
import {identidadApi} from "../api/inicializarApi";
|
|
3
|
-
|
|
4
|
-
const colorDefault = {
|
|
5
|
-
primary: "#1C6CCC",
|
|
6
|
-
secondary: "#17A7FF",
|
|
7
|
-
error: "#f44336",
|
|
8
|
-
warning: "#ff9800",
|
|
9
|
-
info: "#2196f3",
|
|
10
|
-
success: "#4caf50"
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const inicializarSlice = createSlice({
|
|
14
|
-
name: "inicializar",
|
|
15
|
-
initialState: {
|
|
16
|
-
inicializando: true,
|
|
17
|
-
inicializado: false,
|
|
18
|
-
instancia: {
|
|
19
|
-
color: colorDefault
|
|
20
|
-
},
|
|
21
|
-
error: null
|
|
22
|
-
},
|
|
23
|
-
extraReducers(builder) {
|
|
24
|
-
builder
|
|
25
|
-
.addCase(inicializar.pending,state => {
|
|
26
|
-
state.inicializando = true;
|
|
27
|
-
})
|
|
28
|
-
.addCase(inicializar.fulfilled,(state,action) => {
|
|
29
|
-
state.inicializando = false;
|
|
30
|
-
state.inicializado = true;
|
|
31
|
-
state.instancia = {
|
|
32
|
-
...action.payload,
|
|
33
|
-
abreviatura: action.payload.nombre.match(/\b([A-Z])/g).join(""),
|
|
34
|
-
color: {
|
|
35
|
-
...colorDefault,
|
|
36
|
-
...action.payload.color
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
state.error = null;
|
|
40
|
-
})
|
|
41
|
-
.addCase(inicializar.rejected,(state,action) => {
|
|
42
|
-
state.inicializando = false;
|
|
43
|
-
state.inicializado = false;
|
|
44
|
-
state.instancia = {
|
|
45
|
-
color: colorDefault
|
|
46
|
-
};
|
|
47
|
-
state.error = action.payload;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
export const inicializar = createAsyncThunk("inicializar",async (payload) => {
|
|
53
|
-
const response = await identidadApi(payload.devURL,payload.aplicacion);
|
|
54
|
-
return response.data;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export default inicializarSlice.reducer;
|
package/src/redux/loginSlice.jsx
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {createSlice,createAsyncThunk} from "@reduxjs/toolkit";
|
|
2
|
-
import {loginApi} from "../api/loginApi";
|
|
3
|
-
import jwtDecode from "jwt-decode";
|
|
4
|
-
|
|
5
|
-
const loginSlice = createSlice({
|
|
6
|
-
name: "login",
|
|
7
|
-
initialState: {
|
|
8
|
-
cargando: false,
|
|
9
|
-
autenticado: false,
|
|
10
|
-
token: null,
|
|
11
|
-
refreshToken: null,
|
|
12
|
-
expiracion: null,
|
|
13
|
-
usuario: null,
|
|
14
|
-
perfiles: [],
|
|
15
|
-
error: null
|
|
16
|
-
},
|
|
17
|
-
reducers: {
|
|
18
|
-
logout: state => {
|
|
19
|
-
state.cargando = false;
|
|
20
|
-
state.autenticado = false;
|
|
21
|
-
state.token = null;
|
|
22
|
-
state.refreshToken = null;
|
|
23
|
-
state.expiracion = null;
|
|
24
|
-
state.usuario = null;
|
|
25
|
-
state.perfiles = [];
|
|
26
|
-
state.error = null;
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
extraReducers(builder) {
|
|
30
|
-
builder
|
|
31
|
-
.addCase(requestToken.pending,state => {
|
|
32
|
-
state.cargando = true;
|
|
33
|
-
state.error = null;
|
|
34
|
-
})
|
|
35
|
-
.addCase(requestToken.fulfilled,(state,action) => {
|
|
36
|
-
const token = action.payload.access_token;
|
|
37
|
-
const jwtToken = jwtDecode(token);
|
|
38
|
-
const expiracion = new Date();
|
|
39
|
-
expiracion.setSeconds(expiracion.getSeconds() + action.payload.expires_in);
|
|
40
|
-
state.cargando = false;
|
|
41
|
-
state.autenticado = true;
|
|
42
|
-
state.token = token;
|
|
43
|
-
state.refreshToken = action.payload.refresh_token;
|
|
44
|
-
state.expiracion = expiracion.getTime();
|
|
45
|
-
state.usuario = jwtToken.name;
|
|
46
|
-
state.perfiles = jwtToken.authorities;
|
|
47
|
-
})
|
|
48
|
-
.addCase(requestToken.rejected,(state,action) => {
|
|
49
|
-
console.log(action);
|
|
50
|
-
state.cargando = false;
|
|
51
|
-
state.autenticado = false;
|
|
52
|
-
state.token = null;
|
|
53
|
-
state.refreshToken = null;
|
|
54
|
-
state.expiracion = null;
|
|
55
|
-
state.usuario = null;
|
|
56
|
-
state.perfiles = [];
|
|
57
|
-
state.error = action.error?.message;
|
|
58
|
-
})
|
|
59
|
-
.addCase(refreshToken.pending,state => {
|
|
60
|
-
state.cargando = true;
|
|
61
|
-
})
|
|
62
|
-
.addCase(refreshToken.fulfilled,(state,action) => {
|
|
63
|
-
const expiracion = new Date();
|
|
64
|
-
expiracion.setSeconds(expiracion.getSeconds() + action.payload.expires_in);
|
|
65
|
-
state.token = action.payload.access_token;
|
|
66
|
-
state.refreshToken = action.payload.refresh_token;
|
|
67
|
-
state.expiracion = expiracion.getTime();
|
|
68
|
-
})
|
|
69
|
-
.addCase(refreshToken.rejected,(state,action) => {
|
|
70
|
-
state.cargando = false;
|
|
71
|
-
state.autenticado = false;
|
|
72
|
-
state.token = null;
|
|
73
|
-
state.refreshToken = null;
|
|
74
|
-
state.expiracion = null;
|
|
75
|
-
state.usuario = null;
|
|
76
|
-
state.perfiles = [];
|
|
77
|
-
state.error = action.error?.message;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export const requestToken = createAsyncThunk("login/requestToken",async (payload) => {
|
|
83
|
-
const response = await loginApi(payload.devURL).login(payload.clientCredentials,payload.data);
|
|
84
|
-
return response.data;
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export const refreshToken = createAsyncThunk("login/refreshToken",async (devURL,clientCredentials,refreshToken) => {
|
|
88
|
-
const response = await loginApi(devURL).refreshToken(clientCredentials,refreshToken);
|
|
89
|
-
return response.data;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export const {logout} = loginSlice.actions;
|
|
93
|
-
|
|
94
|
-
export default loginSlice.reducer;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {createSlice} from "@reduxjs/toolkit";
|
|
2
|
-
|
|
3
|
-
const notificacionSlice=createSlice({
|
|
4
|
-
name: "notificacion",
|
|
5
|
-
initialState: [],
|
|
6
|
-
reducers: {
|
|
7
|
-
mostrarNotificacion: (state,action) => {
|
|
8
|
-
state.push(action.payload);
|
|
9
|
-
},
|
|
10
|
-
ocultarNotificacion: state => {
|
|
11
|
-
state.pop();
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const getNotificacion=store => Array.isArray(store.notificacion) && store.notificacion.length ? store.notificacion[0] : null;
|
|
17
|
-
|
|
18
|
-
export const {mostrarNotificacion,ocultarNotificacion}=notificacionSlice.actions;
|
|
19
|
-
|
|
20
|
-
export default notificacionSlice.reducer;
|
package/src/redux/store.jsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {configureStore} from "@reduxjs/toolkit";
|
|
2
|
-
import uiSlice from "./uiSlice";
|
|
3
|
-
import loginSlice from "./loginSlice";
|
|
4
|
-
import notificacionSlice from "./notificacionSlice";
|
|
5
|
-
import inicializarSlice from "./inicializarSlice";
|
|
6
|
-
|
|
7
|
-
export const store=(customReducers) => configureStore({
|
|
8
|
-
reducer: {
|
|
9
|
-
ui: uiSlice,
|
|
10
|
-
aplicacion: inicializarSlice,
|
|
11
|
-
login: loginSlice,
|
|
12
|
-
notificaciones: notificacionSlice,
|
|
13
|
-
...customReducers
|
|
14
|
-
}
|
|
15
|
-
});
|
package/src/redux/uiSlice.jsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {createSlice} from "@reduxjs/toolkit";
|
|
2
|
-
|
|
3
|
-
const uiSlice=createSlice({
|
|
4
|
-
name: "ui",
|
|
5
|
-
initialState: {
|
|
6
|
-
tema: "light",
|
|
7
|
-
temaSeleccionado: false,
|
|
8
|
-
idioma: "es",
|
|
9
|
-
},
|
|
10
|
-
reducers: {
|
|
11
|
-
cambiarTema: (state,action) => {
|
|
12
|
-
state.tema=action.payload;
|
|
13
|
-
state.temaSeleccionado=true;
|
|
14
|
-
localStorage.setItem("tema",action.payload);
|
|
15
|
-
},
|
|
16
|
-
cambiarIdioma: (state,action) => {
|
|
17
|
-
state.idioma=action.payload;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export const {cambiarTema,cambiarIdioma}=uiSlice.actions;
|
|
23
|
-
|
|
24
|
-
export default uiSlice.reducer;
|