proper user/session creation and auth integration into UI
This commit is contained in:
@@ -143,6 +143,13 @@ export default function HomePage() {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ prompt: aiPrompt })
|
||||
})
|
||||
|
||||
if (res.status === 401) {
|
||||
alert('Please sign in to use AI features.')
|
||||
setAiLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const data = await res.json()
|
||||
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
@@ -225,25 +232,32 @@ export default function HomePage() {
|
||||
<div className='max-w-fit m-auto'> Drag & Drop *.ics here</div>
|
||||
</div>
|
||||
{/* AI Toolbar */}
|
||||
<div className="flex flex-row gap-4 mb-4 items-start">
|
||||
{session?.user && (
|
||||
<>
|
||||
<div className='w-full'>
|
||||
<Textarea
|
||||
className="wrap-anywhere min-h-12"
|
||||
placeholder='Describe event for AI to create'
|
||||
value={aiPrompt}
|
||||
onChange={e => setAiPrompt(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex flex-row gap-2 pt-1.5'>
|
||||
<Button onClick={handleAiCreate} disabled={aiLoading}>
|
||||
{aiLoading ? 'Thinking...' : 'AI Create'}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{session?.user ? (
|
||||
<div className="flex flex-row gap-4 mb-4 items-start">
|
||||
<div className='w-full'>
|
||||
<Textarea
|
||||
className="wrap-anywhere min-h-12"
|
||||
placeholder='Describe event for AI to create'
|
||||
value={aiPrompt}
|
||||
onChange={e => setAiPrompt(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex flex-row gap-2 pt-1.5'>
|
||||
<Button onClick={handleAiCreate} disabled={aiLoading}>
|
||||
{aiLoading ? 'Thinking...' : 'AI Create'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="mb-4 p-4 border border-dashed rounded-lg text-center">
|
||||
<div className="text-sm text-muted-foreground mb-2">
|
||||
Sign in to unlock AI-powered calendar features
|
||||
</div>
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<a href="/signin">Sign In</a>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Summary Panel */}
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user