박권수

feat. login api edit

......@@ -9,8 +9,8 @@ export const token = atom({
effects_UNSTABLE : [persistAtom],
});
export const userType = atom({
key : 'userType',
export const userTypeCd = atom({
key : 'userTypeCd',
default : 'NORMAL',
effects_UNSTABLE : [persistAtom],
});
\ No newline at end of file
......
......@@ -18,7 +18,7 @@ const LoginContainer = (props : LoginProps) => {
password : '',
});
const [token, setToken] = useRecoilState(recoilUtil.token);
const [userType, setUserType] = useRecoilState(recoilUtil.userType);
const [userTypeCd, setUserTypeCd] = useRecoilState(recoilUtil.userTypeCd);
const onSetUserId = (e : React.ChangeEvent<HTMLInputElement>) => {
setLoginForm({
......@@ -39,6 +39,7 @@ const LoginContainer = (props : LoginProps) => {
const result : any = await authApi.login(loginForm);
if(result.statusText === 'OK') {
setToken(result.data.token);
setUserTypeCd(result.data.userTypeCd);
props.history.push('/');
}
} catch(e) {
......
......@@ -14,7 +14,7 @@ type MainProps = RouteComponentProps
const MainContainer = (props : MainProps) => {
const token = useRecoilValue(recoilUtil.token);
const userType = useRecoilValue(recoilUtil.userType);
const userTypeCd = useRecoilValue(recoilUtil.userTypeCd);
useEffect(() => {
if(!token || !token.length) {
......@@ -24,7 +24,7 @@ const MainContainer = (props : MainProps) => {
return (
<MainPresenter
userType = {userType}
userTypeCd = {userTypeCd}
/>
);
};
......
......@@ -4,13 +4,13 @@ import * as styled from './MainStyled';
interface MainProps {
userType : string;
userTypeCd : string;
}
const MainPresenter = (props : MainProps) => {
return (
<styled.Container>
This is Main Page {props.userType}
This is Main Page {props.userTypeCd}
</styled.Container>
)
};
......