Skip to content

Commit 09efe09

Browse files
committed
feat: Resident Profile PR 1 base page
1 parent 68d160f commit 09efe09

5 files changed

Lines changed: 342 additions & 404 deletions

File tree

frontend-v2/src/components/shared/StatusBadge.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ const enrollmentStatusStyles: Record<string, string> = {
4040
Transferred: 'bg-amber-50 text-amber-700 border-amber-200'
4141
};
4242

43+
const residentStatusStyles: Record<string, string> = {
44+
Active: 'bg-green-100 text-green-800 border-green-300',
45+
Inactive: 'bg-gray-100 text-gray-700 border-gray-300',
46+
Archived: 'bg-orange-100 text-orange-700 border-orange-300'
47+
};
48+
4349
type StatusType =
4450
| SelectedClassStatus
4551
| ProgClassStatus
@@ -49,7 +55,7 @@ type StatusType =
4955

5056
interface StatusBadgeProps {
5157
status: StatusType;
52-
variant?: 'class' | 'progClass' | 'program' | 'enrollment' | 'auto';
58+
variant?: 'class' | 'progClass' | 'program' | 'enrollment' | 'resident' | 'auto';
5359
className?: string;
5460
}
5561

@@ -69,6 +75,9 @@ function getStyleForStatus(
6975
if (variant === 'enrollment' && status in enrollmentStatusStyles) {
7076
return enrollmentStatusStyles[status];
7177
}
78+
if (variant === 'resident' && status in residentStatusStyles) {
79+
return residentStatusStyles[status];
80+
}
7281
if (variant === 'auto') {
7382
if (status in classStatusStyles)
7483
return classStatusStyles[status as SelectedClassStatus];
@@ -78,6 +87,8 @@ function getStyleForStatus(
7887
return programStatusStyles[status as ProgramEffectiveStatus];
7988
if (status in enrollmentStatusStyles)
8089
return enrollmentStatusStyles[status];
90+
if (status in residentStatusStyles)
91+
return residentStatusStyles[status];
8192
}
8293
return 'bg-muted text-foreground border-border';
8394
}

frontend-v2/src/lib/formatters.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ export function formatDate(dateStr?: string): string {
1111
});
1212
}
1313

14+
export function formatRelativeTime(dateStr?: string): string {
15+
if (!dateStr) return '-';
16+
const now = new Date();
17+
const date = new Date(dateStr);
18+
const diffMs = now.getTime() - date.getTime();
19+
if (diffMs < 0) return formatDate(dateStr);
20+
const diffMins = Math.floor(diffMs / 60000);
21+
if (diffMins < 60) return `${diffMins}m ago`;
22+
const diffHours = Math.floor(diffMins / 60);
23+
if (diffHours < 24) return `${diffHours}h ago`;
24+
const diffDays = Math.floor(diffHours / 24);
25+
if (diffDays === 1) return '1 day ago';
26+
if (diffDays < 7) return `${diffDays} days ago`;
27+
return formatDate(dateStr);
28+
}
29+
1430
export function formatDateTime(dateStr: string): string {
1531
const dt = new Date(dateStr);
1632
const date = dt.toLocaleDateString('en-US', {

0 commit comments

Comments
 (0)