@monorise/react 1.0.1 → 1.0.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/dist/actions/config.action.d.ts +10 -0
- package/dist/actions/config.action.d.ts.map +1 -0
- package/dist/actions/config.action.js +31 -0
- package/dist/actions/config.action.js.map +1 -0
- package/dist/actions/core.action.d.ts.map +1 -1
- package/dist/actions/core.action.js +2 -3
- package/dist/actions/core.action.js.map +1 -1
- package/dist/index.d.ts +388 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/index.jsx +48 -0
- package/dist/index.jsx.map +1 -0
- package/dist/services/core.service.d.ts +2 -1
- package/dist/services/core.service.d.ts.map +1 -1
- package/dist/services/core.service.js +9 -10
- package/dist/services/core.service.js.map +1 -1
- package/dist/store/monorise.store.d.ts +9 -3
- package/dist/store/monorise.store.d.ts.map +1 -1
- package/dist/store/monorise.store.js +3 -11
- package/dist/store/monorise.store.js.map +1 -1
- package/index.ts +18 -4
- package/package.json +6 -4
- package/actions/app.action.ts +0 -218
- package/actions/auth.action.ts +0 -71
- package/actions/core.action.ts +0 -878
- package/lib/api.tsx +0 -132
- package/lib/config.ts +0 -36
- package/lib/constant.ts +0 -1
- package/lib/entity.ts +0 -81
- package/lib/utils.ts +0 -12
- package/services/auth.service.ts +0 -59
- package/services/core.service.ts +0 -416
- package/services/filestore.service.ts +0 -136
- package/store/monorise.store.ts +0 -111
- package/types/api.type.ts +0 -57
- package/types/axios.type.ts +0 -14
- package/types/monorise.type.ts +0 -8
package/actions/auth.action.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { Entity } from '@monorise/base';
|
|
2
|
-
import { produce } from 'immer';
|
|
3
|
-
import type { AuthService } from '../services/auth.service';
|
|
4
|
-
import type { MonoriseStore } from '../store/monorise.store';
|
|
5
|
-
|
|
6
|
-
const initAuthActions = (store: MonoriseStore, authService: AuthService) => {
|
|
7
|
-
const requestLogin = async (
|
|
8
|
-
entityType: Entity,
|
|
9
|
-
payload: { email: string },
|
|
10
|
-
) => {
|
|
11
|
-
const { data } = await authService.requestLoginMagicLink(
|
|
12
|
-
entityType,
|
|
13
|
-
payload,
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
return data;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const useProfile = <T extends Record<string, unknown>>(): T & {
|
|
20
|
-
displayName: string;
|
|
21
|
-
email: string;
|
|
22
|
-
accountId: string;
|
|
23
|
-
impersonatorId?: string;
|
|
24
|
-
} => {
|
|
25
|
-
const profile = store((state) => state.auth.profile);
|
|
26
|
-
|
|
27
|
-
return profile as T & typeof profile;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const getProfile = async () => {
|
|
31
|
-
const {
|
|
32
|
-
data: { displayName, email, accountId, ...rest },
|
|
33
|
-
} = await authService.getSessionProfile();
|
|
34
|
-
|
|
35
|
-
store.setState(
|
|
36
|
-
produce((state) => {
|
|
37
|
-
state.auth.profile = {
|
|
38
|
-
displayName,
|
|
39
|
-
email,
|
|
40
|
-
accountId,
|
|
41
|
-
...rest,
|
|
42
|
-
};
|
|
43
|
-
}),
|
|
44
|
-
undefined,
|
|
45
|
-
'mr/auth/get-profile',
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const useIsUnauthorized = () => {
|
|
50
|
-
return store((state) => state.auth.isUnauthorized);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const setIsUnauthorized = (isUnauthorized: boolean) =>
|
|
54
|
-
store.setState(
|
|
55
|
-
produce((state) => {
|
|
56
|
-
state.auth.isUnauthorized = isUnauthorized;
|
|
57
|
-
}),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
requestLogin,
|
|
62
|
-
useProfile,
|
|
63
|
-
getProfile,
|
|
64
|
-
useIsUnauthorized,
|
|
65
|
-
setIsUnauthorized,
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export { initAuthActions };
|
|
70
|
-
|
|
71
|
-
export type AuthActions = ReturnType<typeof initAuthActions>;
|