diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx
index 22214df5..5cc9fbc6 100644
--- a/app/(auth)/login/page.tsx
+++ b/app/(auth)/login/page.tsx
@@ -107,7 +107,9 @@ export default function LoginPage() {
document.cookie = 'gnubok-invite-token=; path=/; max-age=0'
}
- router.push('/')
+ // Always land on the picker after BankID login so the user sees
+ // fresh CompanyRoles fetched during this session's enrichment.
+ router.push('/select-company')
router.refresh()
} catch (error) {
console.error('[login] BankID complete error', error)
diff --git a/app/(auth)/register/page.tsx b/app/(auth)/register/page.tsx
index 09125f15..0e41c940 100644
--- a/app/(auth)/register/page.tsx
+++ b/app/(auth)/register/page.tsx
@@ -144,7 +144,7 @@ function RegisterPageContent() {
return
}
- router.push('/')
+ router.push('/select-company')
router.refresh()
} catch (error) {
console.error('[register] BankID signup error', error)
diff --git a/app/(dashboard)/layout.tsx b/app/(dashboard)/layout.tsx
index f9d2a1f7..448647ed 100644
--- a/app/(dashboard)/layout.tsx
+++ b/app/(dashboard)/layout.tsx
@@ -81,6 +81,7 @@ export default async function DashboardLayout({
companies: [],
isTeamMember,
team,
+ isSandbox: false,
}}
>
@@ -130,6 +131,7 @@ export default async function DashboardLayout({
})),
isTeamMember,
team,
+ isSandbox: false,
}
return (
@@ -179,6 +181,10 @@ export default async function DashboardLayout({
const displayName = settings?.company_name || companyRow.name
const companyWithName = { ...companyRow, name: displayName }
+ const entityType = (settings?.entity_type as EntityType) || 'enskild_firma'
+
+ const isSandbox = settings?.is_sandbox === true
+
const companyContextValue = {
company: companyWithName,
role: memberRow.role as CompanyRole,
@@ -192,12 +198,9 @@ export default async function DashboardLayout({
}),
isTeamMember,
team,
+ isSandbox,
}
- const entityType = (settings?.entity_type as EntityType) || 'enskild_firma'
-
- const isSandbox = settings?.is_sandbox === true
-
return (
diff --git a/components/ui/support-link.tsx b/components/ui/support-link.tsx
index 05021902..f1b1a235 100644
--- a/components/ui/support-link.tsx
+++ b/components/ui/support-link.tsx
@@ -1,6 +1,6 @@
'use client'
-import { useState, useEffect } from 'react'
+import { useState } from 'react'
import { cn } from '@/lib/utils'
import { Mail, Loader2, Send } from 'lucide-react'
import {
@@ -15,6 +15,8 @@ import {
import { Button } from '@/components/ui/button'
import { Textarea } from '@/components/ui/textarea'
import { useToast } from '@/components/ui/use-toast'
+import { submitFeedback } from '@/lib/support/submit-feedback'
+import { useCompanyOptional } from '@/contexts/CompanyContext'
interface SupportLinkProps {
variant?: 'inline' | 'muted'
@@ -29,48 +31,36 @@ export function SupportLink({
children,
className,
}: SupportLinkProps) {
- const [mounted, setMounted] = useState(false)
const [open, setOpen] = useState(false)
const [message, setMessage] = useState('')
const [isSending, setIsSending] = useState(false)
const [sent, setSent] = useState(false)
const { toast } = useToast()
+ const companyCtx = useCompanyOptional()
- useEffect(() => {
- setMounted(true)
- }, [])
+ if (companyCtx?.isSandbox) return null
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
if (message.trim().length < 5) return
setIsSending(true)
- try {
- const res = await fetch('/api/support/contact', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ subject, message: message.trim() }),
- })
-
- if (!res.ok) {
- const data = await res.json()
- throw new Error(data.error || 'Kunde inte skicka meddelandet')
- }
+ const result = await submitFeedback({ subject, message: message.trim() })
+ setIsSending(false)
+ if (result.ok) {
setSent(true)
setTimeout(() => {
setOpen(false)
setSent(false)
setMessage('')
}, 2000)
- } catch (error) {
+ } else {
toast({
title: 'Kunde inte skicka',
- description: error instanceof Error ? error.message : 'Försök igen.',
+ description: result.error || 'Försök igen.',
variant: 'destructive',
})
- } finally {
- setIsSending(false)
}
}
@@ -106,10 +96,6 @@ export function SupportLink({
)
- if (!mounted) {
- return trigger
- }
-
return (