첫 커밋
This commit is contained in:
109
src/pages/home/home-page.tsx
Normal file
109
src/pages/home/home-page.tsx
Normal file
@@ -0,0 +1,109 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { getLocalStorage } from '@/shared/lib';
|
||||
import { StorageKeys } from '@/shared/constants/local-storage';
|
||||
import { useUserInfo } from '@/entities/user/lib/use-user-info';
|
||||
import { FavoriteWrapper } from '@/entities/home/ui/favorite-wrapper';
|
||||
import { DayStatusBox } from '@/entities/home/ui/day-status-box';
|
||||
import { HomeBottomBanner } from '@/entities/home/ui/home-bottom-banner';
|
||||
import { AuthRegister } from '@/entities/home/ui/auth-reguster';
|
||||
import { FooterItemActiveKey } from '@/entities/common/model/types';
|
||||
import { HeaderType } from '@/entities/common/model/types';
|
||||
import {
|
||||
useSetHeaderTitle,
|
||||
useSetHeaderType,
|
||||
useSetFooterMode,
|
||||
useSetFooterCurrentPage
|
||||
} from '@/widgets/sub-layout/use-sub-layout';
|
||||
import moment from 'moment';
|
||||
|
||||
export const HomePage = () => {
|
||||
useSetHeaderTitle('');
|
||||
useSetHeaderType(HeaderType.Home);
|
||||
useSetFooterMode(true);
|
||||
useSetFooterCurrentPage(FooterItemActiveKey.Home);
|
||||
|
||||
const { callLogin } = useUserInfo();
|
||||
|
||||
const today = moment().format('YYYYMMDD').toString();
|
||||
let bannerToday = getLocalStorage(StorageKeys.BottomBannerClose);
|
||||
|
||||
const [bottomBannerOn, setBottomBannerOn] = useState<boolean>(false);
|
||||
const [authRegisterOn, setAuthRegisterOn] = useState<boolean>(false);
|
||||
|
||||
/*
|
||||
const userParmas = {
|
||||
id: 'thenaun12',
|
||||
password: 'answjddl1!'
|
||||
};
|
||||
*/
|
||||
|
||||
const userParmas = {
|
||||
id: 'nictest00',
|
||||
password: 'nictest00'
|
||||
};
|
||||
|
||||
const handleLogin = useCallback(async () =>{
|
||||
await callLogin(userParmas);
|
||||
}, []);
|
||||
const checkBottomBannerOpen = () => {
|
||||
if(!!bannerToday){
|
||||
bannerToday = bannerToday.toString();
|
||||
}
|
||||
let sw = (today !== bannerToday);
|
||||
setBottomBannerOn(sw);
|
||||
};
|
||||
const checkAuthRegisterOpen = () => {
|
||||
setAuthRegisterOn(true);
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
handleLogin();
|
||||
checkBottomBannerOpen();
|
||||
checkAuthRegisterOpen();
|
||||
}, []);
|
||||
|
||||
const setBottomBannerEffect = (mode: boolean) => {
|
||||
setBottomBannerOn(mode);
|
||||
if(mode === false){
|
||||
if(authRegisterOn){
|
||||
setAuthRegisterOn(false);
|
||||
setTimeout(() => {
|
||||
setAuthRegisterOn(true);
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*useLoginMutation
|
||||
const [userInfo] = useStore(
|
||||
useShallow((state) => [state.userSlice.userInfo]),
|
||||
);
|
||||
|
||||
*/
|
||||
// useRefreshUserInfo();
|
||||
return (
|
||||
<>
|
||||
<main>
|
||||
{/*<!-- 탭 컨텐츠 영역 -->*/}
|
||||
<div className="tab-content blue">
|
||||
<div className="tab-pane dashboard active" id="tab1">
|
||||
<FavoriteWrapper></FavoriteWrapper>
|
||||
<DayStatusBox></DayStatusBox>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<HomeBottomBanner
|
||||
setBottomBannerOn={ setBottomBannerEffect }
|
||||
bottomBannerOn={ bottomBannerOn }
|
||||
></HomeBottomBanner>
|
||||
{ (!bottomBannerOn) &&
|
||||
<AuthRegister
|
||||
setAuthRegisterOn={ setAuthRegisterOn }
|
||||
authRegisterOn={ authRegisterOn }
|
||||
></AuthRegister>
|
||||
}
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user