17b9006b88
Build pitch-deck / build-push-deploy (push) Successful in 1m55s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 36s
CI / test-python-voice (push) Successful in 35s
CI / test-bqas (push) Successful in 35s
- Add English email template variants (greeting, message, closing, subject, CTA copy) - Add `preferred_lang` column to `pitch_investors` — stored per investor, deck opens in that language by default - Invite form: DE/EN language toggle that switches email defaults and pitch language setting - Invite form: "Send email" toggle — when off, creates investor + returns magic link without sending email (for cold outreach attachment) - `app/page.tsx`: initializes pitch language from investor's `preferred_lang` before first render (no flash) - Migration 007 added to `/api/admin/migrate` route for production rollout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
997 B
TypeScript
46 lines
997 B
TypeScript
'use client'
|
|
|
|
import { useState, useEffect, useCallback } from 'react'
|
|
|
|
export interface Investor {
|
|
id: string
|
|
email: string
|
|
name: string | null
|
|
company: string | null
|
|
status: string
|
|
last_login_at: string | null
|
|
login_count: number
|
|
created_at: string
|
|
is_showcase: boolean
|
|
preferred_lang: 'de' | 'en'
|
|
}
|
|
|
|
export function useAuth() {
|
|
const [investor, setInvestor] = useState<Investor | null>(null)
|
|
const [loading, setLoading] = useState(true)
|
|
|
|
useEffect(() => {
|
|
async function fetchMe() {
|
|
try {
|
|
const res = await fetch('/api/auth/me')
|
|
if (res.ok) {
|
|
const data = await res.json()
|
|
setInvestor(data.investor)
|
|
}
|
|
} catch {
|
|
// Not authenticated
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}
|
|
fetchMe()
|
|
}, [])
|
|
|
|
const logout = useCallback(async () => {
|
|
await fetch('/api/auth/logout', { method: 'POST' })
|
|
window.location.href = '/auth'
|
|
}, [])
|
|
|
|
return { investor, loading, logout }
|
|
}
|