-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
179 lines (162 loc) · 4.76 KB
/
types.d.ts
File metadata and controls
179 lines (162 loc) · 4.76 KB
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
176
177
178
179
/**
* Represents a book entity with various attributes describing its properties and availability.
*/
interface Book {
id: string | number;
title: string;
author: string;
genre: string;
rating: number;
totalCopies: number;
availableCopies: number;
description: string;
coverColor: string;
coverUrl: string;
videoUrl: string;
summary: string;
createdAt?: Date | null;
isLoanedBook?: boolean;
}
interface BookParams
extends Pick<
Book,
| "title"
| "author"
| "genre"
| "rating"
| "totalCopies"
| "description"
| "summary"
> {
coverUrl: string;
coverColor: string;
videoUrl: string;
}
interface BorrowBookParams {
bookId: string;
userId: string;
}
/**
* Represents the status of a borrowed book in a library or similar borrowing system.
*
* The `BorrowBookStatus` interface is used to define the current borrowing state of a book.
* It can have one of the following statuses:
* - "BORROWED": Indicates that the book is currently borrowed by a user.
* - "PENDING": Indicates that a request to borrow the book has been made but is awaiting approval or processing.
* - "RETURNED": Indicates that the book has been returned to its original location or library.
*/
interface BorrowBookStatus {
status: "BORROWED" | "PENDING" | "RETURNED";
}
interface BorrowBook {
id: string;
userId: string;
bookId: string;
status: BorrowBookStatus["status"];
borrowDate: Date | string;
dueDate: Date | string;
returnDate: string | null;
createdAt: Date | null;
}
interface BorrowedBooks
extends Pick<
BorrowBook,
"id" | "borrowDate" | "dueDate" | "returnDate" | "status"
> {
books: Pick<Book, "id" | "title" | "genre" | "coverUrl" | "coverColor">;
}
interface BorrowRequestData {
id: string;
status: BorrowBookStatus["status"];
borrowDate: Date;
dueDate: Date | string;
returnDate: string | null;
book?: Pick<Book, "id" | "title" | "coverColor" | "coverUrl">;
user?: Pick<User, "id" | "fullName" | "email">;
}
/**
* Represents the status of a user.
*
* This interface defines the allowed states for a user's status, which can be one of the following:
* - "APPROVED": The user's status has been approved.
* - "PENDING": The user's status is pending and requires further action or review.
* - "REJECTED": The user's status has been rejected.
*/
interface UserStatus {
status: "APPROVED" | "PENDING" | "REJECTED";
}
/**
* Represents a user within the system.
*
* @interface User
* @property {string} id - The unique identifier for the user.
* @property {string} fullName - The full name of the user.
* @property {string} email - The email of the user.
* @property {typeof UserStatus} [status] - The current status of the user. This is optional.
* @property {Date} createdAt - The date and time when the user was created.
* @property {Date} lastActivityDate - The date and time of the user's last activity.
*/
interface User {
id: string;
fullName: string;
email?: string;
status?: typeof UserStatus;
createdAt: Date | null;
lastActivityDate: Date | null;
}
interface UsersList
extends Pick<
User,
"id" | "fullName" | "email" | "createdAt" | "lastActivityDate"
> {
role: "ADMIN" | "USER" | null;
universityId: number;
borrowedBooksCount: number;
}
/**
* Interface representing user credentials for authentication purposes.
*
* This interface is typically used to encapsulate the user's email and password fields
* for login or authentication mechanisms. It provides a standardized structure
* for handling user credential data within an application.
*/
interface UserCredentials {
email: string;
password: string;
}
/**
* This interface extends certain properties from the `User` type and the `UserCredentials` interface.
*
* It is used to store user-specific information for authentication purposes, including
* - University identification details
* - User identity details inherited from other types
*/
interface UserAuthCredentials extends Pick<User, "fullName">, UserCredentials {
universityId: number;
universityCard: string;
}
type FilterOptions = "all" | "author" | "title" | "genre" | "rating";
interface AccountRequestUser {
id: string;
fullName: string;
email: string;
universityId: number;
status: UserStatus["status"];
createdAt: Date | null;
lastActivityDate: Date | null;
}
// Region - Sorting Options used within TableSortOptions Component
type BookSortOptions =
| "alphabetical"
| "oldest"
| "latest"
| "author"
| "genre";
type AccountRequestSortOptions = "oldest" | "latest";
type AllUsersSortOptions = "alphabetical" | "oldest" | "latest" | "records";
type BorrowedBooksSortOptions = "oldest" | "latest";
type SortOption<T extends string> = {
id: T;
title: string;
};
// End of Region-Sorting Options used within TableSortOptions Component