[5d6f37a] | 1 | // ----------------------------------------------------------------------
|
---|
| 2 |
|
---|
| 3 | export type ActionMapType<M extends { [index: string]: any }> = {
|
---|
| 4 | [Key in keyof M]: M[Key] extends undefined
|
---|
| 5 | ? {
|
---|
| 6 | type: Key;
|
---|
| 7 | }
|
---|
| 8 | : {
|
---|
| 9 | type: Key;
|
---|
| 10 | payload: M[Key];
|
---|
| 11 | };
|
---|
| 12 | };
|
---|
| 13 |
|
---|
| 14 | export type AuthUserType = null | Record<string, any>;
|
---|
| 15 |
|
---|
| 16 | export type AuthStateType = {
|
---|
| 17 | status?: string;
|
---|
| 18 | loading: boolean;
|
---|
| 19 | user: AuthUserType;
|
---|
| 20 | };
|
---|
| 21 |
|
---|
| 22 | // ----------------------------------------------------------------------
|
---|
| 23 |
|
---|
| 24 | type CanRemove = {
|
---|
| 25 | login?: (email: string, password: string) => Promise<void>;
|
---|
| 26 | register?: (
|
---|
| 27 | email: string,
|
---|
| 28 | password: string,
|
---|
| 29 | firstName: string,
|
---|
| 30 | lastName: string
|
---|
| 31 | ) => Promise<void>;
|
---|
| 32 | //
|
---|
| 33 | loginWithGoogle?: () => Promise<void>;
|
---|
| 34 | loginWithGithub?: () => Promise<void>;
|
---|
| 35 | loginWithTwitter?: () => Promise<void>;
|
---|
| 36 | //
|
---|
| 37 | confirmRegister?: (email: string, code: string) => Promise<void>;
|
---|
| 38 | forgotPassword?: (email: string) => Promise<void>;
|
---|
| 39 | resendCodeRegister?: (email: string) => Promise<void>;
|
---|
| 40 | newPassword?: (email: string, code: string, password: string) => Promise<void>;
|
---|
| 41 | };
|
---|
| 42 |
|
---|
| 43 | export type FirebaseContextType = CanRemove & {
|
---|
| 44 | user: AuthUserType;
|
---|
| 45 | method: string;
|
---|
| 46 | loading: boolean;
|
---|
| 47 | authenticated: boolean;
|
---|
| 48 | unauthenticated: boolean;
|
---|
| 49 | logout: () => Promise<void>;
|
---|
| 50 | loginWithGoogle: () => Promise<void>;
|
---|
| 51 | loginWithGithub: () => Promise<void>;
|
---|
| 52 | loginWithTwitter: () => Promise<void>;
|
---|
| 53 | forgotPassword?: (email: string) => Promise<void>;
|
---|
| 54 | login: (email: string, password: string) => Promise<void>;
|
---|
| 55 | register: (email: string, password: string, firstName: string, lastName: string) => Promise<void>;
|
---|
| 56 | };
|
---|