@arthur2079/internal-profile 0.10.1-next.9 → 4.1.2-next.3
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/package.json +3 -3
- package/dist/api/errors.d.ts +0 -3
- package/dist/api/errors.js +0 -9
- package/dist/api/mod.d.ts +0 -4
- package/dist/api/mod.js +0 -2
- package/dist/api/request.d.ts +0 -19
- package/dist/api/request.js +0 -96
- package/dist/api/types.d.ts +0 -193
- package/dist/api/types.js +0 -1
- package/dist/components/ConnectWalletModal/ConnectWalletFooter.d.ts +0 -5
- package/dist/components/ConnectWalletModal/ConnectWalletFooter.js +0 -9
- package/dist/components/ConnectWalletModal/ConnectWalletModal.constants.d.ts +0 -5
- package/dist/components/ConnectWalletModal/ConnectWalletModal.constants.js +0 -8
- package/dist/components/ConnectWalletModal/ConnectWalletModal.d.ts +0 -3
- package/dist/components/ConnectWalletModal/ConnectWalletModal.helpers.d.ts +0 -2
- package/dist/components/ConnectWalletModal/ConnectWalletModal.helpers.js +0 -9
- package/dist/components/ConnectWalletModal/ConnectWalletModal.js +0 -194
- package/dist/components/ConnectWalletModal/ConnectWalletModal.styles.d.ts +0 -19
- package/dist/components/ConnectWalletModal/ConnectWalletModal.styles.js +0 -101
- package/dist/components/ConnectWalletModal/ConnectWalletModal.types.d.ts +0 -44
- package/dist/components/ConnectWalletModal/ConnectWalletModal.types.js +0 -1
- package/dist/components/ConnectWalletModal/EmptyWalletList.d.ts +0 -2
- package/dist/components/ConnectWalletModal/EmptyWalletList.js +0 -9
- package/dist/components/ConnectWalletModal/StatefulConnectContainer.d.ts +0 -3
- package/dist/components/ConnectWalletModal/StatefulConnectContainer.js +0 -37
- package/dist/components/ConnectWalletModal/StatefulConnectContainer.styles.d.ts +0 -1
- package/dist/components/ConnectWalletModal/StatefulConnectContainer.styles.js +0 -51
- package/dist/components/ConnectWalletModal/StatefulConnectContainer.types.d.ts +0 -12
- package/dist/components/ConnectWalletModal/StatefulConnectContainer.types.js +0 -1
- package/dist/components/ConnectWalletModal/WalletsChainSelect.d.ts +0 -3
- package/dist/components/ConnectWalletModal/WalletsChainSelect.js +0 -87
- package/dist/components/ConnectWalletModal/WalletsChainSelect.styles.d.ts +0 -21
- package/dist/components/ConnectWalletModal/WalletsChainSelect.styles.js +0 -83
- package/dist/components/ConnectWalletModal/WalletsChainSelect.types.d.ts +0 -12
- package/dist/components/ConnectWalletModal/WalletsChainSelect.types.js +0 -1
- package/dist/components/ConnectWalletModal/index.d.ts +0 -3
- package/dist/components/ConnectWalletModal/index.js +0 -2
- package/dist/components/ProfileWallet/ProfileWallet.d.ts +0 -3
- package/dist/components/ProfileWallet/ProfileWallet.js +0 -54
- package/dist/components/ProfileWallet/ProfileWallet.styles.d.ts +0 -6
- package/dist/components/ProfileWallet/ProfileWallet.styles.js +0 -54
- package/dist/components/ProfileWallet/ProfileWallet.types.d.ts +0 -11
- package/dist/components/ProfileWallet/ProfileWallet.types.js +0 -1
- package/dist/components/ProfileWallet/index.d.ts +0 -1
- package/dist/components/ProfileWallet/index.js +0 -1
- package/dist/components/ProfileWallets/ConnectedWallets.d.ts +0 -2
- package/dist/components/ProfileWallets/ConnectedWallets.js +0 -25
- package/dist/components/ProfileWallets/ConnectedWallets.styles.d.ts +0 -4
- package/dist/components/ProfileWallets/ConnectedWallets.styles.js +0 -30
- package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.d.ts +0 -5
- package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.js +0 -9
- package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.styles.d.ts +0 -1
- package/dist/components/ProfileWallets/ConnectedWalletsEmptyState.styles.js +0 -8
- package/dist/components/ProfileWallets/ProfileWallets.d.ts +0 -4
- package/dist/components/ProfileWallets/ProfileWallets.js +0 -37
- package/dist/components/ProfileWallets/ProfileWallets.styles.d.ts +0 -5
- package/dist/components/ProfileWallets/ProfileWallets.styles.js +0 -17
- package/dist/components/ProfileWallets/ProfileWallets.types.d.ts +0 -14
- package/dist/components/ProfileWallets/ProfileWallets.types.js +0 -1
- package/dist/components/ProfileWallets/index.d.ts +0 -1
- package/dist/components/ProfileWallets/index.js +0 -1
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.constants.d.ts +0 -3
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.constants.js +0 -2
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.d.ts +0 -3
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.js +0 -23
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.styles.d.ts +0 -4
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.styles.js +0 -23
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.types.d.ts +0 -23
- package/dist/components/ProfileWalletsModal/ProfileWalletsModal.types.js +0 -1
- package/dist/components/ProfileWalletsModal/index.d.ts +0 -2
- package/dist/components/ProfileWalletsModal/index.js +0 -1
- package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.d.ts +0 -2
- package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.js +0 -21
- package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.styles.d.ts +0 -4
- package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.styles.js +0 -49
- package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.types.d.ts +0 -7
- package/dist/components/SocialWalletIntroModal/SocialWalletIntroModal.types.js +0 -1
- package/dist/components/SocialWalletIntroModal/index.d.ts +0 -1
- package/dist/components/SocialWalletIntroModal/index.js +0 -1
- package/dist/components/StackModal/ModalContainer.d.ts +0 -4
- package/dist/components/StackModal/ModalContainer.js +0 -33
- package/dist/components/StackModal/ModalContainer.types.d.ts +0 -6
- package/dist/components/StackModal/ModalContainer.types.js +0 -1
- package/dist/components/StackModal/StackModal.d.ts +0 -3
- package/dist/components/StackModal/StackModal.js +0 -90
- package/dist/components/StackModal/StackModal.styles.d.ts +0 -2
- package/dist/components/StackModal/StackModal.styles.js +0 -77
- package/dist/components/StackModal/StackModal.types.d.ts +0 -3
- package/dist/components/StackModal/StackModal.types.js +0 -1
- package/dist/components/StackModal/index.d.ts +0 -1
- package/dist/components/StackModal/index.js +0 -1
- package/dist/components/WalletItem/WalletItem.d.ts +0 -3
- package/dist/components/WalletItem/WalletItem.js +0 -60
- package/dist/components/WalletItem/WalletItem.styles.d.ts +0 -9
- package/dist/components/WalletItem/WalletItem.styles.js +0 -71
- package/dist/components/WalletItem/WalletItem.types.d.ts +0 -8
- package/dist/components/WalletItem/WalletItem.types.js +0 -1
- package/dist/components/WalletItem/index.d.ts +0 -1
- package/dist/components/WalletItem/index.js +0 -1
- package/dist/components/mod.d.ts +0 -5
- package/dist/components/mod.js +0 -3
- package/dist/constants/errors.d.ts +0 -1
- package/dist/constants/errors.js +0 -1
- package/dist/constants/events.d.ts +0 -3
- package/dist/constants/events.js +0 -3
- package/dist/constants/links.d.ts +0 -2
- package/dist/constants/links.js +0 -2
- package/dist/constants/mod.d.ts +0 -3
- package/dist/constants/mod.js +0 -3
- package/dist/constants/modals.d.ts +0 -3
- package/dist/constants/modals.js +0 -3
- package/dist/fetcher.d.ts +0 -3
- package/dist/fetcher.js +0 -10
- package/dist/hooks/mod.d.ts +0 -4
- package/dist/hooks/mod.js +0 -3
- package/dist/hooks/useLocalStorage/index.d.ts +0 -1
- package/dist/hooks/useLocalStorage/index.js +0 -1
- package/dist/hooks/useLocalStorage/useLocalStorage.d.ts +0 -1
- package/dist/hooks/useLocalStorage/useLocalStorage.js +0 -24
- package/dist/hooks/useProfile/index.d.ts +0 -1
- package/dist/hooks/useProfile/index.js +0 -1
- package/dist/hooks/useProfile/useProfile.constants.d.ts +0 -2
- package/dist/hooks/useProfile/useProfile.constants.js +0 -8
- package/dist/hooks/useProfile/useProfile.d.ts +0 -2
- package/dist/hooks/useProfile/useProfile.helpers.d.ts +0 -4
- package/dist/hooks/useProfile/useProfile.helpers.js +0 -3
- package/dist/hooks/useProfile/useProfile.js +0 -20
- package/dist/hooks/useProfile/useProfile.types.d.ts +0 -11
- package/dist/hooks/useProfile/useProfile.types.js +0 -1
- package/dist/hooks/useStackModal.d.ts +0 -38
- package/dist/hooks/useStackModal.js +0 -61
- package/dist/hooks/useStatefulConnect.d.ts +0 -7
- package/dist/hooks/useStatefulConnect.js +0 -15
- package/dist/mod.d.ts +0 -1
- package/dist/mod.js +0 -1
- package/dist/store/helpers.d.ts +0 -9
- package/dist/store/helpers.js +0 -69
- package/dist/store/middlewares.d.ts +0 -6
- package/dist/store/middlewares.js +0 -40
- package/dist/store/mod.d.ts +0 -4
- package/dist/store/mod.js +0 -3
- package/dist/store/selectors.d.ts +0 -47
- package/dist/store/selectors.js +0 -21
- package/dist/store/slice.d.ts +0 -134
- package/dist/store/slice.js +0 -230
- package/dist/store/thunks.d.ts +0 -153
- package/dist/store/thunks.js +0 -223
- package/dist/store/types.d.ts +0 -67
- package/dist/store/types.js +0 -1
- package/dist/store/utils.d.ts +0 -1
- package/dist/store/utils.js +0 -11
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -1
- package/dist/utils/mod.d.ts +0 -1
- package/dist/utils/mod.js +0 -1
- package/dist/utils/wallets.d.ts +0 -16
- package/dist/utils/wallets.js +0 -34
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { RootStateLike } from './slice';
|
|
2
|
-
export declare const showPrivateProfileSelector: ((state: RootStateLike, username?: string | undefined) => boolean) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState, args_1: string | undefined) => boolean, {
|
|
3
|
-
clearCache: () => void;
|
|
4
|
-
}> & {
|
|
5
|
-
clearCache: () => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const profileSummarySelector: ((state: RootStateLike, username?: string | undefined) => {
|
|
8
|
-
loading: boolean;
|
|
9
|
-
error: string | null;
|
|
10
|
-
data: import("../api/types").ProfileSummary | null;
|
|
11
|
-
}) & import("reselect").OutputSelectorFields<(args_0: boolean, args_1: import("./types").ProfileState) => {
|
|
12
|
-
loading: boolean;
|
|
13
|
-
error: string | null;
|
|
14
|
-
data: import("../api/types").ProfileSummary | null;
|
|
15
|
-
}, {
|
|
16
|
-
clearCache: () => void;
|
|
17
|
-
}> & {
|
|
18
|
-
clearCache: () => void;
|
|
19
|
-
};
|
|
20
|
-
export declare const privateProfileSummarySelector: ((state: RootStateLike) => {
|
|
21
|
-
loading: boolean;
|
|
22
|
-
error: string | null;
|
|
23
|
-
data: import("../api/types").ProfileSummary | null;
|
|
24
|
-
}) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => {
|
|
25
|
-
loading: boolean;
|
|
26
|
-
error: string | null;
|
|
27
|
-
data: import("../api/types").ProfileSummary | null;
|
|
28
|
-
}, {
|
|
29
|
-
clearCache: () => void;
|
|
30
|
-
}> & {
|
|
31
|
-
clearCache: () => void;
|
|
32
|
-
};
|
|
33
|
-
export declare const isLoggedInProfileSelector: ((state: RootStateLike) => boolean) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => boolean, {
|
|
34
|
-
clearCache: () => void;
|
|
35
|
-
}> & {
|
|
36
|
-
clearCache: () => void;
|
|
37
|
-
};
|
|
38
|
-
export declare const authenticatedProfileSelector: ((state: RootStateLike) => import("../api/types").ProfileAccount | null) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => import("../api/types").ProfileAccount | null, {
|
|
39
|
-
clearCache: () => void;
|
|
40
|
-
}> & {
|
|
41
|
-
clearCache: () => void;
|
|
42
|
-
};
|
|
43
|
-
export declare const usernameProfileSelector: ((state: RootStateLike) => string | null) & import("reselect").OutputSelectorFields<(args_0: import("./types").ProfileState) => string | null, {
|
|
44
|
-
clearCache: () => void;
|
|
45
|
-
}> & {
|
|
46
|
-
clearCache: () => void;
|
|
47
|
-
};
|
package/dist/store/selectors.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createSelector } from '@reduxjs/toolkit';
|
|
2
|
-
const profileSelector = (state) => state.profile;
|
|
3
|
-
const usernameSelector = (_, username) => username;
|
|
4
|
-
export const showPrivateProfileSelector = createSelector([profileSelector, usernameSelector], (profile, username) => {
|
|
5
|
-
return profile.isLoggedIn && profile.username === username;
|
|
6
|
-
});
|
|
7
|
-
export const profileSummarySelector = createSelector([showPrivateProfileSelector, profileSelector], (showPrivateProfile, profile) => {
|
|
8
|
-
return showPrivateProfile ? profile.profileSummary.private : profile.profileSummary.public;
|
|
9
|
-
});
|
|
10
|
-
export const privateProfileSummarySelector = createSelector([profileSelector], (profile) => {
|
|
11
|
-
return profile.profileSummary.private;
|
|
12
|
-
});
|
|
13
|
-
export const isLoggedInProfileSelector = createSelector([profileSelector], (profile) => {
|
|
14
|
-
return profile.isLoggedIn;
|
|
15
|
-
});
|
|
16
|
-
export const authenticatedProfileSelector = createSelector([profileSelector], (profile) => {
|
|
17
|
-
return profile.profileAuth.account;
|
|
18
|
-
});
|
|
19
|
-
export const usernameProfileSelector = createSelector([profileSelector], (profile) => {
|
|
20
|
-
return profile.username;
|
|
21
|
-
});
|
package/dist/store/slice.d.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import type { ProfileState } from './types';
|
|
2
|
-
import type { Slice } from '@reduxjs/toolkit';
|
|
3
|
-
import type { BlockchainMeta, SwapperMeta, Token as TokenMeta } from 'rango-types/mainApi';
|
|
4
|
-
export declare const profileSliceInitialState: ProfileState;
|
|
5
|
-
type ActionsFromSlice<T extends Slice> = ReturnType<T['actions'][keyof T['actions']]>;
|
|
6
|
-
export type ProfileSliceActions = ActionsFromSlice<ReturnType<typeof createProfileState>['slice']>;
|
|
7
|
-
export type MetaStateLike = {
|
|
8
|
-
loadingStatus: 'loading' | 'success' | 'failed';
|
|
9
|
-
tokens: TokenMeta[];
|
|
10
|
-
blockchains: BlockchainMeta[];
|
|
11
|
-
swappers: SwapperMeta[];
|
|
12
|
-
};
|
|
13
|
-
export type RootStateLike = {
|
|
14
|
-
profile: ProfileState;
|
|
15
|
-
meta: MetaStateLike;
|
|
16
|
-
};
|
|
17
|
-
export declare const createProfileState: <T extends RootStateLike>() => {
|
|
18
|
-
slice: Slice<ProfileState, {
|
|
19
|
-
logInUser: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
|
|
20
|
-
logOutUser: () => ProfileState;
|
|
21
|
-
clearAuthError: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
|
|
22
|
-
resetMergeStatus: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
|
|
23
|
-
resetUserData: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
|
|
24
|
-
resetUpdateUsernameError: (state: import("immer/dist/internal.js").WritableDraft<ProfileState>) => void;
|
|
25
|
-
}, "profile">;
|
|
26
|
-
thunks: {
|
|
27
|
-
signMessage: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileSummary | null, import("./types").SignMessageParams, {
|
|
28
|
-
state: RootStateLike;
|
|
29
|
-
rejectValue: string;
|
|
30
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
31
|
-
extra?: unknown;
|
|
32
|
-
serializedErrorType?: unknown;
|
|
33
|
-
pendingMeta?: unknown;
|
|
34
|
-
fulfilledMeta?: unknown;
|
|
35
|
-
rejectedMeta?: unknown;
|
|
36
|
-
}>;
|
|
37
|
-
fetchProfileSummary: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileSummary | null, {
|
|
38
|
-
username: string;
|
|
39
|
-
public: boolean;
|
|
40
|
-
}, {
|
|
41
|
-
state: RootStateLike;
|
|
42
|
-
rejectValue: string | null;
|
|
43
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
44
|
-
extra?: unknown;
|
|
45
|
-
serializedErrorType?: unknown;
|
|
46
|
-
pendingMeta?: unknown;
|
|
47
|
-
fulfilledMeta?: unknown;
|
|
48
|
-
rejectedMeta?: unknown;
|
|
49
|
-
}>;
|
|
50
|
-
fetchProfileDetails: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileDetails | null, undefined, {
|
|
51
|
-
state: T;
|
|
52
|
-
rejectValue: string | null;
|
|
53
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
54
|
-
extra?: unknown;
|
|
55
|
-
serializedErrorType?: unknown;
|
|
56
|
-
pendingMeta?: unknown;
|
|
57
|
-
fulfilledMeta?: unknown;
|
|
58
|
-
rejectedMeta?: unknown;
|
|
59
|
-
}>;
|
|
60
|
-
fetchProfileLeaderboard: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileLeaderboard[] | null, {
|
|
61
|
-
username: string;
|
|
62
|
-
public?: boolean;
|
|
63
|
-
}, {
|
|
64
|
-
state: T;
|
|
65
|
-
rejectValue: string | null;
|
|
66
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
67
|
-
extra?: unknown;
|
|
68
|
-
serializedErrorType?: unknown;
|
|
69
|
-
pendingMeta?: unknown;
|
|
70
|
-
fulfilledMeta?: unknown;
|
|
71
|
-
rejectedMeta?: unknown;
|
|
72
|
-
}>;
|
|
73
|
-
fetchPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<{
|
|
74
|
-
leaderboard: import("../api/types").ProfileLeaderboard[] | null;
|
|
75
|
-
totalPages: number | null;
|
|
76
|
-
}, import("../api/types").PublicLeaderboardRequest, {
|
|
77
|
-
state: T;
|
|
78
|
-
rejectValue: string;
|
|
79
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
80
|
-
extra?: unknown;
|
|
81
|
-
serializedErrorType?: unknown;
|
|
82
|
-
pendingMeta?: unknown;
|
|
83
|
-
fulfilledMeta?: unknown;
|
|
84
|
-
rejectedMeta?: unknown;
|
|
85
|
-
}>;
|
|
86
|
-
fetchTopPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileLeaderboard[] | null, {
|
|
87
|
-
type: import("../api/types").PublicLeaderboardType;
|
|
88
|
-
}, {
|
|
89
|
-
state: T;
|
|
90
|
-
rejectValue: string;
|
|
91
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
92
|
-
extra?: unknown;
|
|
93
|
-
serializedErrorType?: unknown;
|
|
94
|
-
pendingMeta?: unknown;
|
|
95
|
-
fulfilledMeta?: unknown;
|
|
96
|
-
rejectedMeta?: unknown;
|
|
97
|
-
}>;
|
|
98
|
-
updateUsername: import("@reduxjs/toolkit").AsyncThunk<{
|
|
99
|
-
username: string;
|
|
100
|
-
}, import("../api/request").UpdateProfileData & {
|
|
101
|
-
callback: () => void;
|
|
102
|
-
}, {
|
|
103
|
-
state: T;
|
|
104
|
-
rejectValue: string;
|
|
105
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
106
|
-
extra?: unknown;
|
|
107
|
-
serializedErrorType?: unknown;
|
|
108
|
-
pendingMeta?: unknown;
|
|
109
|
-
fulfilledMeta?: unknown;
|
|
110
|
-
rejectedMeta?: unknown;
|
|
111
|
-
}>;
|
|
112
|
-
requestLogOutUser: import("@reduxjs/toolkit").AsyncThunk<void, void, {
|
|
113
|
-
state: RootStateLike;
|
|
114
|
-
rejectValue: string;
|
|
115
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
116
|
-
extra?: unknown;
|
|
117
|
-
serializedErrorType?: unknown;
|
|
118
|
-
pendingMeta?: unknown;
|
|
119
|
-
fulfilledMeta?: unknown;
|
|
120
|
-
rejectedMeta?: unknown;
|
|
121
|
-
}>;
|
|
122
|
-
setClaim: import("@reduxjs/toolkit").AsyncThunk<import("../api/types").ProfileSummary | null, import("./types").SignMessageParams, {
|
|
123
|
-
state: RootStateLike;
|
|
124
|
-
rejectValue: string;
|
|
125
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
126
|
-
extra?: unknown;
|
|
127
|
-
serializedErrorType?: unknown;
|
|
128
|
-
pendingMeta?: unknown;
|
|
129
|
-
fulfilledMeta?: unknown;
|
|
130
|
-
rejectedMeta?: unknown;
|
|
131
|
-
}>;
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
export {};
|
package/dist/store/slice.js
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { getProfileType } from './helpers';
|
|
3
|
-
import { createProfileThunks } from './thunks';
|
|
4
|
-
export const profileSliceInitialState = {
|
|
5
|
-
isLoggedIn: false,
|
|
6
|
-
username: null,
|
|
7
|
-
profileAuth: {
|
|
8
|
-
loading: false,
|
|
9
|
-
error: null,
|
|
10
|
-
account: null,
|
|
11
|
-
numberOfRetries: 0,
|
|
12
|
-
accountMerged: false,
|
|
13
|
-
},
|
|
14
|
-
profileSummary: {
|
|
15
|
-
private: { loading: true, error: null, data: null },
|
|
16
|
-
public: { loading: true, error: null, data: null },
|
|
17
|
-
},
|
|
18
|
-
profileDetails: { loading: true, error: null, data: null },
|
|
19
|
-
profileLeaderboard: { loading: false, error: null, data: null },
|
|
20
|
-
publicLeaderboard: { loading: false, error: null, data: null, totalPages: null },
|
|
21
|
-
topPublicLeaderboard: { loading: false, error: null, data: null },
|
|
22
|
-
updateUsername: { loading: false, error: null },
|
|
23
|
-
logOut: {
|
|
24
|
-
loading: false,
|
|
25
|
-
error: null,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
export const createProfileState = () => {
|
|
29
|
-
const thunks = createProfileThunks();
|
|
30
|
-
const slice = createSlice({
|
|
31
|
-
name: 'profile',
|
|
32
|
-
initialState: profileSliceInitialState,
|
|
33
|
-
reducers: {
|
|
34
|
-
logInUser: (state) => {
|
|
35
|
-
state.isLoggedIn = true;
|
|
36
|
-
},
|
|
37
|
-
logOutUser: () => {
|
|
38
|
-
return profileSliceInitialState;
|
|
39
|
-
},
|
|
40
|
-
clearAuthError: (state) => {
|
|
41
|
-
state.profileAuth.error = null;
|
|
42
|
-
},
|
|
43
|
-
resetMergeStatus: (state) => {
|
|
44
|
-
state.profileAuth.accountMerged = false;
|
|
45
|
-
},
|
|
46
|
-
resetUserData: (state) => {
|
|
47
|
-
state.profileSummary.public = profileSliceInitialState.profileSummary.public;
|
|
48
|
-
},
|
|
49
|
-
resetUpdateUsernameError: (state) => {
|
|
50
|
-
state.updateUsername.error = null;
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
extraReducers: (builder) => {
|
|
54
|
-
builder
|
|
55
|
-
.addCase(thunks.setClaim.fulfilled, (state, action) => {
|
|
56
|
-
state.profileSummary.private.data = action.payload;
|
|
57
|
-
})
|
|
58
|
-
.addCase(thunks.signMessage.pending, (state, action) => {
|
|
59
|
-
state.profileAuth.loading = true;
|
|
60
|
-
state.profileAuth.error = null;
|
|
61
|
-
state.profileAuth.account = action.meta.arg.account;
|
|
62
|
-
state.profileAuth.numberOfRetries = 0;
|
|
63
|
-
})
|
|
64
|
-
.addCase(thunks.signMessage.rejected, (state, action) => {
|
|
65
|
-
state.profileAuth.loading = false;
|
|
66
|
-
state.profileAuth.account = null;
|
|
67
|
-
state.profileAuth.numberOfRetries = 0;
|
|
68
|
-
state.profileAuth.error = action.payload ?? null;
|
|
69
|
-
})
|
|
70
|
-
.addCase(thunks.signMessage.fulfilled, (state, action) => {
|
|
71
|
-
state.profileAuth.loading = false;
|
|
72
|
-
state.profileSummary.private.loading = false;
|
|
73
|
-
state.profileAuth.error = null;
|
|
74
|
-
state.profileAuth.account = null;
|
|
75
|
-
if (action.payload) {
|
|
76
|
-
if (state.isLoggedIn) {
|
|
77
|
-
state.profileAuth.accountMerged = true;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
state.isLoggedIn = true;
|
|
81
|
-
}
|
|
82
|
-
state.profileSummary.private.data = action.payload;
|
|
83
|
-
if (action.payload?.username) {
|
|
84
|
-
state.username = action.payload?.username;
|
|
85
|
-
}
|
|
86
|
-
state.profileAuth.numberOfRetries = 0;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
state.profileAuth.numberOfRetries += 1;
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
.addCase(thunks.fetchProfileSummary.pending, (state, action) => {
|
|
93
|
-
const { meta: { arg }, } = action;
|
|
94
|
-
const key = getProfileType(arg.public);
|
|
95
|
-
state.profileSummary[key].data = null;
|
|
96
|
-
state.profileSummary[key].loading = true;
|
|
97
|
-
state.profileSummary[key].error = null;
|
|
98
|
-
})
|
|
99
|
-
.addCase(thunks.fetchProfileSummary.fulfilled, (state, action) => {
|
|
100
|
-
const key = getProfileType(action.meta.arg.public);
|
|
101
|
-
state.profileSummary[key].loading = false;
|
|
102
|
-
state.profileSummary[key].error = null;
|
|
103
|
-
state.profileSummary[key].data = action.payload;
|
|
104
|
-
if (action.payload?.username && key === 'private') {
|
|
105
|
-
state.username = action.payload?.username;
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
.addCase(thunks.fetchProfileSummary.rejected, (state, action) => {
|
|
109
|
-
/**
|
|
110
|
-
* In DEV mode react strict will call the action twice.
|
|
111
|
-
* We added a check here to make sure if the first request has been cancelled,
|
|
112
|
-
* we don't update the state in between of these two requests.
|
|
113
|
-
*/
|
|
114
|
-
if (!action.payload || action.error.name === 'AbortError') {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const key = getProfileType(action.meta.arg.public);
|
|
118
|
-
state.profileSummary[key].loading = false;
|
|
119
|
-
state.profileSummary[key].error =
|
|
120
|
-
typeof action.payload === 'string' ? action.payload : null;
|
|
121
|
-
state.profileSummary[key].data = null;
|
|
122
|
-
})
|
|
123
|
-
.addCase(thunks.fetchProfileDetails.pending, (state) => {
|
|
124
|
-
state.profileDetails.data = null;
|
|
125
|
-
state.profileDetails.loading = true;
|
|
126
|
-
state.profileDetails.error = null;
|
|
127
|
-
})
|
|
128
|
-
.addCase(thunks.fetchProfileDetails.fulfilled, (state, action) => {
|
|
129
|
-
state.profileDetails.loading = false;
|
|
130
|
-
state.profileDetails.error = null;
|
|
131
|
-
state.profileDetails.data = action.payload;
|
|
132
|
-
})
|
|
133
|
-
.addCase(thunks.fetchProfileDetails.rejected, (state, action) => {
|
|
134
|
-
/**
|
|
135
|
-
* In DEV mode react strict will call the action twice.
|
|
136
|
-
* We added a check here to make sure if the first request has been cancelled,
|
|
137
|
-
* we don't update the state in between of these two requests.
|
|
138
|
-
*/
|
|
139
|
-
if (action.error.name === 'AbortError') {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
state.profileDetails.loading = false;
|
|
143
|
-
state.profileDetails.error = action.payload ?? null;
|
|
144
|
-
state.profileDetails.data = null;
|
|
145
|
-
})
|
|
146
|
-
.addCase(thunks.fetchProfileLeaderboard.pending, (state) => {
|
|
147
|
-
state.profileLeaderboard.data = null;
|
|
148
|
-
state.profileLeaderboard.loading = true;
|
|
149
|
-
state.profileLeaderboard.error = null;
|
|
150
|
-
})
|
|
151
|
-
.addCase(thunks.fetchProfileLeaderboard.fulfilled, (state, action) => {
|
|
152
|
-
state.profileLeaderboard.loading = false;
|
|
153
|
-
state.profileLeaderboard.error = null;
|
|
154
|
-
state.profileLeaderboard.data = action.payload;
|
|
155
|
-
})
|
|
156
|
-
.addCase(thunks.fetchProfileLeaderboard.rejected, (state, action) => {
|
|
157
|
-
if (!action.payload) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
state.profileLeaderboard.loading = false;
|
|
161
|
-
state.profileLeaderboard.error = action.payload ?? null;
|
|
162
|
-
})
|
|
163
|
-
.addCase(thunks.fetchPublicLeaderboard.pending, (state, action) => {
|
|
164
|
-
state.publicLeaderboard.loading = true;
|
|
165
|
-
state.publicLeaderboard.error = null;
|
|
166
|
-
if (action.meta.arg.page === 0) {
|
|
167
|
-
state.topPublicLeaderboard.loading = true;
|
|
168
|
-
state.topPublicLeaderboard.error = null;
|
|
169
|
-
}
|
|
170
|
-
})
|
|
171
|
-
.addCase(thunks.fetchPublicLeaderboard.fulfilled, (state, action) => {
|
|
172
|
-
state.publicLeaderboard.loading = false;
|
|
173
|
-
state.publicLeaderboard.error = null;
|
|
174
|
-
state.publicLeaderboard.data = action.payload.leaderboard;
|
|
175
|
-
state.publicLeaderboard.totalPages = action.payload.totalPages;
|
|
176
|
-
if (action.meta.arg.page === 0) {
|
|
177
|
-
state.topPublicLeaderboard.loading = false;
|
|
178
|
-
state.topPublicLeaderboard.error = null;
|
|
179
|
-
state.topPublicLeaderboard.data = action.payload.leaderboard;
|
|
180
|
-
}
|
|
181
|
-
})
|
|
182
|
-
.addCase(thunks.fetchPublicLeaderboard.rejected, (state, action) => {
|
|
183
|
-
state.publicLeaderboard.loading = false;
|
|
184
|
-
state.publicLeaderboard.error = action.payload ?? null;
|
|
185
|
-
if (action.meta.arg.page === 0) {
|
|
186
|
-
state.topPublicLeaderboard.loading = false;
|
|
187
|
-
state.topPublicLeaderboard.error = action.payload ?? null;
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
.addCase(thunks.fetchTopPublicLeaderboard.pending, (state) => {
|
|
191
|
-
state.topPublicLeaderboard.loading = true;
|
|
192
|
-
state.topPublicLeaderboard.error = null;
|
|
193
|
-
})
|
|
194
|
-
.addCase(thunks.fetchTopPublicLeaderboard.fulfilled, (state, action) => {
|
|
195
|
-
state.topPublicLeaderboard.loading = false;
|
|
196
|
-
state.topPublicLeaderboard.error = null;
|
|
197
|
-
state.topPublicLeaderboard.data = action.payload;
|
|
198
|
-
})
|
|
199
|
-
.addCase(thunks.fetchTopPublicLeaderboard.rejected, (state, action) => {
|
|
200
|
-
state.topPublicLeaderboard.loading = false;
|
|
201
|
-
state.topPublicLeaderboard.error = action.payload ?? null;
|
|
202
|
-
})
|
|
203
|
-
.addCase(thunks.updateUsername.pending, (state) => {
|
|
204
|
-
state.updateUsername.loading = true;
|
|
205
|
-
state.updateUsername.error = null;
|
|
206
|
-
})
|
|
207
|
-
.addCase(thunks.updateUsername.fulfilled, (state, action) => {
|
|
208
|
-
state.updateUsername.loading = false;
|
|
209
|
-
state.username = action.payload.username;
|
|
210
|
-
})
|
|
211
|
-
.addCase(thunks.updateUsername.rejected, (state, action) => {
|
|
212
|
-
state.updateUsername.loading = false;
|
|
213
|
-
state.updateUsername.error = action.payload ?? null;
|
|
214
|
-
})
|
|
215
|
-
.addCase(thunks.requestLogOutUser.pending, (state) => {
|
|
216
|
-
state.logOut.loading = true;
|
|
217
|
-
state.logOut.error = null;
|
|
218
|
-
})
|
|
219
|
-
.addCase(thunks.requestLogOutUser.fulfilled, () => profileSliceInitialState)
|
|
220
|
-
.addCase(thunks.requestLogOutUser.rejected, (state, action) => {
|
|
221
|
-
state.logOut.loading = false;
|
|
222
|
-
state.logOut.error = action.payload ?? null;
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
return {
|
|
227
|
-
slice,
|
|
228
|
-
thunks,
|
|
229
|
-
};
|
|
230
|
-
};
|
package/dist/store/thunks.d.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import type { RootStateLike } from './slice';
|
|
2
|
-
import type { SignMessageParams } from './types';
|
|
3
|
-
import type { ProfileDetails, ProfileLeaderboard, ProfileSummary, PublicLeaderboardRequest, PublicLeaderboardType, UpdateProfileData } from '../api/mod';
|
|
4
|
-
export declare function createSignMessage<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
|
|
5
|
-
state: T;
|
|
6
|
-
rejectValue: string;
|
|
7
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
8
|
-
extra?: unknown;
|
|
9
|
-
serializedErrorType?: unknown;
|
|
10
|
-
pendingMeta?: unknown;
|
|
11
|
-
fulfilledMeta?: unknown;
|
|
12
|
-
rejectedMeta?: unknown;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function createFetchProfileSummary<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, {
|
|
15
|
-
username: string;
|
|
16
|
-
public: boolean;
|
|
17
|
-
}, {
|
|
18
|
-
state: T;
|
|
19
|
-
rejectValue: string | null;
|
|
20
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
21
|
-
extra?: unknown;
|
|
22
|
-
serializedErrorType?: unknown;
|
|
23
|
-
pendingMeta?: unknown;
|
|
24
|
-
fulfilledMeta?: unknown;
|
|
25
|
-
rejectedMeta?: unknown;
|
|
26
|
-
}>;
|
|
27
|
-
export declare function createSetClaim<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
|
|
28
|
-
state: T;
|
|
29
|
-
rejectValue: string;
|
|
30
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
31
|
-
extra?: unknown;
|
|
32
|
-
serializedErrorType?: unknown;
|
|
33
|
-
pendingMeta?: unknown;
|
|
34
|
-
fulfilledMeta?: unknown;
|
|
35
|
-
rejectedMeta?: unknown;
|
|
36
|
-
}>;
|
|
37
|
-
export declare function createRequestLogOutUser<T extends RootStateLike>(): import("@reduxjs/toolkit").AsyncThunk<void, void, {
|
|
38
|
-
state: T;
|
|
39
|
-
rejectValue: string;
|
|
40
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
41
|
-
extra?: unknown;
|
|
42
|
-
serializedErrorType?: unknown;
|
|
43
|
-
pendingMeta?: unknown;
|
|
44
|
-
fulfilledMeta?: unknown;
|
|
45
|
-
rejectedMeta?: unknown;
|
|
46
|
-
}>;
|
|
47
|
-
export declare function createProfileThunks<T extends RootStateLike>(): {
|
|
48
|
-
signMessage: import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
|
|
49
|
-
state: RootStateLike;
|
|
50
|
-
rejectValue: string;
|
|
51
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
52
|
-
extra?: unknown;
|
|
53
|
-
serializedErrorType?: unknown;
|
|
54
|
-
pendingMeta?: unknown;
|
|
55
|
-
fulfilledMeta?: unknown;
|
|
56
|
-
rejectedMeta?: unknown;
|
|
57
|
-
}>;
|
|
58
|
-
fetchProfileSummary: import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, {
|
|
59
|
-
username: string;
|
|
60
|
-
public: boolean;
|
|
61
|
-
}, {
|
|
62
|
-
state: RootStateLike;
|
|
63
|
-
rejectValue: string | null;
|
|
64
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
65
|
-
extra?: unknown;
|
|
66
|
-
serializedErrorType?: unknown;
|
|
67
|
-
pendingMeta?: unknown;
|
|
68
|
-
fulfilledMeta?: unknown;
|
|
69
|
-
rejectedMeta?: unknown;
|
|
70
|
-
}>;
|
|
71
|
-
fetchProfileDetails: import("@reduxjs/toolkit").AsyncThunk<ProfileDetails | null, undefined, {
|
|
72
|
-
state: T;
|
|
73
|
-
rejectValue: string | null;
|
|
74
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
75
|
-
extra?: unknown;
|
|
76
|
-
serializedErrorType?: unknown;
|
|
77
|
-
pendingMeta?: unknown;
|
|
78
|
-
fulfilledMeta?: unknown;
|
|
79
|
-
rejectedMeta?: unknown;
|
|
80
|
-
}>;
|
|
81
|
-
fetchProfileLeaderboard: import("@reduxjs/toolkit").AsyncThunk<ProfileLeaderboard[] | null, {
|
|
82
|
-
username: string;
|
|
83
|
-
public?: boolean;
|
|
84
|
-
}, {
|
|
85
|
-
state: T;
|
|
86
|
-
rejectValue: string | null;
|
|
87
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
88
|
-
extra?: unknown;
|
|
89
|
-
serializedErrorType?: unknown;
|
|
90
|
-
pendingMeta?: unknown;
|
|
91
|
-
fulfilledMeta?: unknown;
|
|
92
|
-
rejectedMeta?: unknown;
|
|
93
|
-
}>;
|
|
94
|
-
fetchPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<{
|
|
95
|
-
leaderboard: ProfileLeaderboard[] | null;
|
|
96
|
-
totalPages: number | null;
|
|
97
|
-
}, PublicLeaderboardRequest, {
|
|
98
|
-
state: T;
|
|
99
|
-
rejectValue: string;
|
|
100
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
101
|
-
extra?: unknown;
|
|
102
|
-
serializedErrorType?: unknown;
|
|
103
|
-
pendingMeta?: unknown;
|
|
104
|
-
fulfilledMeta?: unknown;
|
|
105
|
-
rejectedMeta?: unknown;
|
|
106
|
-
}>;
|
|
107
|
-
fetchTopPublicLeaderboard: import("@reduxjs/toolkit").AsyncThunk<ProfileLeaderboard[] | null, {
|
|
108
|
-
type: PublicLeaderboardType;
|
|
109
|
-
}, {
|
|
110
|
-
state: T;
|
|
111
|
-
rejectValue: string;
|
|
112
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
113
|
-
extra?: unknown;
|
|
114
|
-
serializedErrorType?: unknown;
|
|
115
|
-
pendingMeta?: unknown;
|
|
116
|
-
fulfilledMeta?: unknown;
|
|
117
|
-
rejectedMeta?: unknown;
|
|
118
|
-
}>;
|
|
119
|
-
updateUsername: import("@reduxjs/toolkit").AsyncThunk<{
|
|
120
|
-
username: string;
|
|
121
|
-
}, UpdateProfileData & {
|
|
122
|
-
callback: () => void;
|
|
123
|
-
}, {
|
|
124
|
-
state: T;
|
|
125
|
-
rejectValue: string;
|
|
126
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
127
|
-
extra?: unknown;
|
|
128
|
-
serializedErrorType?: unknown;
|
|
129
|
-
pendingMeta?: unknown;
|
|
130
|
-
fulfilledMeta?: unknown;
|
|
131
|
-
rejectedMeta?: unknown;
|
|
132
|
-
}>;
|
|
133
|
-
requestLogOutUser: import("@reduxjs/toolkit").AsyncThunk<void, void, {
|
|
134
|
-
state: RootStateLike;
|
|
135
|
-
rejectValue: string;
|
|
136
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
137
|
-
extra?: unknown;
|
|
138
|
-
serializedErrorType?: unknown;
|
|
139
|
-
pendingMeta?: unknown;
|
|
140
|
-
fulfilledMeta?: unknown;
|
|
141
|
-
rejectedMeta?: unknown;
|
|
142
|
-
}>;
|
|
143
|
-
setClaim: import("@reduxjs/toolkit").AsyncThunk<ProfileSummary | null, SignMessageParams, {
|
|
144
|
-
state: RootStateLike;
|
|
145
|
-
rejectValue: string;
|
|
146
|
-
dispatch?: import("redux").Dispatch | undefined;
|
|
147
|
-
extra?: unknown;
|
|
148
|
-
serializedErrorType?: unknown;
|
|
149
|
-
pendingMeta?: unknown;
|
|
150
|
-
fulfilledMeta?: unknown;
|
|
151
|
-
rejectedMeta?: unknown;
|
|
152
|
-
}>;
|
|
153
|
-
};
|