Skip to content

Commit bad5061

Browse files
Ni-2alsakhaev
authored andcommitted
Revert "Merge pull request #238 from dapplets/233-display-total-reward-amount-in-the-app-claim-functionality"
This reverts commit a61040c, reversing changes made to 00545b3.
1 parent 0a43aa1 commit bad5061

File tree

3 files changed

+17
-99
lines changed

3 files changed

+17
-99
lines changed

apps/xen-tg-app/src/components/HistoryNote.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
import { AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
22
import { formatNearAmount } from '@/lib/utils'
3-
import { FC, useMemo } from 'react'
3+
import { FC } from 'react'
44
import { THistoryNote } from '../types'
55

66
export const HistoryCard: FC<{ note: THistoryNote }> = ({ note }) => {
7-
const amountInNearRounded = useMemo(() => {
8-
const amountInNear = formatNearAmount(note.amount)
9-
return amountInNear.slice(0, amountInNear.indexOf('.') + 4)
10-
}, [note.amount])
11-
7+
const amountInNear = formatNearAmount(note.amount)
8+
const amountInNearRounded = amountInNear.slice(0, amountInNear.indexOf('.') + 4)
129
return (
1310
<div className="flex items-center justify-between gap-2.5">
1411
<div className="flex w-max min-w-12 shrink-0 flex-col items-start gap-0.5">
1512
{note.isFree ? (
16-
<div className="flex py-0.25 text-xs/[100%] font-normal text-(--color-my-primary)">
13+
<div className="flex py-0.25 text-[12px]/[100%] font-normal text-(--color-my-primary)">
1714
FREE
1815
</div>
1916
) : null}
20-
<div className="flex w-max shrink-0 py-0.25 text-[14px] font-semibold">
17+
<div className="flex w-max shrink-0 py-0.25 text-[14px]/[150%] font-semibold">
2118
{(note.operationType === 'income' ? '+ ' : '- ') + amountInNearRounded}
2219
</div>
2320
</div>
2421
<div className="flex flex-col gap-0.5">
25-
<div className="flex py-0.25 text-xs/[100%] font-normal text-(--color-gray-text)">
22+
<div className="flex py-0.25 text-[12px]/[100%] font-normal text-(--color-gray-text)">
2623
{new Date(note.createdAt).toLocaleString()}
2724
</div>
28-
<div className="flex py-0.25 text-[14px]/4 font-semibold break-all">
25+
<div className="flex py-0.25 text-[14px]/[150%] font-semibold wrap-anywhere">
2926
{note.capabilityName}
3027
</div>
3128
</div>

apps/xen-tg-app/src/components/Wallet.tsx

Lines changed: 10 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { API_URL } from '@/env'
2-
import { formatNearAmount } from '@/lib/utils'
32
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
4-
import { useMemo } from 'react'
53
import LogOutIcon from '../assets/log-out'
64
import NEAR_ICON from '../assets/near-gray.svg'
7-
import { Balance, RewardAmount, TXenUser } from '../types'
5+
import { Balance, TXenUser } from '../types'
86
import HistoryMainPageModule from './HistoryMainPageModule'
97
import Spinner from './Spinner'
108

11-
const WALLET_URL = 'https://app.mynearwallet.com/' // ToDo: hardcode
12-
139
const queryFn = (name: string, isLoggedIn?: boolean) => async () => {
1410
if (isLoggedIn === false) return
1511
if (!window.Telegram.WebApp.initData) {
@@ -73,11 +69,6 @@ const Wallet = () => {
7369
queryFn: queryFn('getBalance', isLoggedIn),
7470
})
7571

76-
const { data: rewardAmount } = useQuery<RewardAmount>({
77-
queryKey: ['reward-amount'],
78-
queryFn: queryFn('getRewardAmount'),
79-
})
80-
8172
const handleLogout = useMutation({
8273
mutationFn: mutationFn('logout'),
8374
onSuccess: () => {
@@ -94,60 +85,28 @@ const Wallet = () => {
9485
},
9586
})
9687

97-
const amountInNearRounded = useMemo(() => {
98-
if (!rewardAmount?.total) return null
99-
const amountInNear = formatNearAmount(rewardAmount.total)
100-
return amountInNear.slice(0, amountInNear.indexOf('.') + 4)
101-
}, [rewardAmount?.total])
102-
103-
const availableToClaimRounded = useMemo(() => {
104-
if (!rewardAmount?.availableToClaim) return null
105-
const amountInNear = formatNearAmount(rewardAmount.availableToClaim)
106-
return amountInNear.slice(0, amountInNear.indexOf('.') + 4)
107-
}, [rewardAmount?.availableToClaim])
108-
10988
return user && isLoggedIn ? (
110-
<div className="z-1 flex w-full flex-col gap-1 overflow-hidden rounded-xl border border-(--color-opposite-text) p-2.5 backdrop-blur-3xl backdrop-opacity-80 dark:border-(--color-main-text)/30">
111-
<div className="ms-5 me-1 flex items-center justify-between gap-3 py-0.5 text-[22px]/7 font-normal wrap-anywhere">
89+
<div className="z-1 flex w-full flex-wrap items-center justify-between gap-2.5 overflow-hidden rounded-xl border border-(--color-opposite-text) p-2.5 backdrop-blur-3xl backdrop-opacity-80 dark:border-(--color-main-text)/30">
90+
<div className="flex shrink-0 justify-between gap-3 text-[22px]/[150%] font-semibold">
91+
<img src={NEAR_ICON} alt="near" />
92+
{balance?.formatted.available ?? '-'}
93+
</div>
94+
<div className="me-1 flex items-center justify-between gap-3 text-[22px]/[150%] font-normal wrap-anywhere">
11295
<a
113-
href={WALLET_URL}
96+
href="https://app.mynearwallet.com/"
11497
target="_blank"
11598
rel="noreferrer"
11699
className="cursor-pointer underline decoration-(--color-current-mix-50) underline-offset-[3px] transition hover:decoration-(--color-current-mix-20) focus:decoration-(--color-current-mix-20)"
117100
>
118101
{user.nearAccountId}
119102
</a>
120103
<button
121-
className="flex cursor-pointer p-1 text-(--color-gray-text) transition hover:text-(--color-main-text)"
104+
className="flex cursor-pointer p-1.5 text-(--color-gray-text) transition hover:text-(--color-main-text)"
122105
onClick={() => handleLogout.mutate()}
123106
>
124107
<LogOutIcon />
125108
</button>
126109
</div>
127-
<div className="flex shrink-0 flex-wrap items-center justify-between gap-x-2.5 gap-y-0">
128-
<div className="flex shrink-0 gap-2 text-[22px]/normal font-semibold">
129-
<img src={NEAR_ICON} alt="near" />
130-
{balance?.formatted.available ?? '-'}
131-
</div>
132-
<div className="flex shrink-0 flex-col text-xs/tight font-semibold text-(--color-gray-text)">
133-
<div className="flex gap-1">
134-
Total revenue:{' '}
135-
<span className="text-(--color-my-primary)">
136-
{amountInNearRounded && amountInNearRounded !== '0' ? `+${amountInNearRounded}` : '0'}
137-
</span>{' '}
138-
<img className="w-2.5" src={NEAR_ICON} alt="near" />
139-
</div>
140-
<div className="flex gap-1">
141-
Available to claim:{' '}
142-
<span className="text-(--color-my-primary)">
143-
{availableToClaimRounded && availableToClaimRounded !== '0'
144-
? `+${availableToClaimRounded}`
145-
: '0'}
146-
</span>{' '}
147-
<img className="w-2.5" src={NEAR_ICON} alt="near" />
148-
</div>
149-
</div>
150-
</div>
151110
<HistoryMainPageModule />
152111
</div>
153112
) : (
@@ -156,40 +115,7 @@ const Wallet = () => {
156115
<Spinner />
157116
) : (
158117
<div className="flex w-full items-center justify-between">
159-
<div className="flex shrink-0 flex-col gap-1 text-xs/tight font-semibold text-(--color-gray-text)">
160-
{availableToClaimRounded && availableToClaimRounded !== '0' ? (
161-
<>
162-
<div className="flex flex-col text-sm text-(--color-main-text)">
163-
<p>Available to claim:</p>
164-
<div className="flex gap-1 text-2xl/tight">
165-
<p className="text-(--color-my-primary)">{`+${availableToClaimRounded}`}</p>
166-
<img className="w-4" src={NEAR_ICON} alt="near" />
167-
</div>
168-
</div>
169-
<div className="flex gap-1">
170-
Total revenue:{' '}
171-
<span className="text-(--color-my-primary)">
172-
{amountInNearRounded && amountInNearRounded !== '0'
173-
? `+${amountInNearRounded}`
174-
: '0'}
175-
</span>{' '}
176-
<img className="w-2.5" src={NEAR_ICON} alt="near" />
177-
</div>
178-
</>
179-
) : (
180-
<div className="flex flex-col text-sm text-(--color-main-text)">
181-
<p>Total revenue:</p>
182-
<div className="flex gap-1 text-2xl/tight">
183-
<p className="text-(--color-my-primary)">
184-
{amountInNearRounded || amountInNearRounded !== '0'
185-
? `+${amountInNearRounded}`
186-
: '0'}
187-
</p>
188-
<img className="w-4" src={NEAR_ICON} alt="near" />
189-
</div>
190-
</div>
191-
)}
192-
</div>
118+
<div className="text-[18px]/[150%] font-semibold">No wallet connected</div>
193119
<button
194120
className="flex w-[118px] cursor-pointer flex-nowrap items-center justify-center rounded-xl bg-(--color-my-primary) py-2 text-(--color-opposite-text) dark:bg-[#f8f9ff] dark:text-(--color-opposite-text)"
195121
onClick={() => handleLogin.mutate()}

apps/xen-tg-app/src/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,3 @@ export type THistoryNote = {
6666
createdAt: string
6767
isFree?: boolean
6868
}
69-
70-
export type RewardAmount = {
71-
total: string
72-
availableToClaim: string
73-
}

0 commit comments

Comments
 (0)