Skip to content

Commit 728f4fa

Browse files
committed
fixed formatting
1 parent e6f7039 commit 728f4fa

20 files changed

+503
-478
lines changed

src/api/endpoints.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export default function endpoints<ReducerPath extends string>(
2626
// TODO: https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-queryfn
2727
logout: _build.mutation<LogoutResult, LogoutQuery>({
2828
query: () => ({
29-
url: 'session/logout/',
30-
method: 'GET'
31-
})
32-
})
33-
};
29+
url: "session/logout/",
30+
method: "GET",
31+
}),
32+
}),
33+
}
3434
}

src/api/models.ts

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
1-
import { COUNTRY_ISO_CODES, UK_COUNTIES } from '../helpers/general';
2-
import type { Model } from '../helpers/rtkQuery';
1+
import type { CountryIsoCodes, UkCounties } from "../helpers/general"
2+
import type { Model } from "../helpers/rtkQuery"
33

44
export type User = Model<
55
number,
66
{
7-
password: string;
8-
last_login?: Date;
9-
first_name: string;
10-
last_name?: string;
11-
email?: string;
12-
is_staff: boolean;
13-
is_active: boolean;
14-
date_joined: Date;
15-
requesting_to_join_class?: string;
16-
teacher?: Teacher;
17-
student?: Student;
7+
password: string
8+
last_login?: Date
9+
first_name: string
10+
last_name?: string
11+
email?: string
12+
is_staff: boolean
13+
is_active: boolean
14+
date_joined: Date
15+
requesting_to_join_class?: string
16+
teacher?: Teacher
17+
student?: Student
1818
}
19-
>;
19+
>
2020

2121
export type Teacher = Model<
2222
number,
2323
{
24-
user: number;
25-
school?: number;
26-
is_admin: boolean;
24+
user: number
25+
school?: number
26+
is_admin: boolean
2727
}
28-
>;
28+
>
2929

3030
export type Student = Model<
3131
number,
3232
{
33-
user: number;
34-
school: number;
35-
klass: string;
33+
user: number
34+
school: number
35+
klass: string
3636
}
37-
>;
37+
>
3838

3939
export type School = Model<
4040
number,
4141
{
42-
name: string;
43-
country?: (typeof COUNTRY_ISO_CODES)[number];
44-
uk_county?: (typeof UK_COUNTIES)[number];
42+
name: string
43+
country?: CountryIsoCodes
44+
uk_county?: UkCounties
4545
}
46-
>;
46+
>
4747

4848
export type Class = Model<
4949
string,
5050
{
51-
name: string;
52-
teacher: number;
53-
school: number;
54-
read_classmates_data: boolean;
55-
receive_requests_until?: Date;
51+
name: string
52+
teacher: number
53+
school: number
54+
read_classmates_data: boolean
55+
receive_requests_until?: Date
5656
}
57-
>;
57+
>
5858

5959
export type AuthFactor = Model<
6060
number,
6161
{
62-
user: number;
63-
type: 'otp';
62+
user: number
63+
type: "otp"
6464
}
65-
>;
65+
>

src/api/tagTypes.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const tagTypes = [
22
// These are the tags for the common models used throughout our system.
33
// https://github.com/ocadotechnology/codeforlife-package-python/tree/main/codeforlife/user/models
44
// NOTE: Don't use the "Teacher" and "Student" tags. Use "User" instead.
5-
'User',
6-
'School',
7-
'Class',
8-
'AuthFactor'
9-
] as const;
5+
"User",
6+
"School",
7+
"Class",
8+
"AuthFactor",
9+
] as const
1010

1111
export default tagTypes
1212
export type TagTypes = (typeof tagTypes)[number]

src/api/urls.ts

+16-37
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
1-
const urls: Record<
2-
string,
3-
{
4-
list: string;
5-
detail: string;
6-
}
7-
> = {
8-
user: {
9-
list: 'users/',
10-
detail: 'users/<id>/'
11-
},
12-
teacher: {
13-
list: 'users/teachers/',
14-
detail: 'users/teachers/<id>/'
15-
},
16-
student: {
17-
list: 'users/students/',
18-
detail: 'users/students/<id>/'
19-
},
20-
school: {
21-
list: 'schools/',
22-
detail: 'schools/<id>/'
23-
},
24-
class: {
25-
list: 'classes/',
26-
detail: 'classes/<id>/'
27-
},
28-
otpBypassToken: {
29-
list: 'otp-bypass-tokens/',
30-
detail: 'otp-bypass-tokens/<id>/'
31-
},
32-
authFactor: {
33-
list: 'auth-factors/',
34-
detail: 'auth-factors/<id>/'
35-
}
36-
};
1+
function url(list: string, detail: string) {
2+
if (list === detail) throw Error("List and detail are the same.")
373

38-
export default urls;
4+
return { list, detail }
5+
}
6+
7+
const urls = {
8+
user: url("users/", "users/<id>/"),
9+
teacher: url("users/teachers/", "users/teachers/<id>/"),
10+
student: url("users/students/", "users/students/<id>/"),
11+
school: url("schools/", "schools/<id>/"),
12+
class: url("classes/", "classes/<id>/"),
13+
otpBypassToken: url("otp-bypass-tokens/", "otp-bypass-tokens/<id>/"),
14+
authFactor: url("auth-factors/", "auth-factors/<id>/"),
15+
}
16+
17+
export default urls

src/components/ItemizedList.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import type React from "react"
2-
import { List, type ListProps, type ListItem, type ListItemText } from "@mui/material"
2+
import {
3+
List,
4+
type ListProps,
5+
type ListItem,
6+
type ListItemText,
7+
} from "@mui/material"
38

49
type ListItemElement = React.ReactElement<typeof ListItem | typeof ListItemText>
510

src/components/form/CheckboxField.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
Stack,
88
} from "@mui/material"
99
import { Error as ErrorIcon } from "@mui/icons-material"
10-
import { Field, type FieldProps, type FieldConfig, type FieldValidator } from "formik"
10+
import {
11+
Field,
12+
type FieldProps,
13+
type FieldConfig,
14+
type FieldValidator,
15+
} from "formik"
1116
import { bool as YupBool, BooleanSchema, ValidationError } from "yup"
1217

1318
import { wrap } from "../../helpers"

src/components/form/Form.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import React from "react"
22
import { Stack, type StackProps } from "@mui/material"
3-
import { Formik, type FormikValues, type FormikConfig, Form as FormikForm } from "formik"
3+
import {
4+
Formik,
5+
type FormikValues,
6+
type FormikConfig,
7+
Form as FormikForm,
8+
} from "formik"
49

510
export interface FormProps<Values> extends FormikConfig<Values> {
611
stackProps?: Omit<StackProps, "children">

src/components/form/TextField.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import {
55
InputAdornment,
66
} from "@mui/material"
77
import { ErrorOutline as ErrorOutlineIcon } from "@mui/icons-material"
8-
import { Field, type FieldProps, type FieldConfig, type FieldValidator } from "formik"
8+
import {
9+
Field,
10+
type FieldProps,
11+
type FieldConfig,
12+
type FieldValidator,
13+
} from "formik"
914
import {
1015
string as YupString,
1116
array as YupArray,

src/components/form/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { type FormikErrors } from "formik"
22

3-
import AutocompleteField, { type AutocompleteFieldProps } from "./AutocompleteField"
3+
import AutocompleteField, {
4+
type AutocompleteFieldProps,
5+
} from "./AutocompleteField"
46
import CheckboxField, { type CheckboxFieldProps } from "./CheckboxField"
57
import DateField, { type DateFieldProps } from "./DateField"
68
import EmailField, { type EmailFieldProps } from "./EmailField"

src/components/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import App, { type AppProps } from "./App"
2-
import ClickableTooltip, { type ClickableTooltipProps } from "./ClickableTooltip"
2+
import ClickableTooltip, {
3+
type ClickableTooltipProps,
4+
} from "./ClickableTooltip"
35
import CopyIconButton, { type CopyIconButtonProps } from "./CopyIconButton"
46
import Countdown, { type CountdownProps } from "./Countdown"
57
import ElevatedAppBar, { type ElevatedAppBarProps } from "./ElevatedAppBar"

src/components/page/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import Banner, { type BannerProps } from "./Banner"
2-
import Container, { type ContainerProps, type ContainerState } from "./Container"
2+
import Container, {
3+
type ContainerProps,
4+
type ContainerState,
5+
} from "./Container"
36
import Notification, { type NotificationProps } from "./Notification"
47
import Section, { type SectionProps } from "./Section"
58
import TabBar, { type TabBarProps } from "./TabBar"

src/features/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import InactiveDialog, { type InactiveDialogProps } from "./InactiveDialog"
2-
import ScreenTimeDialog, { type ScreenTimeDialogProps } from "./ScreenTimeDialog"
2+
import ScreenTimeDialog, {
3+
type ScreenTimeDialogProps,
4+
} from "./ScreenTimeDialog"
35

46
export {
57
InactiveDialog,

0 commit comments

Comments
 (0)