diff --git a/src/components/Act1Dialog.tsx b/src/components/Act1Dialog.tsx index 5cfaf736..2195af7d 100644 --- a/src/components/Act1Dialog.tsx +++ b/src/components/Act1Dialog.tsx @@ -6,6 +6,7 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { useAISettings } from '@/hooks/useAISettings'; +import { useAICredits } from '@/hooks/useAICredits'; import { useLocalStorage } from '@/hooks/useLocalStorage'; interface Act1DialogProps { @@ -13,7 +14,7 @@ interface Act1DialogProps { onOpenChange: (open: boolean) => void; } -type DialogStep = 'welcome' | 'migration' | 'conclusion'; +type DialogStep = 'welcome' | 'migration' | 'credits' | 'conclusion'; const SHAKESPEARE_PROVIDER = { id: "shakespeare", @@ -22,7 +23,6 @@ const SHAKESPEARE_PROVIDER = { }; const MKSTACK_NSP_ADDR = '31999:4bcaa7b5606e3c14df05cd497e588f5d3fe559b4e9a425e8b418a43af1ffb015:mkstack'; -const MKSTACK_NSP_FREE_ADDR = '31999:8c68ce13a4a4a178ba95cbca8a759b31fe95c4b6e61fa1a7f6ad2e751458f49:mkstack'; export function Act1Dialog({ open, onOpenChange }: Act1DialogProps) { const [step, setStep] = useState('welcome'); @@ -32,6 +32,9 @@ export function Act1Dialog({ open, onOpenChange }: Act1DialogProps) { // Get the selectedNSPAddr from localStorage const [selectedNSPAddr] = useLocalStorage('selectedNSPAddr', null); + // Get user's credits + const { data: creditsData } = useAICredits(SHAKESPEARE_PROVIDER); + const handleGetStarted = async () => { setIsSettingUp(true); @@ -39,12 +42,15 @@ export function Act1Dialog({ open, onOpenChange }: Act1DialogProps) { // Add Shakespeare provider to their config setProvider(SHAKESPEARE_PROVIDER); - // Configure recently used models based on their Act 1 NSP - if (selectedNSPAddr === MKSTACK_NSP_ADDR) { - // MKStack NSP - set to shakespeare model + // Configure recently used models based on credits or NSP + const hasCredits = creditsData?.amount && creditsData.amount > 0; + const hasMKStackNSP = selectedNSPAddr === MKSTACK_NSP_ADDR; + + if (hasCredits || hasMKStackNSP) { + // User has credits or MKStack NSP - set to shakespeare model updateSettings({ recentlyUsedModels: ['shakespeare/shakespeare'] }); - } else if (selectedNSPAddr === MKSTACK_NSP_FREE_ADDR) { - // MKStack NSP Free - set to tybalt model + } else { + // No credits - set to tybalt model (free) updateSettings({ recentlyUsedModels: ['shakespeare/tybalt'] }); } @@ -58,6 +64,10 @@ export function Act1Dialog({ open, onOpenChange }: Act1DialogProps) { }; const handleContinue = () => { + setStep('credits'); + }; + + const handleCreditsNext = () => { setStep('conclusion'); }; @@ -94,7 +104,7 @@ export function Act1Dialog({ open, onOpenChange }: Act1DialogProps) { )} - {step === 'conclusion' && ( + {step === 'credits' && ( )} + {step === 'conclusion' && ( + + )} {step === 'welcome' && 'Welcome to Shakespeare: Act 2! 🎭'} {step === 'migration' && 'Migrating Your Projects'} + {step === 'credits' && 'Your Credits'} {step === 'conclusion' && "You're All Set!"} @@ -260,23 +281,7 @@ export function Act1Dialog({ open, onOpenChange }: Act1DialogProps) { - - - - 💳 - Your Credits - - - -

- Your Act 1 credits are still available through the Shakespeare AI provider. - We've automatically configured this for you! -

- - Credits Available - -
-
+
@@ -291,6 +296,63 @@ export function Act1Dialog({ open, onOpenChange }: Act1DialogProps) {
)} + {step === 'credits' && ( +
+
💳
+
+

Your Credits

+

+ Your Act 1 credits are still available through the Shakespeare AI provider. +

+
+ + + + {creditsData?.amount && creditsData.amount > 0 ? ( +
+
+
+ ${creditsData.amount.toFixed(2)} +
+

+ Available credits +

+
+
+

+ ✅ You're all set! We've configured the premium Shakespeare model for you. +

+
+
+ ) : ( +
+
+
🆓
+

Free Access

+
+
+

+ You can continue using Shakespeare for free with the Tybalt model. + It's perfect for learning and building amazing projects! +

+
+
+ )} +
+
+ +
+ +
+
+ )} + {step === 'conclusion' && (
🎉