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
34bf84b4
Commit
34bf84b4
authored
Sep 30, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rewards config query
parent
b9a823da
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
6 deletions
+47
-6
resources.ts
lib/api/resources.ts
+7
-0
rewards.ts
types/api/rewards.ts
+9
-0
RewardsDashboard.tsx
ui/pages/RewardsDashboard.tsx
+7
-1
CongratsStepContent.tsx
ui/rewards/steps/CongratsStepContent.tsx
+14
-5
useRewardsConfig.tsx
ui/rewards/useRewardsConfig.tsx
+10
-0
No files found.
lib/api/resources.ts
View file @
34bf84b4
...
...
@@ -91,6 +91,7 @@ import type {
}
from
'
types/api/optimisticL2
'
;
import
type
{
RawTracesResponse
}
from
'
types/api/rawTrace
'
;
import
type
{
RewardsConfigResponse
,
RewardsNonceResponse
,
RewardsCheckUserResponse
,
RewardsLoginResponse
,
...
...
@@ -329,6 +330,11 @@ export const RESOURCES = {
},
// REWARDS SERVICE
rewards_config
:
{
path
:
'
/api/v1/config
'
,
endpoint
:
getFeaturePayload
(
config
.
features
.
rewards
)?.
api
.
endpoint
,
basePath
:
getFeaturePayload
(
config
.
features
.
rewards
)?.
api
.
basePath
,
},
rewards_nonce
:
{
path
:
'
/api/v1/auth/nonce
'
,
endpoint
:
getFeaturePayload
(
config
.
features
.
rewards
)?.
api
.
endpoint
,
...
...
@@ -1221,6 +1227,7 @@ Q extends 'address_mud_records' ? AddressMudRecords :
Q
extends
'
address_mud_record
'
?
AddressMudRecord
:
Q
extends
'
withdrawals
'
?
WithdrawalsResponse
:
Q
extends
'
withdrawals_counters
'
?
WithdrawalsCounters
:
Q
extends
'
rewards_config
'
?
RewardsConfigResponse
:
Q
extends
'
rewards_nonce
'
?
RewardsNonceResponse
:
Q
extends
'
rewards_check_user
'
?
RewardsCheckUserResponse
:
Q
extends
'
rewards_login
'
?
RewardsLoginResponse
:
...
...
types/api/rewards.ts
View file @
34bf84b4
export
type
RewardsConfigResponse
=
{
rewards
:
{
registration
:
string
;
registration_with_referral
:
string
;
daily_claim
:
string
;
referral_share
:
string
;
};
};
export
type
RewardsNonceResponse
=
{
nonce
:
string
;
};
...
...
ui/pages/RewardsDashboard.tsx
View file @
34bf84b4
...
...
@@ -6,6 +6,7 @@ import { useRewardsContext } from 'lib/contexts/rewards';
import
CopyField
from
'
ui/rewards/CopyField
'
;
import
RewardsDashboardCard
from
'
ui/rewards/RewardsDashboardCard
'
;
import
useReferrals
from
'
ui/rewards/useReferrals
'
;
import
useRewardsConfig
from
'
ui/rewards/useRewardsConfig
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
LinkExternal
from
'
ui/shared/links/LinkExternal
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
...
...
@@ -14,6 +15,7 @@ const RewardsDashboard = () => {
const
router
=
useRouter
();
const
{
balances
,
dailyReward
,
isLogedIn
}
=
useRewardsContext
();
const
referralsQuery
=
useReferrals
();
const
rewardsConfigQuery
=
useRewardsConfig
();
if
(
!
isLogedIn
)
{
router
.
replace
({
pathname
:
'
/
'
},
undefined
,
{
shallow
:
true
});
...
...
@@ -66,7 +68,11 @@ const RewardsDashboard = () => {
Referral program
</
Text
>
<
Text
fontSize=
"sm"
>
Refer friends and boost your merits! You receive a 10% bonus on all merits earned by your referrals.
Refer friends and boost your merits! You receive a
{
'
'
}
<
Skeleton
display=
"inline"
isLoaded=
{
!
rewardsConfigQuery
.
isLoading
}
>
{
Number
(
rewardsConfigQuery
.
data
?.
rewards
.
referral_share
||
0
)
*
100
}
%
</
Skeleton
>
{
'
'
}
bonus on all merits earned by your referrals.
</
Text
>
</
Flex
>
<
Flex
...
...
ui/rewards/steps/CongratsStepContent.tsx
View file @
34bf84b4
import
{
Text
,
Box
,
Flex
,
useColorModeValue
,
Button
}
from
'
@chakra-ui/react
'
;
import
{
Text
,
Box
,
Flex
,
useColorModeValue
,
Button
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
...
...
@@ -8,9 +8,12 @@ import IconSvg from 'ui/shared/IconSvg';
import
AvailableSoonLabel
from
'
../AvailableSoonLabel
'
;
import
CopyField
from
'
../CopyField
'
;
import
useReferrals
from
'
../useReferrals
'
;
import
useRewardsConfig
from
'
../useRewardsConfig
'
;
const
CongratsStepContent
=
()
=>
{
const
referralsQuery
=
useReferrals
();
const
rewardsConfigQuery
=
useRewardsConfig
();
return
(
<>
<
Flex
...
...
@@ -23,9 +26,11 @@ const CongratsStepContent = () => {
>
<
Flex
alignItems=
"center"
pl=
{
2
}
mb=
{
4
}
>
<
IconSvg
name=
"merits_colored"
boxSize=
{
16
}
/>
<
Text
fontSize=
"30px"
fontWeight=
"700"
color=
"blue.700"
>
+250
</
Text
>
<
Skeleton
isLoaded=
{
!
rewardsConfigQuery
.
isLoading
}
>
<
Text
fontSize=
"30px"
fontWeight=
"700"
color=
"blue.700"
>
+
{
rewardsConfigQuery
.
data
?.
rewards
.
registration
}
</
Text
>
</
Skeleton
>
</
Flex
>
<
Flex
flexDirection=
"column"
...
...
@@ -53,7 +58,11 @@ const CongratsStepContent = () => {
</
Text
>
</
Flex
>
<
Text
fontSize=
"md"
mt=
{
2
}
>
Receive a 10% bonus on all merits earned by your referrals
Receive a
{
'
'
}
<
Skeleton
display=
"inline"
isLoaded=
{
!
rewardsConfigQuery
.
isLoading
}
>
{
Number
(
rewardsConfigQuery
.
data
?.
rewards
.
referral_share
||
0
)
*
100
}
%
</
Skeleton
>
{
'
'
}
bonus on all merits earned by your referrals
</
Text
>
<
CopyField
label=
"Referral link"
...
...
ui/rewards/useRewardsConfig.tsx
0 → 100644
View file @
34bf84b4
import
config
from
'
configs/app
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
export
default
function
useReferrals
()
{
return
useApiQuery
(
'
rewards_config
'
,
{
queryOptions
:
{
enabled
:
config
.
features
.
rewards
.
isEnabled
,
},
});
}
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