From 1101573d20935b791277cca3ca0d3e82d0c22e0f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 26 Oct 2025 20:44:20 -0500 Subject: [PATCH] Reorganize credits dialog into accordions --- src/components/CreditsDialog.tsx | 560 ++++++++++++++++--------------- 1 file changed, 289 insertions(+), 271 deletions(-) diff --git a/src/components/CreditsDialog.tsx b/src/components/CreditsDialog.tsx index 118b6081..5b30e668 100644 --- a/src/components/CreditsDialog.tsx +++ b/src/components/CreditsDialog.tsx @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import QRCode from 'qrcode'; -import { CreditCard, Zap, ExternalLink, RefreshCw, Check, X, Clock, AlertCircle, Copy, RotateCcw, ArrowLeft, Gift } from 'lucide-react'; +import { CreditCard, Zap, ExternalLink, RefreshCw, Check, X, Clock, AlertCircle, Copy, RotateCcw, ArrowLeft, Gift, Plus, History, DollarSign } from 'lucide-react'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; @@ -10,6 +10,7 @@ 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 { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; import { useToast } from '@/hooks/useToast'; import { createAIClient } from '@/lib/ai-client'; import { useCurrentUser } from '@/hooks/useCurrentUser'; @@ -611,198 +612,217 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro {/* Buy Credits Tab */} - - {/* Add Credits Form - Fixed size section */} -
-
- -
- setAmount(Number(e.target.value))} - placeholder="Enter amount" - className="text-center text-lg font-medium" - /> -
- {PRESET_AMOUNTS.map((preset) => ( - - ))} + + + {/* Buy Credits Accordion */} + + +
+ + Buy Credits
-
-
- -
- - setPaymentMethod(value)} className="w-full"> - - - - Credit Card - - - - Lightning - - - -
- - -
- -
- -
- - {/* Transaction History - Flexible section */} -
-
-

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 && ( - - )} -
- )} + + +
+
+ +
+ 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 && ( + + )} +
+ )} +
+
+ ))} +
+ )} +
+
+
+ {/* Gift Cards Tab */} - -
- {/* Redeem Gift Card Section */} -
-
- -
- setRedeemCode(e.target.value)} - placeholder="Enter gift card code" - className="flex-1" - /> - + + + {/* Redeem Gift Card Accordion */} + + +
+ + Redeem Gift Card
-
-
+ + +
+
+ setRedeemCode(e.target.value)} + placeholder="Enter gift card code" + className="flex-1" + /> + +
+
+
+ -
- -
- - {/* Create Gift Card Section */} -
-
- -
+ {/* Create Gift Card Accordion */} + + +
+ + Create Gift Card +
+
+ +
@@ -843,104 +863,102 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro ))}
+
-
+
+
- -
- -
- -
- - {/* Gift Cards List */} -
-
-

Your Gift Cards

-
-
- {isLoadingGiftcards ? ( -
-
- - - + {/* Your Gift Cards Accordion */} + + +
+ + Your Gift Cards +
+
+ +
+ {isLoadingGiftcards ? ( +
+
+ + + +
+
- -
- ) : !giftcards || giftcards.length === 0 ? ( -
-
+ ) : !giftcards || giftcards.length === 0 ? ( +

No gift cards yet

Create gift cards to share with others

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

{formatCurrency(giftcard.amount)}

+
-
-

{formatCurrency(giftcard.amount)}

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