@@ -6,28 +6,44 @@ import { PLANS, getPlan, isWithinDailyLimit, isWithinTotalLimit } from "@/lib/pl
66import Link from "next/link" ;
77
88type Platform = "x" | "facebook" | "instagram" | "linkedin" ;
9- type PostStatus = "draft " | "published " ;
9+ type Tone = "professional " | "casual" | "witty" | "inspirational" | "urgent ";
1010
1111interface Post {
1212 id : string ;
1313 platform : Platform ;
1414 prompt : string ;
1515 content : string ;
16- status : PostStatus ;
16+ status : "draft" | "published" ;
1717 createdAt : string ;
1818}
1919
20+ interface UserMeta {
21+ dailyPostsUsed : number ;
22+ plan : string ;
23+ name ?: string ;
24+ email ?: string ;
25+ }
26+
2027const PLATFORM_ICONS : Record < Platform , string > = {
2128 x : "𝕏" ,
2229 facebook : "f" ,
2330 instagram : "◈" ,
2431 linkedin : "in" ,
2532} ;
2633
34+ const TONES : { value : Tone ; label : string } [ ] = [
35+ { value : "professional" , label : "Professional" } ,
36+ { value : "casual" , label : "Casual" } ,
37+ { value : "witty" , label : "Witty" } ,
38+ { value : "inspirational" , label : "Inspirational" } ,
39+ { value : "urgent" , label : "Urgent" } ,
40+ ] ;
41+
2742export default function DashboardPage ( ) {
2843 const { data : session } = useSession ( ) ;
2944 const [ tab , setTab ] = useState < "generate" | "saved" > ( "generate" ) ;
3045 const [ platform , setPlatform ] = useState < Platform > ( "x" ) ;
46+ const [ tone , setTone ] = useState < Tone > ( "professional" ) ;
3147 const [ prompt , setPrompt ] = useState ( "" ) ;
3248 const [ generated , setGenerated ] = useState ( "" ) ;
3349 const [ generating , setGenerating ] = useState ( false ) ;
@@ -106,7 +122,8 @@ export default function DashboardPage() {
106122 ) ;
107123 }
108124
109- const dailyUsed = ( session . user as any ) ?. dailyPostsUsed ?? 0 ;
125+ const userMeta = session . user as unknown as UserMeta ;
126+ const dailyUsed = userMeta ?. dailyPostsUsed ?? 0 ;
110127 const remaining = isWithinDailyLimit ( plan , dailyUsed )
111128 ? ( plan . dailyPostLimit === - 1 ? Infinity : plan . dailyPostLimit - dailyUsed )
112129 : 0 ;
@@ -141,7 +158,7 @@ export default function DashboardPage() {
141158 </ span >
142159 </ div >
143160
144- < div className = "flex gap-2" >
161+ < div className = "flex gap-2 flex-wrap " >
145162 { ( [ "x" , "linkedin" , "instagram" , "facebook" ] as Platform [ ] ) . map ( p => (
146163 < button key = { p } onClick = { ( ) => setPlatform ( p ) }
147164 className = { `px-3 py-1.5 rounded-lg text-xs transition-all ${ platform === p ? "bg-gold-500/15 text-gold-500 border border-gold-500/30" : "text-[#5a5870] border border-white/[0.06]" } ` } >
@@ -150,6 +167,13 @@ export default function DashboardPage() {
150167 ) ) }
151168 </ div >
152169
170+ < select value = { tone } onChange = { e => setTone ( e . target . value as Tone ) }
171+ className = "w-full rounded-xl border border-white/[0.1] bg-white/[0.03] px-4 py-3 text-sm text-[#e8e6f0] outline-none focus:border-gold-500/40" >
172+ { TONES . map ( t => (
173+ < option key = { t . value } value = { t . value } className = "bg-bg" > { t . label } </ option >
174+ ) ) }
175+ </ select >
176+
153177 < textarea value = { prompt } onChange = { e => setPrompt ( e . target . value ) }
154178 placeholder = "What do you want to post about?"
155179 rows = { 3 }
@@ -176,6 +200,17 @@ export default function DashboardPage() {
176200 className = "text-xs px-3 py-1.5 rounded-lg bg-teal-500/10 text-teal-400 border border-teal-500/20" >
177201 { saving ? "Saving..." : saveSuccess ? "Saved!" : "Save" }
178202 </ button >
203+ < button onClick = { ( ) => {
204+ const blob = new Blob ( [ generated ] , { type : "text/plain" } ) ;
205+ const a = document . createElement ( "a" ) ;
206+ a . href = URL . createObjectURL ( blob ) ;
207+ a . download = platform + "-post.txt" ;
208+ a . click ( ) ;
209+ URL . revokeObjectURL ( a . href ) ;
210+ } }
211+ className = "text-xs px-3 py-1.5 rounded-lg bg-violet-500/10 text-violet-400 border border-violet-500/20" >
212+ Export
213+ </ button >
179214 </ div >
180215 </ div >
181216 ) }
0 commit comments