chore(release): v2.4.35 — lint cleanup (68→0) + duplicate-Zavřít modal fix
UI fix:
- Close-only modals showing a redundant second close button now use
hideCancel: ReceivedInvoices paid-detail modal (was two identical "Zavřít"
buttons) and PlanCellModal "Den je součástí rozsahu".
- Add modal-duplicate-close test enforcing close-only modals set hideCancel.
Lint: cleared all 68 warnings → 0.
- preserve-caught-error: attach { cause } in ai.service / exchange-rates.
- no-require-imports: package.json version read via fs (APP_VERSION) instead
of require(), avoiding a rootDir-expanding static JSON import.
- react-hooks/exhaustive-deps (11): ref-in-cleanup copies, derived-value
useMemo wrapping, PlanGrid field extraction, stable nextKey useCallback,
AuthContext documented cycle-break.
- no-explicit-any (53): precise route param/Prisma types, generic enrich*()
preserving payload shape, minimal vite module type, frontend body/query-key
types, SystemInfo for Settings.
Refactor (test enablement): shift-form types moved to dependency-free
shiftFormTypes.ts so the print-HTML builders are unit-testable without the
component graph; characterization test pins their output.
Gates: 649 tests pass, tsc -b clean, lint 0. Verified touched flows live
via Playwright (PlanWork CRUD + optimistic cache, warehouse form keys,
Settings system info, invoice detail).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ import type {
|
||||
ProjectLog,
|
||||
Project,
|
||||
User,
|
||||
} from "../components/ShiftFormModal";
|
||||
} from "../components/shiftFormTypes";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Types
|
||||
@@ -344,14 +344,25 @@ function escapeHtml(str: string): string {
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function buildProjectLogsHtml(record: Record<string, any>): string {
|
||||
/** Shape of the print endpoint payload consumed by the HTML builders. */
|
||||
interface PrintData {
|
||||
month: string;
|
||||
month_name: string;
|
||||
selected_user_name?: string | null;
|
||||
user_totals: Record<string, UserTotal>;
|
||||
}
|
||||
|
||||
export function buildProjectLogsHtml(record: AttendanceRecord): string {
|
||||
if (record.project_logs && record.project_logs.length > 0) {
|
||||
return record.project_logs
|
||||
.map((log: any) => {
|
||||
.map((log) => {
|
||||
let h: number, m: number;
|
||||
if (log.hours !== null && log.hours !== undefined) {
|
||||
h = parseInt(log.hours) || 0;
|
||||
m = parseInt(log.minutes) || 0;
|
||||
// hours/minutes arrive as string or number — String() before parseInt
|
||||
// (parseInt already coerces to string internally, so this is a no-op
|
||||
// at runtime, it just satisfies parseInt's string parameter type).
|
||||
h = parseInt(String(log.hours)) || 0;
|
||||
m = parseInt(String(log.minutes)) || 0;
|
||||
} else if (log.started_at && log.ended_at) {
|
||||
const mins = Math.max(
|
||||
0,
|
||||
@@ -374,13 +385,13 @@ function buildProjectLogsHtml(record: Record<string, any>): string {
|
||||
return escapeHtml(record.project_name || "—");
|
||||
}
|
||||
|
||||
function buildUserSectionHtml(
|
||||
export function buildUserSectionHtml(
|
||||
userId: string,
|
||||
userData: Record<string, any>,
|
||||
printData: Record<string, any>,
|
||||
userData: UserTotal,
|
||||
printData: PrintData,
|
||||
): string {
|
||||
// Build a date-keyed lookup of the user's records.
|
||||
const recordsByDate = new Map<string, Record<string, any>>();
|
||||
const recordsByDate = new Map<string, AttendanceRecord>();
|
||||
for (const r of userData.records || []) {
|
||||
recordsByDate.set(normalizeDateStr(r.shift_date), r);
|
||||
}
|
||||
@@ -391,7 +402,7 @@ function buildUserSectionHtml(
|
||||
const mo = parseInt(monthStr, 10);
|
||||
const daysInMonth = getDaysInMonth(yr, mo);
|
||||
|
||||
const userRecords = (userData.records || []) as Record<string, any>[];
|
||||
const userRecords = userData.records ?? [];
|
||||
|
||||
const rows: string[] = [];
|
||||
for (let d = 1; d <= daysInMonth; d++) {
|
||||
@@ -588,8 +599,8 @@ function buildUserSectionHtml(
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function buildPrintHtml(
|
||||
pData: Record<string, any>,
|
||||
export function buildPrintHtml(
|
||||
pData: PrintData,
|
||||
userSections: string,
|
||||
emptyMsg: string,
|
||||
filterNote: string,
|
||||
@@ -1330,7 +1341,7 @@ export default function useAttendanceAdmin({ alert }: AlertContext) {
|
||||
const pData = result.data;
|
||||
const userSections = Object.entries(pData.user_totals)
|
||||
.map(([uid, uData]) =>
|
||||
buildUserSectionHtml(uid, uData as Record<string, any>, pData),
|
||||
buildUserSectionHtml(uid, uData as UserTotal, pData),
|
||||
)
|
||||
.join("");
|
||||
const emptyMsg =
|
||||
|
||||
Reference in New Issue
Block a user