Add agent level progression and extend backend services.
Introduce agent level utilities/service, expand auth and notification flows, update category definitions and seed data, and wire level-aware order and suggestion handling.
This commit is contained in:
+39
-2
@@ -133240,6 +133240,25 @@ var require_notifications_service = __commonJS({
|
||||
dispatchAdmin(input) {
|
||||
void this.notifyAdmin(input);
|
||||
}
|
||||
async notifyCustomer(input) {
|
||||
try {
|
||||
await this.prisma.customerNotification.create({
|
||||
data: {
|
||||
customerId: input.customerId,
|
||||
event: input.event,
|
||||
title: input.title.trim(),
|
||||
body: input.body.trim(),
|
||||
tone: input.tone ?? client_1.NotificationTone.info,
|
||||
link: input.link ?? null
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.error(`notifyCustomer(${input.event}) failed for customer ${input.customerId}`, err instanceof Error ? err.stack : err);
|
||||
}
|
||||
}
|
||||
dispatchCustomer(input) {
|
||||
void this.notifyCustomer(input);
|
||||
}
|
||||
async listForCustomer(customerId, limit = 50) {
|
||||
const rows = await this.prisma.customerNotification.findMany({
|
||||
where: { customerId },
|
||||
@@ -139500,14 +139519,18 @@ var require_suggestions_service = __commonJS({
|
||||
Object.defineProperty(exports2, "__esModule", { value: true });
|
||||
exports2.SuggestionsService = void 0;
|
||||
var common_12 = require_common();
|
||||
var client_1 = require_default2();
|
||||
var notifications_service_1 = require_notifications_service();
|
||||
var prisma_service_1 = require_prisma_service();
|
||||
var SuggestionsService = class SuggestionsService {
|
||||
static {
|
||||
__name(this, "SuggestionsService");
|
||||
}
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
notifications;
|
||||
constructor(prisma, notifications) {
|
||||
this.prisma = prisma;
|
||||
this.notifications = notifications;
|
||||
}
|
||||
async listAdmin(customerId) {
|
||||
const rows = await this.prisma.productSuggestion.findMany({
|
||||
@@ -139549,6 +139572,15 @@ var require_suggestions_service = __commonJS({
|
||||
product: { select: { name: true, code: true, color: true } }
|
||||
}
|
||||
});
|
||||
const note = row.note?.trim();
|
||||
this.notifications.dispatchCustomer({
|
||||
customerId: input.customerId,
|
||||
event: "product_suggestion",
|
||||
title: "\u067E\u06CC\u0634\u0646\u0647\u0627\u062F \u0645\u062D\u0635\u0648\u0644 \u0628\u0631\u0627\u06CC \u0634\u0645\u0627",
|
||||
body: note ? `\u06A9\u0627\u0631\u0634\u0646\u0627\u0633\u0627\u0646 \u0645\u0627 \u0645\u062D\u0635\u0648\u0644 \xAB${row.product.name}\xBB \u0631\u0627 \u0628\u0647 \u0634\u0645\u0627 \u067E\u06CC\u0634\u0646\u0647\u0627\u062F \u062F\u0627\u062F\u0647\u200C\u0627\u0646\u062F: ${note}` : `\u06A9\u0627\u0631\u0634\u0646\u0627\u0633\u0627\u0646 \u0645\u0627 \u0645\u062D\u0635\u0648\u0644 \xAB${row.product.name}\xBB \u0631\u0627 \u0628\u0647 \u0634\u0645\u0627 \u067E\u06CC\u0634\u0646\u0647\u0627\u062F \u062F\u0627\u062F\u0647\u200C\u0627\u0646\u062F.`,
|
||||
tone: client_1.NotificationTone.info,
|
||||
link: `/product?id=${input.productId}`
|
||||
});
|
||||
return this.map(row);
|
||||
}
|
||||
async setActive(id, isActive) {
|
||||
@@ -139596,7 +139628,10 @@ var require_suggestions_service = __commonJS({
|
||||
exports2.SuggestionsService = SuggestionsService;
|
||||
exports2.SuggestionsService = SuggestionsService = __decorate2([
|
||||
(0, common_12.Injectable)(),
|
||||
__metadata2("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
__metadata2("design:paramtypes", [
|
||||
prisma_service_1.PrismaService,
|
||||
notifications_service_1.NotificationsService
|
||||
])
|
||||
], SuggestionsService);
|
||||
}
|
||||
});
|
||||
@@ -139738,6 +139773,7 @@ var require_suggestions_module = __commonJS({
|
||||
Object.defineProperty(exports2, "__esModule", { value: true });
|
||||
exports2.SuggestionsModule = void 0;
|
||||
var common_12 = require_common();
|
||||
var notifications_module_1 = require_notifications_module();
|
||||
var suggestions_controller_1 = require_suggestions_controller();
|
||||
var suggestions_service_1 = require_suggestions_service();
|
||||
var SuggestionsModule = class SuggestionsModule {
|
||||
@@ -139748,6 +139784,7 @@ var require_suggestions_module = __commonJS({
|
||||
exports2.SuggestionsModule = SuggestionsModule;
|
||||
exports2.SuggestionsModule = SuggestionsModule = __decorate2([
|
||||
(0, common_12.Module)({
|
||||
imports: [notifications_module_1.NotificationsModule],
|
||||
controllers: [suggestions_controller_1.SuggestionsController],
|
||||
providers: [suggestions_service_1.SuggestionsService],
|
||||
exports: [suggestions_service_1.SuggestionsService]
|
||||
|
||||
Reference in New Issue
Block a user