-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
41 lines (34 loc) · 1014 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { DefaultCtx, SessionContext, SimpleRolesIsAuthorized } from "blitz"
import { User } from "db"
import { LegacyRef } from "react"
import { FieldError } from "react-hook-form"
export type ModalComponentProps<T = any> = {
isOpen: boolean
onClose: () => void
onFinish: (data: T) => void
}
export type SubmittableFormProps = { onSuccess?: (...args: unknown[]) => void }
export type Loadable = {
isLoading: boolean
}
export type UnregisteredFormFieldProps = Loadable & {
tabIndex?: number
getError: () => FieldError | undefined
}
export type FormFieldProps = UnregisteredFormFieldProps & {
register: LegacyRef<HTMLInputElement>
}
// Note: You should switch to Postgres and then use a DB enum for role type
export type Role = "ADMIN" | "USER"
declare module "blitz" {
export interface Ctx extends DefaultCtx {
session: SessionContext
}
export interface Session {
isAuthorized: SimpleRolesIsAuthorized<Role>
PublicData: {
userId: User["id"]
role: Role
}
}
}