Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
b9a823da
Commit
b9a823da
authored
Sep 30, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add referrals query
parent
fbffec54
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
27 deletions
+58
-27
RewardsDashboard.tsx
ui/pages/RewardsDashboard.tsx
+10
-6
CopyField.tsx
ui/rewards/CopyField.tsx
+22
-19
CongratsStepContent.tsx
ui/rewards/steps/CongratsStepContent.tsx
+9
-2
useReferrals.tsx
ui/rewards/useReferrals.tsx
+17
-0
No files found.
ui/pages/RewardsDashboard.tsx
View file @
b9a823da
import
{
Button
,
Flex
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Button
,
Flex
,
Skeleton
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
useRewardsContext
}
from
'
lib/contexts/rewards
'
;
import
{
useRewardsContext
}
from
'
lib/contexts/rewards
'
;
import
CopyField
from
'
ui/rewards/CopyField
'
;
import
CopyField
from
'
ui/rewards/CopyField
'
;
import
RewardsDashboardCard
from
'
ui/rewards/RewardsDashboardCard
'
;
import
RewardsDashboardCard
from
'
ui/rewards/RewardsDashboardCard
'
;
import
useReferrals
from
'
ui/rewards/useReferrals
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
LinkExternal
from
'
ui/shared/links/LinkExternal
'
;
import
LinkExternal
from
'
ui/shared/links/LinkExternal
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
...
@@ -12,6 +13,7 @@ import PageTitle from 'ui/shared/Page/PageTitle';
...
@@ -12,6 +13,7 @@ import PageTitle from 'ui/shared/Page/PageTitle';
const
RewardsDashboard
=
()
=>
{
const
RewardsDashboard
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
{
balances
,
dailyReward
,
isLogedIn
}
=
useRewardsContext
();
const
{
balances
,
dailyReward
,
isLogedIn
}
=
useRewardsContext
();
const
referralsQuery
=
useReferrals
();
if
(
!
isLogedIn
)
{
if
(
!
isLogedIn
)
{
router
.
replace
({
pathname
:
'
/
'
},
undefined
,
{
shallow
:
true
});
router
.
replace
({
pathname
:
'
/
'
},
undefined
,
{
shallow
:
true
});
...
@@ -76,8 +78,8 @@ const RewardsDashboard = () => {
...
@@ -76,8 +78,8 @@ const RewardsDashboard = () => {
px=
{
6
}
px=
{
6
}
flexShrink=
{
0
}
flexShrink=
{
0
}
>
>
<
CopyField
label=
"Referral link"
value=
"blockscout.com/ref/0x789a9201d10029139101"
/>
<
CopyField
label=
"Referral link"
value=
{
referralsQuery
.
data
?.
link
||
''
}
isLoading=
{
referralsQuery
.
isLoading
}
/>
<
CopyField
label=
"Referral code"
value=
"CODE10"
/>
<
CopyField
label=
"Referral code"
value=
{
referralsQuery
.
data
?.
code
||
''
}
isLoading=
{
referralsQuery
.
isLoading
}
/>
<
Flex
flexDirection=
"column"
>
<
Flex
flexDirection=
"column"
>
<
Flex
alignItems=
"center"
gap=
{
1
}
w=
"120px"
>
<
Flex
alignItems=
"center"
gap=
{
1
}
w=
"120px"
>
<
IconSvg
name=
"info"
boxSize=
{
5
}
color=
"gray.500"
/>
<
IconSvg
name=
"info"
boxSize=
{
5
}
color=
"gray.500"
/>
...
@@ -85,9 +87,11 @@ const RewardsDashboard = () => {
...
@@ -85,9 +87,11 @@ const RewardsDashboard = () => {
Referrals
Referrals
</
Text
>
</
Text
>
</
Flex
>
</
Flex
>
<
Text
fontSize=
"32px"
fontWeight=
"500"
>
<
Skeleton
isLoaded=
{
!
referralsQuery
.
isLoading
}
>
0
<
Text
fontSize=
"32px"
fontWeight=
"500"
>
</
Text
>
{
referralsQuery
.
data
?.
referrals
||
0
}
</
Text
>
</
Skeleton
>
</
Flex
>
</
Flex
>
</
Flex
>
</
Flex
>
</
Flex
>
</
Flex
>
...
...
ui/rewards/CopyField.tsx
View file @
b9a823da
import
{
FormControl
,
Input
,
InputGroup
,
InputRightElement
,
chakra
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
FormControl
,
Input
,
InputGroup
,
InputRightElement
,
Skeleton
,
chakra
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
...
@@ -8,29 +8,32 @@ type Props = {
...
@@ -8,29 +8,32 @@ type Props = {
label
:
string
;
label
:
string
;
value
:
string
;
value
:
string
;
className
?:
string
;
className
?:
string
;
isLoading
?:
boolean
;
};
};
const
CopyField
=
({
label
,
value
,
className
}:
Props
)
=>
{
const
CopyField
=
({
label
,
value
,
className
,
isLoading
}:
Props
)
=>
{
const
bgColor
=
`
${
useColorModeValue
(
'
gray.200
'
,
'
blackAlpha.900
'
)
}
!important`
;
const
bgColor
=
`
${
useColorModeValue
(
'
gray.200
'
,
'
blackAlpha.900
'
)
}
!important`
;
return
(
return
(
<
FormControl
variant=
"floating"
id=
{
label
}
className=
{
className
}
>
<
FormControl
variant=
"floating"
id=
{
label
}
className=
{
className
}
>
<
InputGroup
>
<
Skeleton
isLoaded=
{
!
isLoading
}
>
<
Input
<
InputGroup
>
readOnly
<
Input
fontWeight=
"500"
readOnly
value=
{
value
}
fontWeight=
"500"
overflow=
"hidden"
value=
{
value
}
textOverflow=
"ellipsis"
overflow=
"hidden"
pr=
"40px !important"
textOverflow=
"ellipsis"
bgColor=
{
bgColor
}
pr=
"40px !important"
borderColor=
{
bgColor
}
bgColor=
{
bgColor
}
borderRadius=
"12px !important"
borderColor=
{
bgColor
}
/>
borderRadius=
"12px !important"
<
InputPlaceholder
text=
{
label
}
bgColor=
{
bgColor
}
/>
/>
<
InputRightElement
w=
"40px"
display=
"flex"
justifyContent=
"flex-end"
pr=
{
2
}
>
<
InputPlaceholder
text=
{
label
}
bgColor=
{
bgColor
}
/>
<
CopyToClipboard
text=
{
value
}
/>
<
InputRightElement
w=
"40px"
display=
"flex"
justifyContent=
"flex-end"
pr=
{
2
}
>
</
InputRightElement
>
<
CopyToClipboard
text=
{
value
}
/>
</
InputGroup
>
</
InputRightElement
>
</
InputGroup
>
</
Skeleton
>
</
FormControl
>
</
FormControl
>
);
);
};
};
...
...
ui/rewards/steps/CongratsStepContent.tsx
View file @
b9a823da
...
@@ -7,8 +7,10 @@ import IconSvg from 'ui/shared/IconSvg';
...
@@ -7,8 +7,10 @@ import IconSvg from 'ui/shared/IconSvg';
import
AvailableSoonLabel
from
'
../AvailableSoonLabel
'
;
import
AvailableSoonLabel
from
'
../AvailableSoonLabel
'
;
import
CopyField
from
'
../CopyField
'
;
import
CopyField
from
'
../CopyField
'
;
import
useReferrals
from
'
../useReferrals
'
;
const
CongratsStepContent
=
()
=>
{
const
CongratsStepContent
=
()
=>
{
const
referralsQuery
=
useReferrals
();
return
(
return
(
<>
<>
<
Flex
<
Flex
...
@@ -53,8 +55,13 @@ const CongratsStepContent = () => {
...
@@ -53,8 +55,13 @@ const CongratsStepContent = () => {
<
Text
fontSize=
"md"
mt=
{
2
}
>
<
Text
fontSize=
"md"
mt=
{
2
}
>
Receive a 10% bonus on all merits earned by your referrals
Receive a 10% bonus on all merits earned by your referrals
</
Text
>
</
Text
>
<
CopyField
label=
"Code"
value=
"Test value"
mt=
{
3
}
/>
<
CopyField
<
Button
mt=
{
6
}
>
label=
"Referral link"
value=
{
referralsQuery
.
data
?.
link
||
''
}
isLoading=
{
referralsQuery
.
isLoading
}
mt=
{
3
}
/>
<
Button
mt=
{
6
}
isLoading=
{
referralsQuery
.
isLoading
}
>
Share on
<
IconSvg
name=
"social/twitter"
boxSize=
{
6
}
ml=
{
1
}
/>
Share on
<
IconSvg
name=
"social/twitter"
boxSize=
{
6
}
ml=
{
1
}
/>
</
Button
>
</
Button
>
</
Flex
>
</
Flex
>
...
...
ui/rewards/useReferrals.tsx
0 → 100644
View file @
b9a823da
import
config
from
'
configs/app
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
export
default
function
useReferrals
()
{
const
apiToken
=
cookies
.
get
(
cookies
.
NAMES
.
REWARDS_API_TOKEN
);
return
useApiQuery
(
'
rewards_user_referrals
'
,
{
queryOptions
:
{
enabled
:
Boolean
(
apiToken
)
&&
config
.
features
.
rewards
.
isEnabled
,
},
fetchParams
:
{
headers
:
{
Authorization
:
`Bearer
${
apiToken
}
`
,
},
},
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment