Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portal frontend 23 #24

Merged
merged 15 commits into from
Aug 8, 2024
16 changes: 8 additions & 8 deletions src/api/klass.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import { type Class, urls } from "codeforlife/api"
import getReadClassEndpoints, {
CLASS_TAG,
type ListClassesArg,
type ListClassesResult,
type RetrieveClassArg,
type RetrieveClassResult,
} from "codeforlife/api/endpoints/klass"
import {
type BulkUpdateArg,
type BulkUpdateResult,
Expand All @@ -18,6 +10,14 @@ import {
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type Class, urls } from "codeforlife/api"
import getReadClassEndpoints, {
CLASS_TAG,
type ListClassesArg,
type ListClassesResult,
type RetrieveClassArg,
type RetrieveClassResult,
} from "codeforlife/api/endpoints/klass"

import api from "."

Expand Down
12 changes: 6 additions & 6 deletions src/api/school.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { type School, urls } from "codeforlife/api"
import getReadSchoolEndpoints, {
type RetrieveSchoolArg,
type RetrieveSchoolResult,
SCHOOL_TAG,
} from "codeforlife/api/endpoints/school"
import {
type CreateArg,
type CreateResult,
Expand All @@ -12,6 +6,12 @@ import {
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type School, urls } from "codeforlife/api"
import getReadSchoolEndpoints, {
type RetrieveSchoolArg,
type RetrieveSchoolResult,
SCHOOL_TAG,
} from "codeforlife/api/endpoints/school"

import api from "."

Expand Down
2 changes: 1 addition & 1 deletion src/api/schoolTeacherInvitation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type User } from "codeforlife/api"
import {
type Arg,
type CreateArg,
Expand All @@ -15,6 +14,7 @@ import {
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type User } from "codeforlife/api"

import api from "."

Expand Down
16 changes: 8 additions & 8 deletions src/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import { type User, urls } from "codeforlife/api"
import getReadUserEndpoints, {
type ListUsersArg,
type ListUsersResult,
type RetrieveUserArg,
type RetrieveUserResult,
USER_TAG,
} from "codeforlife/api/endpoints/user"
import {
type Arg,
type CreateArg,
Expand All @@ -17,6 +9,14 @@ import {
buildUrl,
tagData,
} from "codeforlife/utils/api"
import { type User, urls } from "codeforlife/api"
import getReadUserEndpoints, {
type ListUsersArg,
type ListUsersResult,
type RetrieveUserArg,
type RetrieveUserResult,
USER_TAG,
} from "codeforlife/api/endpoints/user"

import api from "."

Expand Down
74 changes: 52 additions & 22 deletions src/pages/teacherDashboard/TeacherDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@
import { type SchoolTeacherUser } from "codeforlife/api"
import { getParam } from "codeforlife/utils/router"

import Account, { type AccountProps } from "./account/Account"
import Classes, { type ClassesProps } from "./classes/Classes"
import {
type RetrieveUserResult,
useLazyRetrieveUserQuery,
} from "../../api/user"
import Account from "./account/Account"
import Classes from "./classes/Classes"
import School from "./school/School"
import School, { type SchoolProps } from "./school/School"
import { paths } from "../../router"

export interface TeacherDashboardProps {}
export type TeacherDashboardProps =
| {
tab: "school"
view?: SchoolProps["view"]
}
| {
tab: "classes"
view?: ClassesProps["view"]
}
| {
tab: "account"
view?: AccountProps["view"]
}

const TeacherDashboard: FC<TeacherDashboardProps> = () => {
const TeacherDashboard: FC<TeacherDashboardProps> = ({ tab, view }) => {

Check warning on line 31 in src/pages/teacherDashboard/TeacherDashboard.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/teacherDashboard/TeacherDashboard.tsx#L31

Added line #L31 was not covered by tests
let [retrieveUser, { data: authUser, isError }] = useLazyRetrieveUserQuery()
const navigate = useNavigate()

Expand All @@ -41,27 +53,45 @@
const authSchoolTeacherUser =
authUser as SchoolTeacherUser<RetrieveUserResult>

const tabs: page.TabBarProps["tabs"] = [

Check warning on line 56 in src/pages/teacherDashboard/TeacherDashboard.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/teacherDashboard/TeacherDashboard.tsx#L56

Added line #L56 was not covered by tests
{
label: "Your school",
children: (
<School
authUser={authSchoolTeacherUser}
view={view as SchoolProps["view"]}
/>
),
path: getParam(paths.teacher.dashboard.tab.school, "tab"),
},
{
label: "Your classes",
children: (
<Classes
authUser={authSchoolTeacherUser}
view={view as ClassesProps["view"]}
/>
),
path: getParam(paths.teacher.dashboard.tab.classes, "tab"),
},
{
label: "Your account",
children: (
<Account
authUser={authSchoolTeacherUser}
view={view as AccountProps["view"]}
/>
),
path: getParam(paths.teacher.dashboard.tab.account, "tab"),
},
]

return (
<page.TabBar
header={`Welcome back, ${authUser.first_name} ${authUser.last_name}`}
originalPath={paths.teacher.dashboard.tab._}
tabs={[
{
label: "Your school",
children: <School authUser={authSchoolTeacherUser} />,
path: getParam(paths.teacher.dashboard.tab.school, "tab"),
},
{
label: "Your classes",
children: <Classes authUser={authSchoolTeacherUser} />,
path: getParam(paths.teacher.dashboard.tab.classes, "tab"),
},
{
label: "Your account",
children: <Account authUser={authSchoolTeacherUser} />,
path: getParam(paths.teacher.dashboard.tab.account, "tab"),
},
]}
value={tabs.findIndex(t => t.path === tab)}

Check warning on line 93 in src/pages/teacherDashboard/TeacherDashboard.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/teacherDashboard/TeacherDashboard.tsx#L93

Added line #L93 was not covered by tests
tabs={tabs}
/>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/teacherDashboard/account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { type RetrieveUserResult } from "../../../api/user"

export interface AccountProps {
authUser: SchoolTeacherUser<RetrieveUserResult>
view?: "otp"
}

const Account: FC<AccountProps> = ({ authUser }) => {
Expand Down
9 changes: 9 additions & 0 deletions src/pages/teacherDashboard/classes/Class.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { type FC } from "react"

export interface ClassProps {}

const Class: FC<ClassProps> = () => {
return <>Class</>

Check warning on line 6 in src/pages/teacherDashboard/classes/Class.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/teacherDashboard/classes/Class.tsx#L5-L6

Added lines #L5 - L6 were not covered by tests
}

export default Class
14 changes: 12 additions & 2 deletions src/pages/teacherDashboard/classes/Classes.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { type FC } from "react"
import { type SchoolTeacherUser } from "codeforlife/api"

import Class from "./Class"
import JoinClassRequest from "./JoinClassRequest"
import { type RetrieveUserResult } from "../../../api/user"

export interface ClassesProps {
authUser: SchoolTeacherUser<RetrieveUserResult>
view?: "class" | "join-class-request"
}

const Classes: FC<ClassesProps> = ({ authUser }) => {
return <>TODO</>
const Classes: FC<ClassesProps> = ({ authUser, view }) => {

Check warning on line 13 in src/pages/teacherDashboard/classes/Classes.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/teacherDashboard/classes/Classes.tsx#L13

Added line #L13 was not covered by tests
if (view) {
return {

Check warning on line 15 in src/pages/teacherDashboard/classes/Classes.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/teacherDashboard/classes/Classes.tsx#L15

Added line #L15 was not covered by tests
class: <Class />,
"join-class-request": <JoinClassRequest />,
}[view]
}

return <>Classes</>

Check warning on line 21 in src/pages/teacherDashboard/classes/Classes.tsx

View check run for this annotation

Codecov / codecov/patch

src/pages/teacherDashboard/classes/Classes.tsx#L21

Added line #L21 was not covered by tests
}

export default Classes
Loading