-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefinitions.ts
175 lines (155 loc) · 4.22 KB
/
definitions.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import { ReactNode } from "react";
import { InferType } from "yup";
import {
yupDepartmentCreateSchema,
yupDepartmentUpdateSchema,
yupInstructorCreateSchema,
yupInstructorUpdateSchema,
yupLoginSchema,
yupStudentCreateSchema,
yupStudentUpdateSchema,
yupSubjectCreateSchema,
yupSubjectUpdateSchema,
yupUserCreateSchema,
yupUserResetPasswordSchema,
yupUserUpdateSchema,
} from "./lib/validation-schema-yup";
// this type handle the setState function when using prev
// Ex: setState((prev)=> !prev) as UpdateStateType
export type UpdateStateType = (
updateFn: (prev: boolean) => boolean,
) => void | undefined;
//---------------------------------
// database types
//---------------------------------
export type ILogin = InferType<typeof yupLoginSchema>;
export interface IUser {
id?: number;
userName?: string;
email?: string;
imagePath?: string | null;
fullName?: string;
roles?: number[] | string;
roleId?: number;
createdAt?: string;
lastUpdate?: string;
}
export type YupUserUpdateInputs = InferType<typeof yupUserUpdateSchema>;
export type YupUserResetPassword = InferType<typeof yupUserResetPasswordSchema>;
export type YupUserCreateInputs = InferType<typeof yupUserCreateSchema>;
export interface IInstructor {
id?: number;
instId?: number;
name: string;
nameAr?: string;
nameEn?: string;
address: string;
position: string;
imagePath: null;
supervisorId: number;
salary: number;
deptId: number;
}
// {
// id: 6,
// name: 'Dr. Gamal Hassan',
// address: '678 Professor St',
// position: 'Professor',
// imagePath: null,
// supervisorId: null,
// salary: 70000,
// deptId: 4
// }
export type YupInstructorUpdateInputs = InferType<
typeof yupInstructorUpdateSchema
>;
export type YupInstructorCreateInputs = InferType<
typeof yupInstructorCreateSchema
>;
export interface IDepartment {
id: number;
// deptId?: number;
name: string;
managerId: number;
managerName?: string;
students: { id: number; name: string }[];
instructors: { id: number; name: string }[];
subjects: { id: number; name: string }[];
}
export type YupDepartmentUpdateInputs = InferType<
typeof yupDepartmentUpdateSchema
>;
export type YupDepartmentCreateInputs = InferType<
typeof yupDepartmentCreateSchema
>;
//----------------------------
export interface IStudent {
id?: number;
studId?: number;
name: string;
address: string;
departmentName?: string[] | null;
departmentId?: number | null;
}
export type YupStudentUpdateInputs = InferType<typeof yupStudentUpdateSchema>;
export type YupStudentCreateInputs = InferType<typeof yupStudentCreateSchema>;
export interface ISubject {
id: number;
subjectName?: string;
name?: string;
departments?: {
departmentId: number;
departmentName: string;
}[];
period?: string;
}
export type YupSubjectUpdateInputs = InferType<typeof yupSubjectUpdateSchema>;
export type YupSubjectCreateInputs = InferType<typeof yupSubjectCreateSchema>;
export interface IRole {
id?: number;
name: string;
hasRole?: boolean;
}
//---------------------------------
// react hook form types
//---------------------------------
export interface FormDataObjectType<T> {
[key: string]: T;
}
export interface IResponse {
statusCode: number;
success: boolean;
message: string;
}
export interface IApiResponseReturn<T> {
data?: T | undefined;
error: string | undefined | string[];
success: string | undefined | string[];
status: "idle" | "success" | "error";
}
export interface IFetchResponse<T> {
data?: T | T[] | { [key: string]: T } | {} | null | undefined;
isEmpty?: boolean;
isSuccess: boolean;
isError: boolean;
message: string | string[] | { [key: string]: string[] } | {} | null;
}
export interface IClientResponse<T>
extends Pick<
IFetchResponse<T>,
"isEmpty" | "isSuccess" | "isError" | "message"
> {
data?: T;
}
/**
* Table head names and the keys of the endpoints data
* this export interface used to identify the array that passeed into the <TableLayer/> component into tableHead
*/
export interface ITableHead {
/**
* make the type works dynamically with the array and the object keys
*/
[key: string]: string | { key: string; name: string }[];
name: string;
// arr: { key: string; name: string }[];
}