Team-Eingang: Gutschriften, Angebote, E-Mail-Speicher und Funktionen fuer alle Mitarbeiter, Kundenfilter, Zaehlroute
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a06c3bc8ef
commit
7d93ae0cd9
5 files changed
+129
-2
No files matched your search
@@ -20,7 +20,7 @@ function sendError(res, err, fallback) {
|
||||
return res.status(status).json({ error: err.message || fallback })
|
||||
}
|
||||
|
||||
offersAdminRouter.get('/', async (_req, res) => {
|
||||
offersAdminRouter.get('/', async (req, res) => {
|
||||
try {
|
||||
const [docs, customers, subs] = await Promise.all([
|
||||
listOffers(),
|
||||
@@ -30,8 +30,12 @@ offersAdminRouter.get('/', async (_req, res) => {
|
||||
])
|
||||
const byId = new Map(customers.map((c) => [c.$id, c]))
|
||||
const subById = new Map(subs.map((s) => [s.$id, s]))
|
||||
// ?customerId= (Kunden-Reiter "Abo & Angebote" im Ticketsystem)
|
||||
const customerId = typeof req.query.customerId === 'string' ? req.query.customerId : ''
|
||||
return res.json({
|
||||
offers: docs.map((d) => adminOfferView(d, byId.get(d.customerId), subById.get(d.stripeSubscriptionId))),
|
||||
offers: docs
|
||||
.filter((d) => !customerId || d.customerId === customerId)
|
||||
.map((d) => adminOfferView(d, byId.get(d.customerId), subById.get(d.stripeSubscriptionId))),
|
||||
})
|
||||
} catch (err) {
|
||||
return sendError(res, err, 'Angebote konnten nicht geladen werden')
|
||||
|
||||
@@ -101,6 +101,15 @@ async function reconcileOpenSwitches() {
|
||||
}
|
||||
}
|
||||
|
||||
// Zahl offener Aufgaben fuer die Sidebar des Ticketsystems: ohne Wechsel-Abgleich (kein Stripe), jede Minute abgefragt
|
||||
storageTasksAdminRouter.get('/open-count', async (_req, res) => {
|
||||
try {
|
||||
return res.json({ open: (await listOpenStorageTasks()).length })
|
||||
} catch {
|
||||
return res.json({ open: 0 })
|
||||
}
|
||||
})
|
||||
|
||||
storageTasksAdminRouter.get('/', async (_req, res) => {
|
||||
try {
|
||||
await reconcileOpenSwitches()
|
||||
|
||||
@@ -124,7 +124,10 @@ takeoverAdminRouter.get('/', async (req, res) => {
|
||||
])
|
||||
const byId = new Map(customers.map((c) => [c.$id, c]))
|
||||
const onlyOpen = req.query.status !== 'all'
|
||||
// ?customerId= (Kunden-Reiter im Ticketsystem); openCount zaehlt weiter alle offenen Antraege
|
||||
const customerId = typeof req.query.customerId === 'string' ? req.query.customerId : ''
|
||||
const requests = docs
|
||||
.filter((d) => !customerId || d.customerId === customerId)
|
||||
.filter((d) => !onlyOpen || d.status === STATUS.open || d.status === STATUS.question)
|
||||
.map((d) => {
|
||||
const c = byId.get(d.customerId)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { Router } from 'express'
|
||||
import { requireStaffJwt } from '../../middleware/staffJwt.js'
|
||||
import { chatAdminRouter } from '../chatAdmin.js'
|
||||
import { funktionenAdminRouter } from '../admin/funktionenAdmin.js'
|
||||
import { offersAdminRouter } from '../offers.js'
|
||||
import { storageTasksAdminRouter } from '../storageTasks.js'
|
||||
import { takeoverAdminRouter } from '../takeoverCredits.js'
|
||||
import customersRoutes from './customers.js'
|
||||
import filesRoutes from './files.js'
|
||||
import previewRoutes from './preview.js'
|
||||
@@ -13,5 +17,10 @@ router.use(requireStaffJwt)
|
||||
router.use('/customers', customersRoutes)
|
||||
router.use('/preview-link', previewRoutes)
|
||||
router.use(chatAdminRouter)
|
||||
// Gutschriften, Abo-Angebote, E-Mail-Speicher, Funktionen: dieselben Router wie im Admin-Panel
|
||||
router.use('/takeover-credits', takeoverAdminRouter)
|
||||
router.use('/offers', offersAdminRouter)
|
||||
router.use('/storage-tasks', storageTasksAdminRouter)
|
||||
router.use('/funktionen', funktionenAdminRouter)
|
||||
|
||||
export default router
|
||||
Reference in new issue
Block a user