-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
148 lines (135 loc) · 3.04 KB
/
types.d.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
import { InsertMeaning } from "./db/schema/meanings";
import { PartOfSpeech } from "./db/schema/part_of_speechs";
import { InsertRoot } from "./db/schema/roots";
import { InsertWord } from "./db/schema/words";
type LoginInputs = {
usernameOrEmail: string;
password: string;
};
type ForgotPassword = {
forgotPasswordEmail: string;
};
type Prettify<T> = { [K in keyof T]: T[K] } & {};
type SignupInputs =
| "name"
| "username"
| "email"
| "password"
| "confirmPassword";
type SignupForm = Record<SignupInputs, string>;
type SignupRequest = Omit<SignupForm, "confirmPassword">; // Omit confirmPassword from SignUpInputs to create SignUpRequest
type ReplaceNullWithUndefined<T> = T extends null ? undefined : T;
type ToUndefinedProps<T> = {
// Replace null with undefined
[P in keyof T]: ReplaceNullWithUndefined<T[P]>;
};
type WordInput = ToUndefinedProps<
// Replace null with undefined since null is not allowed in Input value prop of NextUI
Prettify<
Partial<
Omit<InsertWord, "rootId" | "created_at" | "updated_at" | "id"> &
{
language: string
root: string;
attributes: string[];
}
>
>
>;
type Meaning = {
meaning: string;
image: FileList | null;
example?: {
sentence: string | undefined;
author?: string | undefined;
};
partOfSpeechId: number | undefined;
attributes: string[];
};
type MeaningInputs = Partial<Meaning>;
type WordForm = Prettify<
WordInput & {
meanings: MeaningInputs[];
}
>;
type WordFormSubmit = Prettify<{
name: string;
language?: string;
phonetic?: string;
root?: string;
prefix?: string;
suffix?: string;
attributes: number[]
meanings: {
meaning: string;
partOfSpeechId: number;
attributes: number[];
example?: {
sentence: string;
author?: number | undefined;
}
}[]
}>;
type Language = {
id: number;
language_en: string;
language_tr: string;
language_code: string;
}
type WordSearchResult = {
word_data: {
word_id: number;
word_name: string;
phonetic: string;
prefix: string;
suffix: string;
attributes?: {
attribute_id: number;
attribute: string;
}[];
root: {
root: string;
} & Omit<Language, "id">
meanings: {
meaning_id: number;
meaning: string;
part_of_speech: string;
part_of_speech_id: number
sentence: string | undefined;
author: string | undefined;
author_id: number | undefined
attributes?: [
{
attribute_id: number;
attribute: string;
}
]
}[];
}
}
type DashboardWordList = {
word_id: number;
name: string;
meaning: string;
}
type EditMeaningForm = {
id: string | number
meaning: string
attributes?: string[]
partOfSpeechId: string
exampleSentence: string | undefined
authorId: string | undefined
}
type EditWordForm = {
name: string
attributes?: string[]
language?: string
root?: string
phonetic?: string
suffix?: string
prefix?: string
meanings: EditMeaningForm[]
}
type NewAttributeForm = {
attribute: string
}