@@ -6,22 +6,25 @@ export const CreateWallet = () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<StyledButton
|
||||
variant="primary"
|
||||
isLoading={mutation.isPending}
|
||||
onClick={() => mutation.mutate()}
|
||||
>
|
||||
Create Wallet
|
||||
</StyledButton>
|
||||
|
||||
<p className="my-2 text-sm text-gray-400 dark:text-neutral-500">
|
||||
<p className="text-base">
|
||||
Create a free wallet to receive
|
||||
{" "}
|
||||
<strong className="font-medium">Power</strong>
|
||||
, which can
|
||||
be used to reward creators and also get rewarded for your content
|
||||
contributions.
|
||||
<strong className="inline-flex items-baseline gap-1 font-medium">
|
||||
<i className="i-mgc-power translate-y-[2px]" />
|
||||
Power
|
||||
</strong>
|
||||
, which can be used to
|
||||
reward creators and also get rewarded for your content contributions.
|
||||
</p>
|
||||
<div className="mt-4 text-right">
|
||||
<StyledButton
|
||||
variant="primary"
|
||||
isLoading={mutation.isPending}
|
||||
onClick={() => mutation.mutate()}
|
||||
>
|
||||
Create Wallet
|
||||
</StyledButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -19,76 +19,72 @@ export const MyWalletSection = () => {
|
||||
const wallet = useWallet({ userId: user?.id })
|
||||
const myWallet = wallet.data?.[0]
|
||||
|
||||
if (wallet.isPending) {
|
||||
return (
|
||||
<div className="center absolute inset-0 flex">
|
||||
<LoadingCircle size="large" className="-translate-y-full" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!myWallet) {
|
||||
return <CreateWallet />
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
{wallet.isPending ? (
|
||||
<div className="center absolute inset-0 flex">
|
||||
<LoadingCircle size="large" className="-translate-y-full" />
|
||||
<div className="space-y-8">
|
||||
<div>
|
||||
<SettingSectionTitle title="Balance" />
|
||||
<div className="flex items-end justify-between">
|
||||
<Balance className="text-xl font-bold text-theme-accent">
|
||||
{BigInt(myWallet.dailyPowerToken || 0n) +
|
||||
BigInt(myWallet.cashablePowerToken || 0n)}
|
||||
</Balance>
|
||||
<ClaimDailyReward />
|
||||
</div>
|
||||
) : !myWallet ?
|
||||
(
|
||||
<CreateWallet />
|
||||
) :
|
||||
(
|
||||
<div className="space-y-8">
|
||||
<div>
|
||||
<SettingSectionTitle title="Balance" />
|
||||
<div className="flex items-center justify-between">
|
||||
<Balance className="text-xl font-bold text-theme-accent">
|
||||
{BigInt(myWallet.dailyPowerToken || 0n) +
|
||||
BigInt(myWallet.cashablePowerToken || 0n)}
|
||||
</Balance>
|
||||
<ClaimDailyReward />
|
||||
</div>
|
||||
<Divider className="my-4" />
|
||||
<Tooltip>
|
||||
<TooltipTrigger className="block">
|
||||
<div className="flex flex-row items-center gap-x-2 text-xs text-zinc-600 dark:text-neutral-400">
|
||||
<span className="flex w-[120px] items-center gap-1 text-left">
|
||||
Daily Power
|
||||
<i className="i-mingcute-question-line" />
|
||||
</span>
|
||||
<Balance>{myWallet.dailyPowerToken}</Balance>
|
||||
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent align="start" className="z-[999]">
|
||||
<p>1. Daily Power can only be used for tips.</p>
|
||||
<p>
|
||||
2. It comes from the Power you claim for free every day..
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger className="block">
|
||||
<div className="flex flex-row items-center gap-x-2 text-xs text-zinc-600 dark:text-neutral-400">
|
||||
<span className="flex w-[120px] items-center gap-1 text-left">
|
||||
Cashable Power
|
||||
{" "}
|
||||
<i className="i-mingcute-question-line" />
|
||||
</span>
|
||||
|
||||
<Balance>{myWallet.cashablePowerToken}</Balance>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent align="start" className="z-[999]">
|
||||
<p>
|
||||
1. You can transfer Cashable Power to your wallet and trade
|
||||
freely.
|
||||
</p>
|
||||
<p>
|
||||
2. It comes from the Power you recharge and the tips you
|
||||
receive.
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<Divider className="my-4" />
|
||||
<Tooltip>
|
||||
<TooltipTrigger className="block">
|
||||
<div className="flex flex-row items-center gap-x-2 text-xs text-zinc-600 dark:text-neutral-400">
|
||||
<span className="flex w-[120px] items-center gap-1 text-left">
|
||||
Daily Power
|
||||
<i className="i-mingcute-question-line" />
|
||||
</span>
|
||||
<Balance>{myWallet.dailyPowerToken}</Balance>
|
||||
</div>
|
||||
)}
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent align="start" className="z-[999]">
|
||||
<p>1. Daily Power can only be used for tips.</p>
|
||||
<p>2. It comes from the Power you claim for free every day..</p>
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger className="block">
|
||||
<div className="flex flex-row items-center gap-x-2 text-xs text-zinc-600 dark:text-neutral-400">
|
||||
<span className="flex w-[120px] items-center gap-1 text-left">
|
||||
Cashable Power
|
||||
{" "}
|
||||
<i className="i-mingcute-question-line" />
|
||||
</span>
|
||||
|
||||
<Balance>{myWallet.cashablePowerToken}</Balance>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent align="start" className="z-[999]">
|
||||
<p>
|
||||
1. You can transfer Cashable Power to your wallet and trade
|
||||
freely.
|
||||
</p>
|
||||
<p>
|
||||
2. It comes from the Power you recharge and the tips you
|
||||
receive.
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
} from "@renderer/components/ui/avatar"
|
||||
import { RelativeTime } from "@renderer/components/ui/datetime"
|
||||
import { LoadingCircle } from "@renderer/components/ui/loading"
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -17,7 +19,6 @@ import { Balance } from "@renderer/components/ui/wallet/balance"
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
import { SettingSectionTitle } from "@renderer/modules/settings/section"
|
||||
import { useWallet, useWalletTransactions } from "@renderer/queries/wallet"
|
||||
import dayjs from "dayjs"
|
||||
|
||||
export const TransactionsSection = () => {
|
||||
const user = useMe()
|
||||
@@ -26,9 +27,15 @@ export const TransactionsSection = () => {
|
||||
|
||||
const transactions = useWalletTransactions({ fromOrToUserId: user?.id })
|
||||
|
||||
if (!myWallet) return
|
||||
if (!myWallet) return null
|
||||
|
||||
if (transactions.isLoading) { return <div className="text-theme-disabled">Loading...</div> }
|
||||
if (transactions.isLoading) {
|
||||
return (
|
||||
<div className="center mt-12">
|
||||
<LoadingCircle size="large" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// if (transactions.data?.length === 0) return <div className="text-theme-disabled">No transactions</div>
|
||||
|
||||
@@ -40,11 +47,21 @@ export const TransactionsSection = () => {
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead size="sm">Type</TableHead>
|
||||
<TableHead size="sm">Amount</TableHead>
|
||||
<TableHead size="sm">From</TableHead>
|
||||
<TableHead size="sm">To</TableHead>
|
||||
<TableHead size="sm">Date</TableHead>
|
||||
<TableHead className="text-center" size="sm">
|
||||
Type
|
||||
</TableHead>
|
||||
<TableHead className="text-center" size="sm">
|
||||
Amount
|
||||
</TableHead>
|
||||
<TableHead className="text-center" size="sm">
|
||||
From
|
||||
</TableHead>
|
||||
<TableHead className="text-center" size="sm">
|
||||
To
|
||||
</TableHead>
|
||||
<TableHead className="text-center" size="sm">
|
||||
Date
|
||||
</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
@@ -67,7 +84,7 @@ export const TransactionsSection = () => {
|
||||
</TableCell>
|
||||
{/* <TableCell align="center" size="sm"><FeedRenderer feed={row.toFeed} /></TableCell> */}
|
||||
<TableCell align="center" size="sm">
|
||||
{dayjs(row.createdAt).fromNow()}
|
||||
<RelativeTime date={row.createdAt} />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user