improvement: some files replaced, lots of them i shall say. AGENT.MD file created. some rules and skills added for cursor agent.
This commit is contained in:
40
frontend/src/components/lab/caseDetailUtils.ts
Normal file
40
frontend/src/components/lab/caseDetailUtils.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { LabCaseDetail } from '@/types/cases';
|
||||
import type { CaseToothChartProsthesisRow } from '@/components/ui/lab/CaseToothChartPanel';
|
||||
|
||||
export function formatPatientName(patient: { firstName: string; lastName: string }) {
|
||||
return `${patient.firstName} ${patient.lastName}`.trim();
|
||||
}
|
||||
|
||||
export function formatCaseDateTime(value: string | null, locale: string) {
|
||||
if (!value) return '—';
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
}).format(new Date(value));
|
||||
}
|
||||
|
||||
export function buildCaseProsthesisRows(labCase: LabCaseDetail): CaseToothChartProsthesisRow[] {
|
||||
if (labCase.toothProsthesis.length > 0) {
|
||||
const byCode = new Map<string, string[]>();
|
||||
for (const row of labCase.toothProsthesis) {
|
||||
const teeth = byCode.get(row.prosthesisTypeCode) ?? [];
|
||||
if (!teeth.includes(row.tooth)) teeth.push(row.tooth);
|
||||
byCode.set(row.prosthesisTypeCode, teeth);
|
||||
}
|
||||
return [...byCode.entries()].map(([prosthesisTypeCode, teeth]) => ({
|
||||
prosthesisTypeCode,
|
||||
teeth,
|
||||
}));
|
||||
}
|
||||
return labCase.tasksByTooth.map((g) => ({
|
||||
prosthesisTypeCode: g.prosthesisTypeCode,
|
||||
teeth: g.teeth,
|
||||
}));
|
||||
}
|
||||
|
||||
export function latestCaseAttachment(labCase: LabCaseDetail) {
|
||||
if (!labCase.attachments.length) return null;
|
||||
return [...labCase.attachments].sort(
|
||||
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
|
||||
)[0];
|
||||
}
|
||||
25
frontend/src/components/lab/labTaskStatusDisplay.ts
Normal file
25
frontend/src/components/lab/labTaskStatusDisplay.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { CSSProperties } from 'react';
|
||||
import type { BadgeVariant } from '@/components/ui/shared/Badge';
|
||||
import type { LabTaskStatus } from '@/types/cases';
|
||||
|
||||
export function labTaskStatusVariant(status: LabTaskStatus): BadgeVariant {
|
||||
return status === 'COMPLETED' ? 'success' : 'warning';
|
||||
}
|
||||
|
||||
/**
|
||||
* Inline style for the closed status <select> so its text/border reflect the
|
||||
* current value (yellow = in progress, green = completed). Uses the same badge
|
||||
* token colors as the badges for consistency. Native <option> colors have
|
||||
* limited cross-browser support, so only the closed control is themed.
|
||||
*/
|
||||
export function labTaskStatusSelectStyle(status: LabTaskStatus): CSSProperties {
|
||||
const color =
|
||||
status === 'COMPLETED'
|
||||
? 'var(--color-badge-success-fg)'
|
||||
: 'var(--color-badge-warning-fg)';
|
||||
const borderColor =
|
||||
status === 'COMPLETED'
|
||||
? 'var(--color-badge-success-border)'
|
||||
: 'var(--color-badge-warning-border)';
|
||||
return { color, borderColor };
|
||||
}
|
||||
Reference in New Issue
Block a user