From e247757348f9a817304b47e7a5fa7cb1a7bdc449 Mon Sep 17 00:00:00 2001 From: Pritesh Date: Wed, 3 Jun 2026 04:27:05 +0530 Subject: [PATCH] feat(lead-gen): extract DograhCreditsCard with top-up + hire CTAs Co-Authored-By: Claude Opus 4.8 (1M context) --- .../components/billing/DograhCreditsCard.tsx | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 ui/src/components/billing/DograhCreditsCard.tsx diff --git a/ui/src/components/billing/DograhCreditsCard.tsx b/ui/src/components/billing/DograhCreditsCard.tsx new file mode 100644 index 00000000..25a09a6e --- /dev/null +++ b/ui/src/components/billing/DograhCreditsCard.tsx @@ -0,0 +1,97 @@ +"use client"; + +import { UserRound } from "lucide-react"; +import { useCallback, useEffect, useState } from "react"; + +import { getMpsCreditsApiV1OrganizationsUsageMpsCreditsGet } from "@/client/sdk.gen"; +import type { MpsCreditsResponse } from "@/client/types.gen"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Progress } from "@/components/ui/progress"; +import { useLeadForms } from "@/context/LeadFormsContext"; +import { useAuth } from "@/lib/auth"; + +export function DograhCreditsCard() { + const auth = useAuth(); + const { openHireExpert, openTopUp } = useLeadForms(); + const [mpsCredits, setMpsCredits] = useState(null); + const [isLoadingCredits, setIsLoadingCredits] = useState(true); + + const fetchMpsCredits = useCallback(async () => { + if (!auth.isAuthenticated) return; + try { + const response = await getMpsCreditsApiV1OrganizationsUsageMpsCreditsGet(); + if (response.data) { + setMpsCredits(response.data); + } + } catch (error) { + console.error("Failed to fetch MPS credits:", error); + } finally { + setIsLoadingCredits(false); + } + }, [auth.isAuthenticated]); + + useEffect(() => { + if (auth.isAuthenticated) { + fetchMpsCredits(); + } + }, [auth.isAuthenticated, fetchMpsCredits]); + + return ( + + + Dograh Model Credits + + These track usage of Dograh models using Dograh Service Keys. + + + + {isLoadingCredits ? ( +
+
+
+
+
+ ) : mpsCredits ? ( +
+
+
+

+ {mpsCredits.total_credits_used.toFixed(2)}{" "} + + / {mpsCredits.total_quota.toFixed(2)} + +

+

Credits Used

+
+
+

{mpsCredits.remaining_credits.toFixed(2)}

+

Remaining

+
+
+ + {mpsCredits.total_quota > 0 && ( + + )} +
+ ) : ( +

+ No Dograh service keys configured. Set up a service key in your model configuration to see usage. +

+ )} + + {/* Footer CTAs — card ends with an action */} +
+ Running low? +
+ + +
+
+
+
+ ); +}