-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
85 lines (77 loc) · 1.65 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
// NAMESPACES
declare namespace NodeJS {
interface ProcessEnv {
NODE_ENV: "development" | "production" | "test";
PUBLIC_URL: string;
REACT_APP_HASH: string;
REACT_APP_API_URI: string;
REACT_APP_WS_URI: string;
REACT_APP_FIREBASE_API_KEY: string;
REACT_APP_FIREBASE_AUTH_DOMAIN: string;
REACT_APP_FIREBASE_PROJ_ID: string;
REACT_APP_FIREBASE_STORAGE_BUCKET: string;
REACT_APP_FIREBASE_MSG_SENDER_ID: string;
REACT_APP_FIREBASE_APP_ID: string;
REACT_APP_FIREBASE_MEASUREMENT_ID: string;
REACT_APP_FIREBASE_DB_URL: string;
}
}
// TYPES
type DispatchTypes = "setAppName" | "loadUser" | "setShowTabs" | "setChatWith";
type MediaTypes = "text" | "media";
type IFirestoreData = Message | User;
type CollectionName = "users" | "messages";
type MessageSortingOptions =
| "time"
| "type"
| "sentBy"
| "fileUrl"
| "channel"
| "message";
type Dispatch = ({
type,
payload,
}: {
type: DispatchTypes;
payload: any;
}) => void;
// INTERFACES
interface State {
appName: string;
showTabs: boolean;
user: User | undefined;
chatWith: Contact | undefined;
}
interface Contact {
name: string;
userId: string;
avatar: string;
}
interface User {
id: string;
name: string;
avatar: string;
lastSeen: Date;
passcode: string;
contacts: Contact[];
}
interface Message {
id: string;
sentBy: string;
channel: string;
message: string;
type: MediaTypes;
fileUrl: string | null;
time: { seconds: number; nanoseconds: number } | Date;
}
interface Channel {
userA: string;
userB: string;
}
interface MessagesListener extends Channel {
set: React.Dispatch<React.SetStateAction<Message[]>>;
}
interface IContextProps {
state: State;
dispatch: Dispatch;
}