Skip to content

Commit c4a487b

Browse files
Define proper Enrollment type interface and replace any[] type
Co-authored-by: jeromehardaway <[email protected]>
1 parent df8db2f commit c4a487b

File tree

4 files changed

+157
-136
lines changed

4 files changed

+157
-136
lines changed

package-lock.json

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

src/pages/dashboard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Layout01 from "@layout/layout-01";
55
import type { GetStaticProps, NextPage } from "next";
66
import SEO from "@components/seo/page-seo";
77
import Breadcrumb from "@components/breadcrumb";
8+
import type { Enrollment } from "@/types/enrollment";
89

910

1011
type PageProps = {
@@ -21,7 +22,7 @@ type PageWithLayout = NextPage<PageProps> & {
2122

2223
const Dashboard: PageWithLayout = () => {
2324
const { data: session, status } = useSession();
24-
const [enrollments, setEnrollments] = useState<any[]>([]);
25+
const [enrollments, setEnrollments] = useState<Enrollment[]>([]);
2526
const [loading, setLoading] = useState(true);
2627

2728
useEffect(() => {

src/types/enrollment.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Enrollment types based on the API response structure
3+
*/
4+
5+
export interface EnrollmentStats {
6+
totalLessons: number;
7+
completedLessons: number;
8+
progressPercentage: number;
9+
}
10+
11+
export interface Course {
12+
id: string;
13+
title: string;
14+
description: string | null;
15+
imageUrl: string | null;
16+
difficulty: string;
17+
category: string;
18+
isPublished: boolean;
19+
estimatedHours: number | null;
20+
prerequisites: string[];
21+
tags: string[];
22+
createdAt: string;
23+
updatedAt: string;
24+
_count: {
25+
modules: number;
26+
};
27+
}
28+
29+
export type EnrollmentStatus = 'ACTIVE' | 'COMPLETED' | 'DROPPED' | 'PAUSED';
30+
31+
export interface Enrollment {
32+
id: string;
33+
userId: string;
34+
courseId: string;
35+
status: EnrollmentStatus;
36+
progress: number;
37+
enrolledAt: string;
38+
completedAt: string | null;
39+
lastActivity: string;
40+
course: Course;
41+
stats: EnrollmentStats;
42+
}

yarn.lock

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,11 +1055,6 @@
10551055
dependencies:
10561056
"@jridgewell/trace-mapping" "0.3.9"
10571057

1058-
"@esbuild/[email protected]":
1059-
version "0.25.5"
1060-
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.5.tgz"
1061-
integrity sha512-GtaBgammVvdF7aPIgH2jxMDdivezgFu6iKpmT+48+F8Hhg5J/sfnDieg0aeG/jfSvkYQU2/pceFPDKlqZzwnfQ==
1062-
10631058
"@eslint-community/eslint-utils@^4.2.0":
10641059
version "4.4.1"
10651060
resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz"
@@ -1162,18 +1157,6 @@
11621157
resolved "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz"
11631158
integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==
11641159

1165-
1166-
version "0.33.5"
1167-
resolved "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz"
1168-
integrity sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==
1169-
optionalDependencies:
1170-
"@img/sharp-libvips-darwin-arm64" "1.0.4"
1171-
1172-
1173-
version "1.0.4"
1174-
resolved "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.4.tgz"
1175-
integrity sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==
1176-
11771160
"@isaacs/cliui@^8.0.2":
11781161
version "8.0.2"
11791162
resolved "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz"
@@ -1504,10 +1487,15 @@
15041487
dependencies:
15051488
fast-glob "3.3.1"
15061489

1507-
1490+
1491+
version "15.1.1"
1492+
resolved "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.1.1.tgz"
1493+
integrity sha512-KgIiKDdV35KwL9TrTxPFGsPb3J5RuDpw828z3MwMQbWaOmpp/T4MeWQCwo+J2aOxsyAcfsNE334kaWXCb6YTTA==
1494+
1495+
15081496
version "15.1.1"
1509-
resolved "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.1.1.tgz"
1510-
integrity sha512-pq7Hzu0KaaH6UYcCQ22mOuj2mWCD6iqGvYprp/Ep1EcCxbdNOSS+8EJADFbPHsaXLkaonIJ8lTKBGWXaFxkeNQ==
1497+
resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.1.1.tgz"
1498+
integrity sha512-aHP/29x8loFhB3WuW2YaWaYFJN389t6/SBsug19aNwH+PRLzDEQfCvtuP6NxRCido9OAoExd+ZuYJKF9my1Kpg==
15111499

15121500
"@nodelib/[email protected]":
15131501
version "2.1.5"
@@ -6261,16 +6249,6 @@ fs.realpath@^1.0.0:
62616249
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
62626250
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
62636251

6264-
fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3:
6265-
version "2.3.3"
6266-
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
6267-
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
6268-
6269-
6270-
version "2.3.2"
6271-
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
6272-
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
6273-
62746252
function-bind@^1.1.2:
62756253
version "1.1.2"
62766254
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"

0 commit comments

Comments
 (0)