Kundenansicht: Beenden mit Rueckweg ins Ticketsystem, /me mit Ansichts-Kennung, Team-Routen Portal-Status, Protokoll, Preview-Link
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d8ba56088
commit
c5afd42a5f
9 files changed
+284
-23
No files matched your search
@@ -1,11 +1,32 @@
|
||||
import { Router } from 'express'
|
||||
import { config } from '../../config.js'
|
||||
import { listViewLog } from '../../services/customerViewLog.js'
|
||||
import { getPortalAccessStatus } from '../../services/portalAccessStatus.js'
|
||||
import { createStaffPreviewToken } from '../../services/staffPreviewTokens.js'
|
||||
|
||||
// Kunden im Team-Eingang (/api/team/customers), requireStaffJwt sitzt in routes/team/index.js
|
||||
const router = Router()
|
||||
|
||||
// Portal-Zugang und letzter Login (Karte "Portal-Zugang" im Ticketsystem)
|
||||
router.get('/:id/portal', async (req, res) => {
|
||||
try {
|
||||
const { customer, hasAccess, lastLoginAt } = await getPortalAccessStatus(req.params.id)
|
||||
if (!customer) return res.status(404).json({ error: 'Kunde nicht gefunden' })
|
||||
return res.json({ hasAccess, lastLoginAt })
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: err.message || 'Portal-Zugang konnte nicht geladen werden' })
|
||||
}
|
||||
})
|
||||
|
||||
// Protokoll der Kundenansicht (Reiter "Protokoll"), neueste zuerst
|
||||
router.get('/:id/protokoll', async (req, res) => {
|
||||
try {
|
||||
return res.json({ entries: await listViewLog(req.params.id) })
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: err.message || 'Protokoll konnte nicht geladen werden' })
|
||||
}
|
||||
})
|
||||
|
||||
// Kundenansicht oeffnen: Einmal-Link (60 s), den das Ticketsystem in einem neuen Tab aufruft
|
||||
router.post('/:id/kundenansicht', async (req, res) => {
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { Router } from 'express'
|
||||
import { requireStaffJwt } from '../../middleware/staffJwt.js'
|
||||
import customersRoutes from './customers.js'
|
||||
import previewRoutes from './preview.js'
|
||||
|
||||
// Team-Eingang fuer das Ticketsystem: alle Mitarbeiter, Appwrite-JWT (Spec 2026-10-01 Admin-Panel ins Ticketsystem)
|
||||
const router = Router()
|
||||
router.use(requireStaffJwt)
|
||||
router.use('/customers', customersRoutes)
|
||||
router.use('/preview-link', previewRoutes)
|
||||
|
||||
export default router
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Router } from 'express'
|
||||
import { buildStaffPreviewLink } from '../admin/previewOpen.js'
|
||||
|
||||
// Preview aus dem Ticketsystem oeffnen (alle Mitarbeiter): Einmal-Link statt Mitarbeiter-Login im Portal
|
||||
const router = Router()
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
const { status, body } = await buildStaffPreviewLink({
|
||||
userId: req.staff.appwriteUserId,
|
||||
email: req.staff.email,
|
||||
name: req.staff.name,
|
||||
subdomain: req.body?.subdomain,
|
||||
previewUrl: req.body?.previewUrl,
|
||||
})
|
||||
return res.status(status).json(body)
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in new issue
Block a user