Skip to content

Commit 5d261cd

Browse files
committed
Fix GPA card: correct Counted GPA, card width, dark-mode text
Three fixes to the Phase 7 GPA/Credit cards: - Counted GPA was wrong: parseHours matched /\d+/ + parseInt, so the scraped "3.7766 GPA" cell truncated to 3. Parse a full decimal (/\d+(?:\.\d+)?/ + parseFloat) so GPA cells keep their fractional part. Hours/course columns are always integers, so this is a no-op for them — the only snapshot changes are the two GPA rows (3 -> 3.7766, 3 -> 3.6091). - Card width collapsed: the side-panel VStack defaults to items-start, so the card shrank to its content instead of filling the w-sm column. Add w-full to both cards. - Dark mode: hardcoded text-gray-500/600/700 don't flip, so the text was unreadable on the dark card. Switch to the theme-aware text-muted token, and give the "Required" GPA box an explicit text-text (it was inheriting default black, invisible in dark mode).
1 parent f41f897 commit 5d261cd

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

features/audit-scraping/audit-page-parser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import type { RequirementProgressUnit } from "@/domain/progress";
2121
// --- Helper Functions ---
2222

2323
export function parseHours(text: string): number {
24-
const match = text.match(/\d+/);
25-
return match ? parseInt(match[0], 10) : 0;
24+
// Match a full decimal so GPA cells like "3.7766 GPA" keep their fractional
25+
// part. Hours/course columns are always integers, so this is a no-op for them.
26+
const match = text.match(/\d+(?:\.\d+)?/);
27+
return match ? parseFloat(match[0]) : 0;
2628
}
2729

2830
export function parseRequirementProgress(text: string): {

features/dashboard/gpa-credit-cards.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,23 @@ export const GPATotalsCard = ({
7474
summary,
7575
}: GPATotalsProps) => {
7676
return (
77-
<div className="p-5 rounded-lg border border-gray-200 bg-background shadow-md">
77+
<div className="w-full p-5 rounded-lg border border-gray-200 bg-background shadow-md">
7878
<HStack x="between" y="top" fill>
7979
<h3 className="text-xl font-bold text-text">GPA Totals</h3>
8080
<InfoIcon />
8181
</HStack>
8282

8383
<HStack gap={6} className="mt-4">
8484
<VStack gap={1}>
85-
<span className="text-sm text-gray-500">Required</span>
85+
<span className="text-sm text-muted">Required</span>
8686
<div className="px-4 py-2 bg-background border border-gray-300 rounded-lg">
87-
<span className="text-lg font-semibold">{required.toFixed(4)}</span>
87+
<span className="text-lg font-semibold text-text">
88+
{required.toFixed(4)}
89+
</span>
8890
</div>
8991
</VStack>
9092
<VStack gap={1}>
91-
<span className="text-sm text-gray-500">Counted</span>
93+
<span className="text-sm text-muted">Counted</span>
9294
<div className="px-4 py-2 bg-dap-green rounded-lg">
9395
<span className="text-lg font-semibold text-white">
9496
{counted.toFixed(4)}
@@ -98,7 +100,7 @@ export const GPATotalsCard = ({
98100
</HStack>
99101

100102
{summary ? (
101-
<p className="mt-4 text-sm text-gray-600">
103+
<p className="mt-4 text-sm text-muted">
102104
{summary.hoursUsed} hours for a total of {summary.points} points were
103105
used to calculate the GPA.
104106
</p>
@@ -120,14 +122,14 @@ export const CreditHourTotalsCard = ({
120122
requirements,
121123
}: CreditHourTotalsProps) => {
122124
return (
123-
<div className="p-5 rounded-lg border border-gray-200 bg-background shadow-md">
125+
<div className="w-full p-5 rounded-lg border border-gray-200 bg-background shadow-md">
124126
<h3 className="text-xl font-bold text-text">Credit Hour Totals</h3>
125127

126128
<VStack gap={3} className="mt-4">
127129
{requirements.map((req) => (
128130
<HStack key={req.text} gap={3} y="middle">
129131
<FramedStatusIcon state={STATUS_ICON_STATE[req.status]} />
130-
<span className="text-sm text-gray-700">{req.text}</span>
132+
<span className="text-sm text-muted">{req.text}</span>
131133
</HStack>
132134
))}
133135
</VStack>

tests/scraping/__snapshots__/audit-scraper.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ OR
654654
{
655655
"rules": [
656656
{
657-
"appliedHours": 3,
657+
"appliedHours": 3.7766,
658658
"courses": [
659659
"course-1",
660660
"course-2",
@@ -677,7 +677,7 @@ OR
677677
"text": "A University GPA of 2.00 is required on all courses undertaken (including credit by examination, correspondence, and extension) for which a grade or symbol other than Q, W, X, or CR is recorded.",
678678
},
679679
{
680-
"appliedHours": 3,
680+
"appliedHours": 3.6091,
681681
"courses": [
682682
"course-1",
683683
"course-2",

0 commit comments

Comments
 (0)