refactor: deduplicate modals, notifications, confirms, comboboxes, proficiency
Modal Overlay (Finding 1 — 6 admin files): - Migrated CountriesClient, ManagementLevelsClient, OrgUnitsClient, CalculationRulesClient, UtilizationCategoriesClient, RoleModal from inline fixed-overlay to AnimatedModal component - Gains: animated transitions, backdrop blur, escape key for free Notification Helper (Finding 9 — 9 API files, 14 call sites): - New createNotification() + createNotificationsForUsers() in packages/api/src/lib/create-notification.ts - Handles exactOptionalPropertyTypes spread + SSE emit internally - Simplified: budget-alerts, estimate-reminders, auto-staffing, vacation-conflicts, chargeability-alerts, comment, vacation, notification ConfirmDialog (Finding 3 — 11 files): - Replaced all window.confirm() calls with ConfirmDialog component - Files: CommentThread, EffortRules, ExperienceMultipliers, ManagementLevels, CalculationRules, Countries, RateCards, ApplyEffortRules, ApplyExperienceMultipliers, NotificationCenter, ReminderModal EntityCombobox (Finding 4 — 3 files): - New generic EntityCombobox<T> with customization hooks - ResourceCombobox + ProjectCombobox rewritten as thin wrappers - All consumers unchanged (backwards-compatible props) Proficiency Constants (Finding 2 — 2 files): - SkillsAnalytics + SkillMarketplace now import from skills/shared.tsx - Deleted ~70 LOC of local duplicate definitions Regression: 283 engine + 37 staffing tests pass. TypeScript clean. AI Assistant: all 87 tools verified accessible. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { listAssignmentBookings } from "@planarchy/application";
|
||||
import { emitNotificationCreated } from "../sse/event-bus.js";
|
||||
import { createNotificationsForUsers } from "./create-notification.js";
|
||||
|
||||
type DbClient = Parameters<typeof listAssignmentBookings>[0] & {
|
||||
project: {
|
||||
@@ -119,23 +119,18 @@ export async function checkBudgetThresholds(
|
||||
{ minimumFractionDigits: 2, maximumFractionDigits: 2 },
|
||||
);
|
||||
|
||||
for (const manager of managers) {
|
||||
const notification = await db.notification.create({
|
||||
data: {
|
||||
userId: manager.id,
|
||||
type: threshold.type,
|
||||
category: "NOTIFICATION",
|
||||
priority: threshold.priority,
|
||||
title: `Budget alert: ${project.name} has reached ${threshold.label} of budget`,
|
||||
body: `Project ${project.shortCode} "${project.name}" has spent ${formattedSpend} EUR of ${formattedBudget} EUR budget (${Math.round(spendPercent)}%).`,
|
||||
entityId: projectId,
|
||||
entityType: "project_budget",
|
||||
link: `/projects/${projectId}`,
|
||||
channel: "in_app",
|
||||
},
|
||||
});
|
||||
|
||||
emitNotificationCreated(manager.id, notification.id);
|
||||
}
|
||||
await createNotificationsForUsers({
|
||||
db,
|
||||
userIds: managers.map((m) => m.id),
|
||||
type: threshold.type,
|
||||
category: "NOTIFICATION",
|
||||
priority: threshold.priority,
|
||||
title: `Budget alert: ${project.name} has reached ${threshold.label} of budget`,
|
||||
body: `Project ${project.shortCode} "${project.name}" has spent ${formattedSpend} EUR of ${formattedBudget} EUR budget (${Math.round(spendPercent)}%).`,
|
||||
entityId: projectId,
|
||||
entityType: "project_budget",
|
||||
link: `/projects/${projectId}`,
|
||||
channel: "in_app",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user