Skip to content

Commit f76fadc

Browse files
committed
removed unusaged package,s more genral cleanup
1 parent 031030b commit f76fadc

22 files changed

Lines changed: 343 additions & 8586 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ name: CI
44
on: [push, pull_request]
55

66
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
- name: Install bun
13+
uses: oven-sh/setup-bun@v1
14+
- name: Install dependencies
15+
run: bun install
16+
- name: Run tests
17+
run: bun test
18+
719
check:
820
runs-on: ubuntu-latest
921
steps:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ stats-*.json
1414
.wxt
1515
web-ext.config.ts
1616
claude.md
17+
18+
# Bun is the package manager; keep npm's lockfile out
19+
package-lock.json
1720
# Editor directories and files
1821
.vscode/*
1922
!.vscode/extensions.json

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

bun.lock

Lines changed: 28 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/error-boundary.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { Component, type ErrorInfo, type ReactNode } from "react";
2+
3+
interface ErrorBoundaryProps {
4+
children: ReactNode;
5+
fallback?: ReactNode;
6+
}
7+
8+
interface ErrorBoundaryState {
9+
hasError: boolean;
10+
error: Error | null;
11+
}
12+
13+
/**
14+
* Single root-level error boundary. Catches render errors (e.g. getCourseById
15+
* throwing on a missing course id) so a bad reference doesn't white-screen the
16+
* whole degree-audit page.
17+
*
18+
* Place one instance at the page root; don't scatter throughout the tree.
19+
*/
20+
export default class ErrorBoundary extends Component<
21+
ErrorBoundaryProps,
22+
ErrorBoundaryState
23+
> {
24+
state: ErrorBoundaryState = { hasError: false, error: null };
25+
26+
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
27+
return { hasError: true, error };
28+
}
29+
30+
componentDidCatch(error: Error, info: ErrorInfo) {
31+
console.error("[Degree Audit Plus] Render error caught by ErrorBoundary:", error, info);
32+
}
33+
34+
handleReset = () => {
35+
this.setState({ hasError: false, error: null });
36+
};
37+
38+
render() {
39+
if (this.state.hasError) {
40+
if (this.props.fallback) return this.props.fallback;
41+
42+
return (
43+
<div className="flex min-h-screen w-full flex-col items-center justify-center gap-4 bg-background px-6 text-center text-text">
44+
<h1 className="text-2xl font-bold text-dap-primary">
45+
Something went wrong
46+
</h1>
47+
<p className="max-w-md text-sm text-dap-gray-light">
48+
An unexpected error occurred while rendering your degree audit.
49+
Re-run your audit from the popup to refresh the data, or click the
50+
button below to try again.
51+
</p>
52+
{this.state.error && (
53+
<pre className="max-w-lg rounded bg-gray-100 px-4 py-2 text-left text-xs text-red-600 dark:bg-gray-800">
54+
{this.state.error.message}
55+
</pre>
56+
)}
57+
<button
58+
onClick={this.handleReset}
59+
className="rounded-md bg-dap-primary px-4 py-2 text-sm font-semibold text-white hover:opacity-90"
60+
>
61+
Try again
62+
</button>
63+
</div>
64+
);
65+
}
66+
67+
return this.props.children;
68+
}
69+
}

entrypoints/degree-audit/main.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "@/entrypoints/styles/content.css";
22
import { seedDatabase } from "@/features/catalog/seed-catalog";
3-
import clsx from "clsx";
3+
import { cn } from "@/lib/utils";
44
import React from "react";
55
import ReactDOM from "react-dom/client";
66
import { HStack, VStack } from "@/components/ui/stack";
@@ -14,6 +14,7 @@ import {
1414
PreferencesProvider,
1515
usePreferences,
1616
} from "@/features/preferences/preferences-provider";
17+
import ErrorBoundary from "@/components/error-boundary";
1718

1819
const App = () => {
1920
return (
@@ -36,7 +37,7 @@ const MainContent = () => {
3637
return (
3738
<VStack
3839
x="center"
39-
className={clsx(
40+
className={cn(
4041
"w-full min-w-0 h-screen overflow-hidden transition-[margin-left] duration-300 ease-out",
4142
{
4243
"ml-[365px]": sidebarIsOpen,
@@ -64,7 +65,9 @@ async function bootstrap() {
6465

6566
root.render(
6667
<React.StrictMode>
67-
<App />
68+
<ErrorBoundary>
69+
<App />
70+
</ErrorBoundary>
6871
</React.StrictMode>,
6972
);
7073
}

entrypoints/popup-app/style.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
--color-course-applied: #b8c5a3;
3636
--color-course-in-progress: #f5f0dc;
3737
--color-course-unknown: #e5e7eb;
38+
--color-course-completed-bg: #ecf8d0;
39+
--color-course-completed-border: #9fca5b;
40+
--color-course-planned-bg: #dbeafe;
41+
--color-course-planned-border: #93c5fd;
42+
--color-course-in-progress-bg: #fef9c3;
43+
--color-course-in-progress-border: #fde047;
3844

3945
/* Gray scale */
4046
--color-dap-gray-light: #9cadb7;
@@ -53,6 +59,19 @@
5359
--color-ut-charcoal: #333f48;
5460
--color-ut-off-white: #d6d2c4;
5561

62+
/* Planned-course greens (course-add-modal, semester-dropdowns, requirement-breakdown) */
63+
--color-dap-plan-green: #579d42;
64+
--color-dap-plan-green-hover: #4c8f3b;
65+
--color-dap-plan-green-dark: #4a7c59;
66+
--color-dap-plan-green-light: #5ba753;
67+
68+
/* Status / UI grays */
69+
--color-dap-status-slate: #4a5568;
70+
--color-dap-slate-blue: #b7c6d1;
71+
72+
/* Destructive */
73+
--color-dap-delete: #c63636;
74+
5675
/* Fonts */
5776
--font-family-staatliches: Staatliches, cursive;
5877
--font-family-roboto-flex: "Roboto Flex", sans-serif;

entrypoints/styles/content.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
--color-course-applied: #b8c5a3;
3636
--color-course-in-progress: #f5f0dc;
3737
--color-course-unknown: #e5e7eb;
38+
--color-course-completed-bg: #ecf8d0;
39+
--color-course-completed-border: #9fca5b;
40+
--color-course-planned-bg: #dbeafe;
41+
--color-course-planned-border: #93c5fd;
42+
--color-course-in-progress-bg: #fef9c3;
43+
--color-course-in-progress-border: #fde047;
3844

3945
/* Gray scale */
4046
--color-dap-gray-light: #9cadb7;
@@ -57,6 +63,19 @@
5763
--color-ut-charcoal: #333f48;
5864
--color-ut-off-white: #d6d2c4;
5965

66+
/* Planned-course greens (course-add-modal, semester-dropdowns, requirement-breakdown) */
67+
--color-dap-plan-green: #579d42;
68+
--color-dap-plan-green-hover: #4c8f3b;
69+
--color-dap-plan-green-dark: #4a7c59;
70+
--color-dap-plan-green-light: #5ba753;
71+
72+
/* Status / UI grays */
73+
--color-dap-status-slate: #4a5568;
74+
--color-dap-slate-blue: #b7c6d1;
75+
76+
/* Destructive */
77+
--color-dap-delete: #c63636;
78+
6079
/* Fonts */
6180
--font-family-staatliches: Staatliches, cursive;
6281
--font-family-roboto-flex: "Roboto Flex", sans-serif;

eslint.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import js from "@eslint/js";
2+
import type { ESLint } from "eslint";
23
import pluginReact from "eslint-plugin-react";
4+
import reactHooks from "eslint-plugin-react-hooks";
35
import { defineConfig } from "eslint/config";
46
import globals from "globals";
57
import tseslint from "typescript-eslint";
@@ -15,10 +17,16 @@ export default defineConfig([
1517
tseslint.configs.recommended,
1618
pluginReact.configs.flat.recommended,
1719
{
20+
plugins: { "react-hooks": reactHooks as unknown as ESLint.Plugin },
1821
rules: {
1922
"react/react-in-jsx-scope": "off",
20-
"@typescript-eslint/no-unused-vars": "off",
23+
"@typescript-eslint/no-unused-vars": [
24+
"error",
25+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
26+
],
2127
"@typescript-eslint/no-explicit-any": "warn",
28+
"react-hooks/rules-of-hooks": "error",
29+
"react-hooks/exhaustive-deps": "warn",
2230
},
2331
},
2432
]);

features/audit/audit-provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function AuditContextProvider({
105105
() => getCompositeAuditRequirements(compositeAuditData),
106106
[compositeAuditData],
107107
);
108-
const courseMap = auditData?.courses ?? {};
108+
const courseMap = useMemo(() => auditData?.courses ?? {}, [auditData]);
109109
const progresses = useMemo(
110110
() => calculateWeightedDegreeCompletion(sections, courseMap),
111111
[courseMap, sections],
@@ -157,7 +157,7 @@ export function AuditContextProvider({
157157
return () => {
158158
cancelled = true;
159159
};
160-
}, [currentAuditId]);
160+
}, [currentAuditId, updateLastAuditId]);
161161

162162
const value = useMemo<AuditContextValue>(() => {
163163
const persist = async (auditId: string, updated: CachedAuditData) => {

0 commit comments

Comments
 (0)