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:
ClaudeandClaude Opus 5.5 committed 2026-10-02 02:50:55 +00:00
1 parent a06c3bc8ef
commit 7d93ae0cd9
5 files changed
+129 -2

No files matched your search

+6 -2
View File
@@ -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')