add bal
This commit is contained in:
parent
daf559cfae
commit
2608cadb4c
@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
|
|||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
import { Button, Typography } from "@/components/ui";
|
import { Button, Typography } from "@/components/ui";
|
||||||
|
import { useUserBalance } from "@/hooks/balance/useUserBalance";
|
||||||
import { ROUTES } from "@/shared/constants/client-routes";
|
import { ROUTES } from "@/shared/constants/client-routes";
|
||||||
|
|
||||||
import styles from "./Billing.module.scss";
|
import styles from "./Billing.module.scss";
|
||||||
@ -12,6 +13,10 @@ import styles from "./Billing.module.scss";
|
|||||||
function Billing() {
|
function Billing() {
|
||||||
const t = useTranslations("Profile.billing");
|
const t = useTranslations("Profile.billing");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { balance, isLoading } = useUserBalance();
|
||||||
|
|
||||||
|
// Round balance to nearest integer when available
|
||||||
|
const roundedBalance = balance !== null ? Math.round(balance) : null;
|
||||||
|
|
||||||
const onBilling = () => {
|
const onBilling = () => {
|
||||||
router.push(ROUTES.profileSubscriptions());
|
router.push(ROUTES.profileSubscriptions());
|
||||||
@ -27,7 +32,7 @@ function Billing() {
|
|||||||
<div className={styles.credits}>
|
<div className={styles.credits}>
|
||||||
<Typography as="p" weight="bold" color="white" align="left">
|
<Typography as="p" weight="bold" color="white" align="left">
|
||||||
{t("credits.title", {
|
{t("credits.title", {
|
||||||
credits: String(0),
|
credits: isLoading || roundedBalance === null ? "..." : String(roundedBalance),
|
||||||
})}
|
})}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
|
|||||||
@ -40,4 +40,5 @@ export const API_ROUTES = {
|
|||||||
getChatsList: () => createRoute(["chats", "list"]),
|
getChatsList: () => createRoute(["chats", "list"]),
|
||||||
getChatMessages: (chatId: string) =>
|
getChatMessages: (chatId: string) =>
|
||||||
createRoute(["chats", chatId, "messages"]),
|
createRoute(["chats", chatId, "messages"]),
|
||||||
|
getUserBalance: () => createRoute(["chats", "balance"]),
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user