@@ -11,6 +11,7 @@ import { CommandExpiryJob } from '../jobs/command-expiry.job';
|
||||
import { createdFieldTimes } from '../stock/product-fields';
|
||||
import { checkConsistency } from './consistency';
|
||||
import { countReset, deleteVenue, lockVenue, resetVenue, ResetCounts, ResetScope } from './venue-reset';
|
||||
import { ensureDefaultCustomers } from '../planned-tabs/default-customers';
|
||||
import { PurgeTarget } from './dto/admin.dto';
|
||||
|
||||
/** The superadmin doing it. */
|
||||
@@ -18,7 +19,8 @@ export type Actor = { id: string; email: string; name: string; venueId: string }
|
||||
|
||||
// What each reset scope changes on the dashboard
|
||||
const SCOPE_TOPICS: Record<ResetScope, RealtimeTopic[]> = {
|
||||
tabs: ['tabs'],
|
||||
// Plans the Free Drinks customer again
|
||||
tabs: ['tabs', 'planned-tabs'],
|
||||
settlements: ['tabs'],
|
||||
tabEvents: [],
|
||||
plannedTabs: ['planned-tabs', 'reminders'],
|
||||
@@ -92,7 +94,11 @@ export class AdminService {
|
||||
}
|
||||
|
||||
async createVenue(name: string, actor: Actor) {
|
||||
const venue = await this.prisma.venue.create({ data: { name: name.trim() } });
|
||||
const venue = await this.prisma.$transaction(async (tx) => {
|
||||
const created = await tx.venue.create({ data: { name: name.trim() } });
|
||||
await ensureDefaultCustomers(tx, created.id);
|
||||
return created;
|
||||
});
|
||||
await this.audit.log(venue.id, 'client_user', actor.id, 'admin_venue_created', { name: venue.name, by: actor.email });
|
||||
return venue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user