Skip to content

Commit

Permalink
Portal frontend 23 (#24)
Browse files Browse the repository at this point in the history
* export results and args

* new js package

* add icon

* table components

* quick save

* extract id from body

* school name field

* ready for review

* only teachers

* fix rendering issue and create placeholder tabs

* merge from dev

* working order

* create sub view for leaving school

* merge from dev

* fix imports
  • Loading branch information
SKairinos authored Aug 8, 2024
1 parent 10b08fe commit eddebcb
Show file tree
Hide file tree
Showing 14 changed files with 572 additions and 88 deletions.
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 { CircularProgress } from "@mui/material"
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 }) => {
let [retrieveUser, { data: authUser, isError }] = useLazyRetrieveUserQuery()
const navigate = useNavigate()

Expand All @@ -41,27 +53,45 @@ const TeacherDashboard: FC<TeacherDashboardProps> = () => {
const authSchoolTeacherUser =
authUser as SchoolTeacherUser<RetrieveUserResult>

const tabs: page.TabBarProps["tabs"] = [
{
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)}
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</>
}

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 }) => {
if (view) {
return {
class: <Class />,
"join-class-request": <JoinClassRequest />,
}[view]
}

return <>Classes</>
}

export default Classes
Loading

0 comments on commit eddebcb

Please sign in to comment.