@@ -6,41 +6,43 @@ import { PayoutDetailed } from "@/common/contracts/potlock/interfaces/pot.interf
6
6
import { getDonationsForProject } from "@/common/contracts/potlock/pot" ;
7
7
import {
8
8
NEARSocialUserProfile ,
9
- getUserProfile ,
9
+ getSocialProfile ,
10
10
} from "@/common/contracts/social" ;
11
11
import { yoctosToUsdWithFallback } from "@/common/lib" ;
12
12
13
- import { fetchProfileImages } from "../core/services/fetchProfileImages " ;
13
+ import { fetchSocialImages } from "../core/services/socialImages " ;
14
14
import {
15
15
getTagsFromSocialProfileData ,
16
16
getTeamMembersFromProfile ,
17
17
getTotalAmountNear ,
18
18
} from "../project/utils" ;
19
19
20
- export type UserState = {
21
- profile : NEARSocialUserProfile ;
20
+ export type Profile = {
21
+ socialData : NEARSocialUserProfile ;
22
22
tags : string [ ] ;
23
23
team : string [ ] ;
24
24
totalAmountNear : string ;
25
- profileImages : {
25
+
26
+ socialImages : {
26
27
image : string ;
27
28
backgroundImage : string ;
28
29
} ;
29
30
} ;
30
- type Users = Record < string , UserState > ;
31
31
32
- export const usersModel = createModel < RootModel > ( ) ( {
33
- state : { } as Users ,
32
+ type ProfileIndex = Record < string , Profile > ;
33
+
34
+ export const profilesModel = createModel < RootModel > ( ) ( {
35
+ state : { } as ProfileIndex ,
34
36
reducers : {
35
- update ( state , payload : Users ) {
37
+ update ( state , payload : ProfileIndex ) {
36
38
return {
37
39
...state ,
38
40
...payload ,
39
41
} ;
40
42
} ,
41
43
} ,
42
44
effects : {
43
- async loadUser ( {
45
+ async loadProfile ( {
44
46
projectId,
45
47
potId,
46
48
payoutDetails,
@@ -49,12 +51,12 @@ export const usersModel = createModel<RootModel>()({
49
51
potId ?: string ;
50
52
payoutDetails ?: PayoutDetailed ;
51
53
} ) {
52
- const profile = await getUserProfile ( {
54
+ const socialData = await getSocialProfile ( {
53
55
accountId : projectId ,
54
56
} ) ;
55
57
56
- const profileImagesPromise = fetchProfileImages ( {
57
- profile ,
58
+ const socialImagesResponse = fetchSocialImages ( {
59
+ socialData ,
58
60
accountId : projectId ,
59
61
} ) ;
60
62
@@ -70,29 +72,24 @@ export const usersModel = createModel<RootModel>()({
70
72
} )
71
73
: Promise . resolve ( [ ] ) ;
72
74
73
- const [ profileImages , donations ] = await Promise . all ( [
74
- profileImagesPromise ,
75
+ const [ socialImages , donations ] = await Promise . all ( [
76
+ socialImagesResponse ,
75
77
donationsPromise ,
76
78
] ) ;
77
79
78
80
const totalAmountNear = await yoctosToUsdWithFallback (
79
81
getTotalAmountNear ( donations , potId , payoutDetails ) ,
80
82
) ;
81
83
82
- const tags = getTagsFromSocialProfileData ( profile || { } ) ;
83
- const team = getTeamMembersFromProfile ( profile ) ;
84
-
85
- const user = {
86
- [ projectId ] : {
87
- profile : profile ?? { } ,
88
- tags,
89
- team,
90
- totalAmountNear,
91
- profileImages,
92
- } ,
84
+ const profile : Profile = {
85
+ socialData : socialData ?? { } ,
86
+ tags : getTagsFromSocialProfileData ( socialData || { } ) ,
87
+ team : getTeamMembersFromProfile ( socialData ) ,
88
+ totalAmountNear,
89
+ socialImages,
93
90
} ;
94
91
95
- this . update ( user ) ;
92
+ this . update ( { [ projectId ] : profile } ) ;
96
93
} ,
97
94
} ,
98
95
} ) ;
@@ -123,7 +120,7 @@ const updateList = (list: string[], item: string): string[] => {
123
120
124
121
export const navModel = createModel < RootModel > ( ) ( {
125
122
state : {
126
- // TODO: add is registery admin
123
+ // TODO: add is registry admin
127
124
accountId : "" ,
128
125
isNadabotVerified : false ,
129
126
actAsDao : {
0 commit comments