Skip to content

Commit

Permalink
refactor: root page 라우터 landing page로 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
se0kcess committed Dec 9, 2024
1 parent 7f46383 commit f9d8429
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/components/RootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Outlet, useLocation } from 'react-router-dom';

const RootLayout = () => {
const location = useLocation();
const isFooterHidden = location.pathname.startsWith('/chatroom');
const isFooterHidden = location.pathname === '/' || location.pathname.startsWith('/chatroom');
return (
<div>
<main className='container'>
<main className="container">
<Outlet />
</main>
{!isFooterHidden && <Footer />}
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface FooterProps {

const menuItems = [
{
path: '/',
path: '/main',
label: '홈',
icon: HomeIcon,
activeIcon: HomeIconClicked,
Expand All @@ -54,7 +54,7 @@ const menuItems = [

const Footer = ({ maxWidth = '425px' }: FooterProps) => {
const navigate = useNavigate();
const [value, setValue] = useState<string>('/');
const [value, setValue] = useState<string>('/main');
const [hoveredPath, setHoveredPath] = useState<string | null>(null);
const handleNavigation = (newValue: string) => {
setValue(newValue);
Expand Down
2 changes: 1 addition & 1 deletion src/constants/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const ROUTES = {
ROOT: '/',
MAIN: '',
MAIN: '/main',
CHAT: '/chat',
MYPAGE: '/mypage',
LANDING: '/landing',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Error/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ErrorPage = () => {
const navigate = useNavigate();

const handleHomeClick = () => {
navigate('/');
navigate('/main');
};

return (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Event/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ const EventPage = () => {
console.log(
`답변: ${answer}\n공개 여부: ${isPrivate ? '비공개' : '공개'}\n이미지: ${uploadedImage ? uploadedImage.name : '없음'}`
);
navigate('/');
navigate('/main');
};

return (
<>
<Header title='이벤트' />
<Header title="이벤트" />
<Container>
<Title>Special Question</Title>
<Question>다가오는 크리스마스, 주연님의 크리스마스 계획은?</Question>
Expand Down
10 changes: 10 additions & 0 deletions src/pages/Landing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { Logo } from '@/components/ui/Logo/Logo';
import { STYLE } from '@/pages/Landing/Constants/style';
import { Container, LogoWrapper, SubTitle, Title } from '@/pages/Landing/styles';
import { useEffect } from 'react';
import { useNavigate } from 'react-router';

const LandingPage = () => {
const navigate = useNavigate();
useEffect(() => {
// 3초 후에 로그인 페이지로 자동 이동
const timer = setTimeout(() => {
navigate('/login');
}, 1000);

// 컴포넌트가 언마운트될 때 타이머 정리
return () => clearTimeout(timer);
}, []);
const handleClick = () => {
navigate('/login');
};
Expand Down
4 changes: 2 additions & 2 deletions src/pages/MyPage/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Title,
RightSection,
IconButton,
} from '@/pages/MyPage/components/Header/Header.styles'
} from '@/pages/MyPage/components/Header/Header.styles';

interface HeaderProps {
profileImage?: string;
Expand All @@ -19,7 +19,7 @@ const Header = ({ className, title }: HeaderProps) => {
const navigate = useNavigate();

const onLogoClick = () => {
navigate('/');
navigate('/main');
};

const handleNotificationClick = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/QSpace/hooks/Query/useGroupList.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { GROUP_KEYS } from '@/api/queryKeys';
import { fetchGroups } from '@/pages/QSpace/api/fetchGroups';
import { useQuery } from '@tanstack/react-query';

export const useGroups = (categoryId: number) => {
return useQuery({
queryKey: ['groups', 'list', categoryId] as const,
queryKey: [GROUP_KEYS.ROOT, GROUP_KEYS.ACTIONS.LIST, categoryId] as const,
queryFn: () => fetchGroups(categoryId),
enabled: categoryId !== undefined,
staleTime: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/QSpace/hooks/Query/useMemberList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { groupAPI } from '@/pages/QSpace/api/groupAPI';

export const useMemberList = (groupId: number) => {
return useQuery<GroupMember[]>({
queryKey: [GROUP_KEYS.ROOT, groupId, 'members'],
queryKey: [GROUP_KEYS.ROOT, GROUP_KEYS.ACTIONS.MEMBERS, groupId],
queryFn: async () => {
const response = await groupAPI.getGroupMembers(groupId);
if (!response.success || !response.data) {
Expand Down
16 changes: 9 additions & 7 deletions src/pages/Question/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ const QuestionPage = () => {
const [isPrivate, setIsPrivate] = useState(true);
const [uploadedImage, setUploadedImage] = useState<File | null>(null);

const { data: question, isLoading: loadingQuestion, error: questionError } =
useQuestions(categoryIdMap[category as string]);
const {
data: question,
isLoading: loadingQuestion,
error: questionError,
} = useQuestions(categoryIdMap[category as string]);
const { mutate: createAnswer, error: isCreateAnswerError } = useCreateAnswer();

const handleImageUpload = (file: File | null) => {
Expand All @@ -36,7 +39,8 @@ const QuestionPage = () => {

const handleSubmit = () => {
console.log(
`답변: ${answer}\n공개 여부: ${isPrivate ? '비공개' : '공개'}\n이미지: ${uploadedImage ? uploadedImage.name : '없음'
`답변: ${answer}\n공개 여부: ${isPrivate ? '비공개' : '공개'}\n이미지: ${
uploadedImage ? uploadedImage.name : '없음'
}`
);

Expand All @@ -50,7 +54,7 @@ const QuestionPage = () => {
createAnswer(createAnswerRequest, {
onSuccess: (data: CreateAnswerResponse) => {
console.log('Answer created:', data.message);
navigate('/');
navigate('/main');
},
onError: (err) => {
console.error('Error creating answer:', err);
Expand Down Expand Up @@ -100,9 +104,7 @@ const QuestionPage = () => {
const PageLayout = ({ children }: { children: React.ReactNode }) => (
<>
<Header />
<Container>
{children}
</Container>
<Container>{children}</Container>
</>
);

Expand Down
2 changes: 1 addition & 1 deletion src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const router = createBrowserRouter([
element: <MyPage />,
},
{
path: ROUTES.LANDING, //랜딩페이지
path: ROUTES.ROOT, //랜딩페이지
element: <LandingPage />,
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface CookieOptions {
}

const defaultOptions: CookieOptions = {
path: '/',
path: '/main',
secure: process.env.NODE_ENV === 'production',
sameSite: 'strict',
};
Expand Down

0 comments on commit f9d8429

Please sign in to comment.