diff --git a/src/components/CreditsDialog.tsx b/src/components/CreditsDialog.tsx index d00fd867..1d6bb6b4 100644 --- a/src/components/CreditsDialog.tsx +++ b/src/components/CreditsDialog.tsx @@ -7,9 +7,8 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Badge } from '@/components/ui/badge'; -import { Separator } from '@/components/ui/separator'; import { Skeleton } from '@/components/ui/skeleton'; -import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'; +import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; import { useToast } from '@/hooks/useToast'; import { createAIClient } from '@/lib/ai-client'; @@ -222,7 +221,6 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro const [paymentMethod, setPaymentMethod] = useState<'stripe' | 'lightning'>('stripe'); const [lightningInvoice, setLightningInvoice] = useState(null); const [refreshingPayments, setRefreshingPayments] = useState>(new Set()); - const [activeTab, setActiveTab] = useState<'buy' | 'giftcards'>('buy'); const [giftcardAmount, setGiftcardAmount] = useState(10); const [giftcardQuantity, setGiftcardQuantity] = useState(1); const [redeemCode, setRedeemCode] = useState(''); @@ -249,7 +247,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro const data = await ai.get('/credits/giftcards?limit=50') as GiftcardsResponse; return data.data; }, - enabled: open && activeTab === 'giftcards', + enabled: open, retry: false, refetchOnWindowFocus: false, }); @@ -601,343 +599,343 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro {/* Buy Credits Accordion */} - -
- - Buy Credits -
-
- -
-
- -
- setAmount(Number(e.target.value))} - placeholder="Enter amount" - className="text-center text-lg font-medium" - /> -
- {PRESET_AMOUNTS.map((preset) => ( - - ))} -
-
-
- -
- - setPaymentMethod(value)} className="w-full"> - - - - Credit Card - - - - Lightning - - - -
- - -
-
-
- - {/* Transaction History Accordion */} - - -
- - Recent Transactions -
-
- -
- {isLoadingPayments ? ( -
-
- - - -
- -
- ) : !payments || payments.length === 0 ? ( -
- -

No transactions yet

-

Your payment history will appear here

-
- ) : ( -
- {payments.map((payment) => ( -
-
-
- {getStatusIcon(payment.status)} - - {payment.method === 'stripe' ? 'Credit Card' : 'Lightning'} - - - {payment.status} - -
-
-

{formatCurrency(payment.amount)}

- {payment.fee > 0 && ( -

- +{formatCurrency(payment.fee)} -

- )} -
-
- -
- {formatDate(payment.created_at)} - {payment.status === 'pending' && ( -
- - {payment.url && ( - - )} -
- )} -
-
- ))} -
- )} -
-
-
- - {/* Redeem Gift Card Accordion */} - - -
- - Redeem Gift Card -
-
- -
-
- setRedeemCode(e.target.value)} - placeholder="Enter gift card code" - className="flex-1" - /> - -
-
-
-
- - {/* Create Gift Card Accordion */} - - -
- - Create Gift Card -
-
- -
-
-
- - setGiftcardAmount(Number(e.target.value))} - placeholder="Amount" - className="text-center" - /> -
-
- - setGiftcardQuantity(Number(e.target.value))} - placeholder="Qty" - className="text-center" - /> -
-
+ +
+ + Buy Credits +
+
+ +
+
+ +
+ setAmount(Number(e.target.value))} + placeholder="Enter amount" + className="text-center text-lg font-medium" + />
{PRESET_AMOUNTS.map((preset) => ( ))}
-
- - +
- {/* Your Gift Cards Accordion */} - - -
- - Your Gift Cards +
+ + setPaymentMethod(value)} className="w-full"> + + + + Credit Card + + + + Lightning + + + +
+ + +
+ +
+ + {/* Transaction History Accordion */} + + +
+ + Recent Transactions +
+
+ +
+ {isLoadingPayments ? ( +
+
+ + + +
+
- - -
- {isLoadingGiftcards ? ( -
-
- - - + ) : !payments || payments.length === 0 ? ( +
+ +

No transactions yet

+

Your payment history will appear here

+
+ ) : ( +
+ {payments.map((payment) => ( +
+
+
+ {getStatusIcon(payment.status)} + + {payment.method === 'stripe' ? 'Credit Card' : 'Lightning'} + + + {payment.status} + +
+
+

{formatCurrency(payment.amount)}

+ {payment.fee > 0 && ( +

+ +{formatCurrency(payment.fee)} +

+ )} +
- -
- ) : !giftcards || giftcards.length === 0 ? ( -
- -

No gift cards yet

-

Create gift cards to share with others

-
- ) : ( -
- {giftcards.map((giftcard) => ( -
-
-
- - - Gift Card - - - {giftcard.redeemed ? 'Redeemed' : 'Active'} - -
-
-

{formatCurrency(giftcard.amount)}

-
-
-
- - {giftcard.code} - -
+
+ {formatDate(payment.created_at)} + {payment.status === 'pending' && ( +
+ + {payment.url && ( - {copiedCode === giftcard.code && ( -
- Copied! -
- )} -
+ )}
+ )} +
+
+ ))} +
+ )} +
+ + - {giftcard.created_at && ( -
- Created {formatDate(giftcard.created_at)} + {/* Redeem Gift Card Accordion */} + + +
+ + Redeem Gift Card +
+
+ +
+
+ setRedeemCode(e.target.value)} + placeholder="Enter gift card code" + className="flex-1" + /> + +
+
+
+
+ + {/* Create Gift Card Accordion */} + + +
+ + Create Gift Card +
+
+ +
+
+
+ + setGiftcardAmount(Number(e.target.value))} + placeholder="Amount" + className="text-center" + /> +
+
+ + setGiftcardQuantity(Number(e.target.value))} + placeholder="Qty" + className="text-center" + /> +
+
+
+ {PRESET_AMOUNTS.map((preset) => ( + + ))} +
+ +
+
+
+ + {/* Your Gift Cards Accordion */} + + +
+ + Your Gift Cards +
+
+ +
+ {isLoadingGiftcards ? ( +
+
+ + + +
+ +
+ ) : !giftcards || giftcards.length === 0 ? ( +
+ +

No gift cards yet

+

Create gift cards to share with others

+
+ ) : ( +
+ {giftcards.map((giftcard) => ( +
+
+
+ + + Gift Card + + + {giftcard.redeemed ? 'Redeemed' : 'Active'} + +
+
+

{formatCurrency(giftcard.amount)}

+
+
+ +
+ + {giftcard.code} + +
+ + {copiedCode === giftcard.code && ( +
+ Copied!
)}
- ))} +
+ + {giftcard.created_at && ( +
+ Created {formatDate(giftcard.created_at)} +
+ )}
- )} + ))}
- - + )} +
+
+
)}