File size: 874 Bytes
6e3eead |
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 |
import { useCallback } from 'react';
import { useDispatch } from 'umi';
export interface ILoginRequestBody {
email: string;
password: string;
}
export interface IRegisterRequestBody extends ILoginRequestBody {
nickname: string;
}
export const useLogin = () => {
const dispatch = useDispatch();
const login = useCallback(
(requestBody: ILoginRequestBody) => {
// TODO: Type needs to be improved
return dispatch<any>({
type: 'loginModel/login',
payload: requestBody,
});
},
[dispatch],
);
return login;
};
export const useRegister = () => {
const dispatch = useDispatch();
const register = useCallback(
(requestBody: IRegisterRequestBody) => {
return dispatch<any>({
type: 'loginModel/register',
payload: requestBody,
});
},
[dispatch],
);
return register;
};
|