This commit is contained in:
dev.daminik00 2025-07-27 02:58:37 +03:00
parent daf559cfae
commit 2608cadb4c
2 changed files with 7 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
import { Button, Typography } from "@/components/ui";
import { useUserBalance } from "@/hooks/balance/useUserBalance";
import { ROUTES } from "@/shared/constants/client-routes";
import styles from "./Billing.module.scss";
@ -12,6 +13,10 @@ import styles from "./Billing.module.scss";
function Billing() {
const t = useTranslations("Profile.billing");
const router = useRouter();
const { balance, isLoading } = useUserBalance();
// Round balance to nearest integer when available
const roundedBalance = balance !== null ? Math.round(balance) : null;
const onBilling = () => {
router.push(ROUTES.profileSubscriptions());
@ -27,7 +32,7 @@ function Billing() {
<div className={styles.credits}>
<Typography as="p" weight="bold" color="white" align="left">
{t("credits.title", {
credits: String(0),
credits: isLoading || roundedBalance === null ? "..." : String(roundedBalance),
})}
</Typography>
<Typography

View File

@ -40,4 +40,5 @@ export const API_ROUTES = {
getChatsList: () => createRoute(["chats", "list"]),
getChatMessages: (chatId: string) =>
createRoute(["chats", chatId, "messages"]),
getUserBalance: () => createRoute(["chats", "balance"]),
};