feat: remove userId query for wallet get
This commit is contained in:
parent
80f1b0fd28
commit
b19fc2be2e
|
|
@ -1,7 +1,6 @@
|
|||
import { useMutation } from "@tanstack/react-query"
|
||||
import { Trans, useTranslation } from "react-i18next"
|
||||
|
||||
import { useWhoami } from "~/atoms/user"
|
||||
import { Button } from "~/components/ui/button"
|
||||
import { CopyButton } from "~/components/ui/code-highlighter"
|
||||
import { LoadingWithIcon } from "~/components/ui/loading"
|
||||
|
|
@ -19,8 +18,7 @@ import { WithdrawButton } from "./withdraw"
|
|||
|
||||
export const MyWalletSection = () => {
|
||||
const { t } = useTranslation("settings")
|
||||
const user = useWhoami()
|
||||
const wallet = useWallet({ userId: user?.id })
|
||||
const wallet = useWallet()
|
||||
const myWallet = wallet.data?.[0]
|
||||
|
||||
const refreshMutation = useMutation({
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import { Trans, useTranslation } from "react-i18next"
|
|||
import { toast } from "sonner"
|
||||
import { z } from "zod"
|
||||
|
||||
import { useWhoami } from "~/atoms/user"
|
||||
import { Button } from "~/components/ui/button"
|
||||
import {
|
||||
Form,
|
||||
|
|
@ -44,8 +43,7 @@ export const WithdrawButton = () => {
|
|||
|
||||
const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => {
|
||||
const { t } = useTranslation("settings")
|
||||
const user = useWhoami()
|
||||
const wallet = useWallet({ userId: user?.id })
|
||||
const wallet = useWallet()
|
||||
const cashablePowerTokenBigInt = [BigInt(wallet.data?.[0].cashablePowerToken || 0n), 18] as const
|
||||
const cashablePowerTokenNumber = toNumber(cashablePowerTokenBigInt)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import { useWallet, useWalletTransactions } from "~/queries/wallet"
|
|||
export const TransactionsSection: Component = ({ className }) => {
|
||||
const { t } = useTranslation("settings")
|
||||
const user = useWhoami()
|
||||
const wallet = useWallet({ userId: user?.id })
|
||||
const wallet = useWallet()
|
||||
const myWallet = wallet.data?.[0]
|
||||
|
||||
const transactions = useWalletTransactions({ fromOrToUserId: user?.id })
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { memo, useState } from "react"
|
|||
import { useTranslation } from "react-i18next"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
import { useWhoami } from "~/atoms/user"
|
||||
import { useSignOut } from "~/hooks/biz/useSignOut"
|
||||
import { useMeasure } from "~/hooks/common"
|
||||
import { nextFrame } from "~/lib/dom"
|
||||
|
|
@ -157,8 +156,7 @@ export const ProfileButton: FC<LoginProps> = memo((props) => {
|
|||
ProfileButton.displayName = "ProfileButton"
|
||||
|
||||
function PowerButton() {
|
||||
const user = useWhoami()
|
||||
const wallet = useWallet({ userId: user?.id })
|
||||
const wallet = useWallet()
|
||||
const { isLoading } = wallet
|
||||
const myWallet = wallet.data?.[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { from } from "dnum"
|
|||
import type { FC } from "react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { useWhoami } from "~/atoms/user"
|
||||
import { Button } from "~/components/ui/button"
|
||||
import { Divider } from "~/components/ui/divider"
|
||||
import { LoadingWithIcon } from "~/components/ui/loading"
|
||||
|
|
@ -21,8 +20,7 @@ import { Balance } from "./balance"
|
|||
const DEFAULT_RECOMMENDED_TIP = 10
|
||||
|
||||
const useMyWallet = () => {
|
||||
const user = useWhoami()
|
||||
const myWallet = useWallet({ userId: user?.id })
|
||||
const myWallet = useWallet()
|
||||
return myWallet
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export function Component() {
|
|||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="max-w-screen-md px-10">
|
||||
<div className="w-[768px] px-10">
|
||||
<div className="mb-8 flex items-center gap-2 text-3xl font-bold">
|
||||
<div className="motion-preset-shake center text-accent motion-delay-500">
|
||||
<i className="i-mgc-power" />
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@ export const wallet = {
|
|||
},
|
||||
}
|
||||
|
||||
export const useWallet = ({ userId }: { userId?: string } = {}) =>
|
||||
useAuthQuery(wallet.get({ userId }), { enabled: !!userId })
|
||||
export const useWallet = () => useAuthQuery(wallet.get())
|
||||
|
||||
export const useWalletTransactions = (query: Parameters<typeof wallet.transactions.get>[0] = {}) =>
|
||||
useAuthQuery(wallet.transactions.get(query))
|
||||
|
|
|
|||
|
|
@ -3968,15 +3968,15 @@ declare const walletsOpenAPISchema: zod.ZodObject<{
|
|||
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
|
||||
createdAt: string;
|
||||
userId: string;
|
||||
address: string | null;
|
||||
addressIndex: number;
|
||||
address: string | null;
|
||||
dailyPowerToken: string;
|
||||
cashablePowerToken: string;
|
||||
}, {
|
||||
createdAt: string;
|
||||
userId: string;
|
||||
address: string | null;
|
||||
addressIndex: number;
|
||||
address: string | null;
|
||||
dailyPowerToken: string;
|
||||
cashablePowerToken: string;
|
||||
}>;
|
||||
|
|
@ -4895,19 +4895,14 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
|
|||
};
|
||||
"/wallets": {
|
||||
$get: {
|
||||
input: {
|
||||
query: {
|
||||
userId?: string | string[] | undefined;
|
||||
address?: string | string[] | undefined;
|
||||
};
|
||||
};
|
||||
input: {};
|
||||
output: {
|
||||
code: 0;
|
||||
data: {
|
||||
createdAt: string;
|
||||
userId: string;
|
||||
address: string | null;
|
||||
addressIndex: number;
|
||||
address: string | null;
|
||||
dailyPowerToken: string;
|
||||
cashablePowerToken: string;
|
||||
}[];
|
||||
|
|
|
|||
Loading…
Reference in New Issue