fix(capa): filter owner dropdown by capa_owner role
Was filtering by non-null department, excluding capa_owner users who had no department set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BzvzV91UqHZKM9P58qtvrA
This commit is contained in:
@@ -7,7 +7,7 @@ Replaces WhatsApp/Excel safety reporting. Client: Ms. Agnes, Mr. Terence, Mr. Ya
|
||||
## Stack
|
||||
- **Frontend + API routes:** Next.js (App Router)
|
||||
- **DB + Auth + Storage:** Supabase (Postgres + RLS + pgvector)
|
||||
- **Hosting:** Vercel (frontend) + Supabase cloud
|
||||
- **Hosting:** VPS at `http://64.176.82.100/ims/` + Supabase cloud
|
||||
- **AI:** Claude API — server-side only, never client-side
|
||||
- **Email:** Resend
|
||||
- **WhatsApp:** Meta WhatsApp Business Cloud API
|
||||
|
||||
@@ -26,7 +26,7 @@ export default async function NewCapaPage({ params }: Props) {
|
||||
const { data: users } = await supabase
|
||||
.from('users')
|
||||
.select('id, name, department')
|
||||
.not('department', 'is', null)
|
||||
.eq('role', 'capa_owner')
|
||||
.order('name')
|
||||
|
||||
return (
|
||||
|
||||
@@ -60,8 +60,10 @@ export async function POST(request: NextRequest) {
|
||||
)
|
||||
newUserId = created.user.id
|
||||
} else {
|
||||
const appUrl = process.env.NEXT_PUBLIC_APP_URL ?? 'http://localhost:3000'
|
||||
const { data: invited, error: inviteError } = await admin.auth.admin.inviteUserByEmail(email, {
|
||||
data: { full_name: body.name ?? '' },
|
||||
redirectTo: `${appUrl}/api/auth/callback`,
|
||||
})
|
||||
if (inviteError || !invited?.user)
|
||||
return NextResponse.json({ error: inviteError?.message ?? 'Invite failed' }, { status: 500 })
|
||||
|
||||
Reference in New Issue
Block a user