44import { supabase } from "@/lib/supabase" ;
55import { v4 as uuidv4 } from "uuid" ;
66import { useEffect , useRef , useState } from "react" ;
7- import { Brand } from "@/lib/supabase/brands" ;
7+
88import { Check } from "lucide-react" ;
99import { Button } from "@/components/ui/button" ;
10- import { LoadingState } from "@/components/loading-state" ;
11- import Stripe from "stripe" ;
12- import { useRouter , useSearchParams } from "next/navigation" ;
10+ import { useRouter } from "next/navigation" ;
1311import { UserSubscription } from "@/hooks/useAuth" ;
1412import { User } from "@supabase/supabase-js" ;
1513import { toast } from "sonner" ;
@@ -44,6 +42,7 @@ import { countries } from "@/lib/countries";
4442import { plans } from "@/lib/utils" ;
4543import { INDUSTRIES } from "@/lib/utils" ;
4644import ShinyText from "@/components/ui/shiny-text" ;
45+ import { KeywordAnalysisResults } from "@/components/keywords/keyword-analysis-results" ;
4746
4847// Personal email domains to block
4948const PERSONAL_EMAIL_DOMAINS = [
@@ -60,6 +59,23 @@ type FormData = {
6059 location : string ;
6160} ;
6261
62+ type KeywordData = {
63+ conversational_keyword : string ;
64+ intent : string ;
65+ google_seed_keyword : string ;
66+ category : string ;
67+ search_volume : number ;
68+ competition_index : number ;
69+ low_cpc : string ;
70+ trend_6m : string ;
71+ relevance_score : number ;
72+ } ;
73+
74+ type KeywordAnalysisResultsProps = {
75+ keywords : Record < string , KeywordData > ;
76+ metadata : Array < { language : string ; country : string } > ;
77+ } ;
78+
6379export default function OnboardingPage ( ) {
6480 const router = useRouter ( ) ;
6581 const [ onboardingStep , setOnboardingStep ] = useState ( 0 ) ;
@@ -86,10 +102,9 @@ export default function OnboardingPage() {
86102 ) ;
87103 const [ subLoading , setSubLoading ] = useState ( false ) ;
88104 const [ isAnalyzing , setIsAnalyzing ] = useState ( false ) ;
89- const [ keywordResults , setKeywordResults ] = useState < Record < string , { keywords ?: string [ ] } > | null > ( null ) ;
105+ const [ keywordResults , setKeywordResults ] = useState < KeywordAnalysisResultsProps | null > ( null ) ;
90106 const [ selectedKeyword , setSelectedKeyword ] = useState < string > ( "" ) ;
91- const step = useSearchParams ( ) ;
92- const currentStep = step . get ( "step" ) || 0 ;
107+
93108
94109 const [ formData , setFormData ] = useState < FormData > ( {
95110 businessBrief : "" ,
@@ -885,34 +900,15 @@ export default function OnboardingPage() {
885900
886901 { keywordResults ? (
887902 < div className = "max-w-4xl mx-auto" >
888- < div className = "mb-8" >
903+ < div className = "mb-8 items-center justify-center flex flex-col " >
889904 < h3 className = "text-xl font-semibold mb-4" > Analysis Results</ h3 >
890- < div className = "grid gap-4 mb-8" >
891- { Object . entries ( keywordResults ) . map ( ( [ sessionId , data ] ) => (
892- < div key = { sessionId } className = "bg-zinc-800/50 rounded-lg p-6" >
893- < div className = "grid gap-3" >
894- { data . keywords ?. map ( ( keyword : string , index : number ) => (
895- < div
896- key = { index }
897- className = { `flex items-center justify-between p-4 rounded-lg border-2 cursor-pointer transition-all ${
898- selectedKeyword === keyword
899- ? 'border-blue-500 bg-blue-500/10'
900- : 'border-zinc-700 bg-zinc-800/50 hover:border-zinc-500'
901- } `}
902- onClick = { ( ) => setSelectedKeyword ( keyword ) }
903- >
904- < div className = "flex items-center gap-3" >
905- < div className = { `w-4 h-4 rounded-full border-2 ${
906- selectedKeyword === keyword ? 'bg-blue-500 border-blue-500' : 'border-zinc-400'
907- } `} > </ div >
908- < span > { keyword } </ span >
909- </ div >
910- </ div >
911- ) ) }
912- </ div >
913- </ div >
914- ) ) }
915- </ div >
905+
906+ < KeywordAnalysisResults
907+ keywords = { keywordResults . keywords }
908+ metadata = { keywordResults . metadata }
909+ limit = { 10 }
910+ />
911+
916912 </ div >
917913
918914 < div className = "flex gap-4 justify-center" >
@@ -924,10 +920,9 @@ export default function OnboardingPage() {
924920 </ Button >
925921 < Button
926922 onClick = { ( ) => setOnboardingStep ( 4 ) }
927- disabled = { ! selectedKeyword }
928923 className = "bg-blue-600 hover:bg-blue-700"
929924 >
930- Continue with Selected Keyword
925+ Continue
931926 </ Button >
932927 </ div >
933928 </ div >
0 commit comments