Skip to content

Commit

Permalink
fix: main 페이지의 type url에 저장
Browse files Browse the repository at this point in the history
  • Loading branch information
miro-ring committed Feb 23, 2024
1 parent fdd9f22 commit 3a2abb9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
13 changes: 9 additions & 4 deletions pages/main/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { useEffect, useRef, useState } from 'react';
import { useRouter, useSearchParams } from 'next/navigation';
import { useEffect, useRef } from 'react';

import WriteInput from '@components/Input/WriteInput';
import Layout from '@components/Layout';
import MainPageTab from '@components/Layout/MainPageTab';
import { ROUTES } from '@constants/routes';
import WriteGuide from '@domain/끄적이는/components/Guide';
import TemporalMemoHistoryTable from '@domain/끄적이는/components/History';
import TodayTemoralMemos from '@domain/끄적이는/components/Today';
Expand All @@ -16,6 +18,9 @@ import useGetMyProfile from '@queries/useGetMyProfile';
import { COLORS } from '@styles/tokens';

const MainPage = () => {
const router = useRouter();
const searchParams = useSearchParams();

useGetMyProfile();

const writeContentRef = useRef<HTMLDivElement>(null);
Expand All @@ -24,7 +29,7 @@ const MainPage = () => {
const { mutate: submitTemporalMemo } = useCreateTemporalMemo();
const { data: memoFolders } = useGetMemoFolders();

const [selectedTab, setSelectedTab] = useState('끄적이는');
const selectedTab = searchParams.get('type') || 'write';

useEffect(() => {
handleScroll();
Expand All @@ -37,7 +42,7 @@ const MainPage = () => {
};

const handleTabSelect = (selectedTab: string) => {
setSelectedTab(selectedTab);
router.push(`${ROUTES.MAIN}?type=${selectedTab}`);
};

const handleSubmit = () => {
Expand All @@ -48,7 +53,7 @@ const MainPage = () => {
};

const backgroundColor =
selectedTab === '참고하는' ? COLORS['Grey/100'] : undefined;
selectedTab === 'refer' ? COLORS['Grey/100'] : undefined;

return (
<Layout backgroundColor={backgroundColor}>
Expand Down
2 changes: 1 addition & 1 deletion pages/redirect/[authType]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Bridge = () => {
saveToken({ accessToken, refreshToken });
localStorage.setItem(STORAGE_KEY.RECENT_LOGIN_TYPE, authType);

router.replace(ROUTES.MAIN);
router.replace(`${ROUTES.MAIN}?type=write`);
})();
}, [router.query, router]);

Expand Down
8 changes: 4 additions & 4 deletions src/components/Layout/MainPageTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const MainPageTab = ({
<Tooltip hasArrow>
<Tooltip.Trigger>
<Tabs.Trigger
value="끄적이는"
value="write"
icon={{ default: 'pencilDefault', active: 'pencilActive' }}
>
끄적이는
Expand All @@ -40,7 +40,7 @@ const MainPageTab = ({
<Tooltip hasArrow>
<Tooltip.Trigger>
<Tabs.Trigger
value="참고하는"
value="refer"
icon={{ default: 'templateDefault', active: 'templateActive' }}
>
참고하는
Expand All @@ -52,8 +52,8 @@ const MainPageTab = ({
</div>

<section className={styles.tabWrapper}>
<Tabs.Content value="끄적이는">{write}</Tabs.Content>
<Tabs.Content value="참고하는">{refer}</Tabs.Content>
<Tabs.Content value="write">{write}</Tabs.Content>
<Tabs.Content value="refer">{refer}</Tabs.Content>
</section>
</Tabs>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Header = ({ type }: HeaderProps) => {
return (
<header className={styles.header}>
<Link
href={refreshToken ? ROUTES.MAIN : ROUTES.LANDING}
href={refreshToken ? `${ROUTES.MAIN}?type=write` : ROUTES.LANDING}
className={styles.logo}
>
<Logo />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const NotFoundArchiveCard = () => {
자주 사용하는 글과 템플릿을 저장해보세요.
</span>
</div>
<Button state="enabled" size="M" onClick={() => router.push(ROUTES.MAIN)}>
<Button
state="enabled"
size="M"
onClick={() => router.push(`${ROUTES.MAIN}?type=refer`)}
>
문장 템플릿 보러가기
</Button>
</div>
Expand Down

0 comments on commit 3a2abb9

Please sign in to comment.