feat: Implement mobile application and lead processing utilities.
This commit is contained in:
23
innungsapp/apps/admin/app/api/push-token/route.ts
Normal file
23
innungsapp/apps/admin/app/api/push-token/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { auth } from '@/lib/auth'
|
||||
import { prisma } from '@innungsapp/shared'
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const session = await auth.api.getSession({ headers: req.headers })
|
||||
if (!session?.user) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
const { token } = await req.json()
|
||||
if (!token || typeof token !== 'string') {
|
||||
return NextResponse.json({ error: 'Invalid token' }, { status: 400 })
|
||||
}
|
||||
|
||||
// Store push token on the member record
|
||||
await prisma.member.updateMany({
|
||||
where: { userId: session.user.id },
|
||||
data: { pushToken: token },
|
||||
})
|
||||
|
||||
return NextResponse.json({ success: true })
|
||||
}
|
||||
Reference in New Issue
Block a user