Skip to content

Commit

Permalink
Fix: series페이지를 메인페이지로
Browse files Browse the repository at this point in the history
  • Loading branch information
dongree committed Oct 22, 2023
1 parent c2907f0 commit 7a8c406
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 48 deletions.
8 changes: 4 additions & 4 deletions src/app/create/memo/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EditorForm from '@/components/create/memo/EditorForm';
import LayoutWrapper from '@/components/shared/LayoutWrapper';
import { checkUser } from '@/service/auth';
import { ACCESS_TOKEN, REFRESH_TOKEN } from '@/utils/const';
import { ACCESS_TOKEN, MAIN_PATH, REFRESH_TOKEN } from '@/utils/const';
import { Metadata } from 'next';
import { cookies, headers } from 'next/headers';
import { redirect } from 'next/navigation';
Expand All @@ -12,9 +12,9 @@ export const metadata: Metadata = {
};

export default async function CreateMemoPage() {
// const headersList = headers();
// const referer = headersList.get('referer');
// referer === null && redirect('/memos');
const headersList = headers();
const referer = headersList.get('referer');
referer === null && redirect(MAIN_PATH);

const accessToken = cookies().get(ACCESS_TOKEN)?.value;
const refreshToken = cookies().get(REFRESH_TOKEN)?.value;
Expand Down
3 changes: 2 additions & 1 deletion src/app/create/question/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import QuestionEditorForm from '@/components/create/QuestionEditorForm';
import LayoutWrapper from '@/components/shared/LayoutWrapper';
import { MAIN_PATH } from '@/utils/const';
import { Metadata } from 'next';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';
Expand All @@ -12,7 +13,7 @@ export const metadata: Metadata = {
export default function CreateMemoPage() {
const headersList = headers();
const referer = headersList.get('referer');
referer === null && redirect('/memos');
referer === null && redirect(MAIN_PATH);

return (
<LayoutWrapper paddingY="sm:py-10">
Expand Down
3 changes: 2 additions & 1 deletion src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Metadata } from 'next';
import Link from 'next/link';
import logo from '@/assets/inforum_logo.png';
import Image from 'next/image';
import { MAIN_PATH } from '@/utils/const';

export const metadata: Metadata = {
title: '로그인',
Expand All @@ -14,7 +15,7 @@ export default function LoginPage() {
return (
<section className="relative flex flex-col w-full items-center max-w-screen-sm mx-auto mt-32 py-5 px-10 sm:px-32">
<Link
href="/memos"
href={MAIN_PATH}
className="absolute top-2 right-4 text-soma-grey-50 text-sm sm:text-base"
>
메인으로
Expand Down
14 changes: 8 additions & 6 deletions src/app/me/[slug]/drafts/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import LayoutWrapper from '@/components/shared/LayoutWrapper';
import MeDraftContainer from '@/components/me/MeDraftContainer';
import { checkUser, getUserInfo } from '@/service/auth';
import { cookies } from 'next/headers';
import { ACCESS_TOKEN, REFRESH_TOKEN } from '@/utils/const';
import { ACCESS_TOKEN, MAIN_PATH, REFRESH_TOKEN } from '@/utils/const';
import { Metadata } from 'next';
import { redirect } from 'next/navigation';
import { getNotificationsTop30 } from '@/service/notification';
Expand All @@ -29,15 +29,17 @@ export default async function MeDraftPage({ params: { slug } }: Props) {
? await getUserInfo(id)
: { profileImageFilePath: undefined };

const notifications = isLogin
? await getNotificationsTop30(cookie)
: [];
const notifications = isLogin ? await getNotificationsTop30(cookie) : [];

id !== Number(slug) && redirect('/memos');
id !== Number(slug) && redirect(MAIN_PATH);

return (
<section>
<Header isLogin={isLogin} notifications={notifications} profileImageFilePath={profileImageFilePath} />
<Header
isLogin={isLogin}
notifications={notifications}
profileImageFilePath={profileImageFilePath}
/>
<LayoutWrapper paddingY="sm:py-5">
<MeDraftContainer memos={memos} isMine={id === Number(slug)} />
</LayoutWrapper>
Expand Down
3 changes: 2 additions & 1 deletion src/app/me/setting/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MyInfoForm from '@/components/MyInfoForm';
import { getUserInfo } from '@/service/auth';
import { getDefaultTags } from '@/service/tag';
import { MAIN_PATH } from '@/utils/const';
import { Metadata } from 'next';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';
Expand All @@ -14,7 +15,7 @@ type Props = {
export default async function MySettingPage({ params: { slug } }: Props) {
const headersList = headers();
const referer = headersList.get('referer');
if (referer === null) redirect('/memos');
if (referer === null) redirect(MAIN_PATH);

const userData = getUserInfo(slug);
const defaultTagsData = getDefaultTags();
Expand Down
3 changes: 2 additions & 1 deletion src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Image from 'next/image';
import image404 from '@/assets/image404.png';
import Link from 'next/link';
import { MAIN_PATH } from '@/utils/const';

export default function NotFoundPage() {
return (
<div className="flex flex-col w-screen h-screen items-center justify-center">
<Image src={image404} alt="image404" />
<h3 className="font-bold text-5xl">페이지를 찾지 못했습니다!</h3>
<Link
href="/memos"
href={MAIN_PATH}
className="flex justify-center items-center font-medium bg-soma-blue-40 w-72 h-16 shadow-2xl text-white px-3.5 py-2 rounded-3xl transition hover:bg-soma-blue-50 sm:text-2xl mt-10"
>
홈으로 가기
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import LandingContainer from '@/components/landing/LandingContainer';
import { checkUser } from '@/service/auth';
import { ACCESS_TOKEN, REFRESH_TOKEN } from '@/utils/const';
import { ACCESS_TOKEN, MAIN_PATH, REFRESH_TOKEN } from '@/utils/const';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

Expand All @@ -11,7 +11,7 @@ export default async function LandingPage() {

const { isLogin } = await checkUser(cookie);

isLogin && redirect('/memos');
isLogin && redirect(MAIN_PATH);

return <LandingContainer />;
}
3 changes: 2 additions & 1 deletion src/app/signup/nickname/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import NicknameForm from '@/components/signup/NicknameForm';
import { MAIN_PATH } from '@/utils/const';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';

Expand All @@ -11,7 +12,7 @@ type Props = {
export default function SignupNicknameSettingPage({ params: { slug } }: Props) {
const headersList = headers();
const referer = headersList.get('referer');
referer === null && redirect('/memos');
referer === null && redirect(MAIN_PATH);

return <NicknameForm userId={Number(slug)} />;
}
3 changes: 2 additions & 1 deletion src/app/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import logo from '@/assets/inforum_logo.png';
import { join } from 'path';
import fs from 'fs';
import SignupBox from '@/components/signup/SignupBox';
import { MAIN_PATH } from '@/utils/const';

export const metadata: Metadata = {
title: '회원가입',
Expand Down Expand Up @@ -32,7 +33,7 @@ export default function SignupPage() {
return (
<section className="relative flex flex-col w-full items-center max-w-screen-sm mx-auto mt-12 py-5 px-10 sm:px-32">
<Link
href="/memos"
href={MAIN_PATH}
className="absolute top-2 right-4 text-soma-grey-50 text-sm sm:text-base"
>
메인으로
Expand Down
7 changes: 4 additions & 3 deletions src/app/signup/setting/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { headers } from 'next/headers';
import { getDefaultTags } from '@/service/tag';
import logo from '@/assets/inforum_logo.png';
import Image from 'next/image';
import { MAIN_PATH } from '@/utils/const';

type Props = {
params: {
Expand All @@ -12,10 +13,10 @@ type Props = {
};

export default async function SignupSettingPage({ params: { slug } }: Props) {
// const headersList = headers();
// const referer = headersList.get('referer');
const headersList = headers();
const referer = headersList.get('referer');

// if (referer === null) redirect('/memos');
if (referer === null) redirect(MAIN_PATH);

const defaultTags = await getDefaultTags();

Expand Down
6 changes: 3 additions & 3 deletions src/components/MyInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { checkUser, registerUserInfo, updateUserInfo } from '@/service/auth';
import { UserInfo } from '@/types';
import Tag from './shared/Tag';
import { notifyToast } from '@/service/notify';
import { MAX_PROFILE_IMAGE_BYTE } from '@/utils/const';
import { MAIN_PATH, MAX_PROFILE_IMAGE_BYTE } from '@/utils/const';

type Props = {
userId: number;
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function MyInfoForm({
}
checkUser().then((data) => {
notifyToast(res.message, 'success');
router.push(data.isLogin ? '/memos' : '/login');
router.push(data.isLogin ? MAIN_PATH : '/login');
router.refresh();
});
})
Expand Down Expand Up @@ -185,7 +185,7 @@ export default function MyInfoForm({
<div className="flex flex-col gap-2 my-3">
<BlueBtn text={isSignup ? '등록' : '수정'} onClick={() => {}} />
{isSignup && (
<Link href="/memos">
<Link href={MAIN_PATH}>
<WhiteBtn text="나중에" onClick={() => {}} extraStyle="w-full" />
</Link>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/landing/LandingContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import editUnderline from '@/assets/icons/edit_underline.svg';
import speechBubble from '@/assets/icons/speech_bubble.svg';
import Footer from '@/components/shared/Footer';
import down from '@/assets/icons/down.svg';
import { MAIN_PATH } from '@/utils/const';

export default function LandingContainer() {
const [readyState, setReadyState] = useState(false);
Expand Down Expand Up @@ -47,7 +48,7 @@ export default function LandingContainer() {
<br />
블럭 기반 에디터를 활용해 개발 기록을 간편하게 작성해보세요
</p>
<Link href="/memos">
<Link href={MAIN_PATH}>
<button className="bg-soma-blue-40 w-72 h-16 shadow-2xl text-white px-3.5 py-2 rounded-3xl transition hover:bg-soma-blue-50 sm:text-2xl">
시작하기
</button>
Expand Down Expand Up @@ -122,7 +123,7 @@ export default function LandingContainer() {
<br />
긍정적인 개발공간을 만들어보세요.
</p>
<Link href="/memos">
<Link href={MAIN_PATH}>
<button className="bg-soma-blue-40 w-72 h-16 shadow-2xl text-white px-3.5 py-2 rounded-3xl transition hover:bg-soma-blue-50 sm:text-2xl">
시작하기
</button>
Expand Down
3 changes: 2 additions & 1 deletion src/components/login/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ChangeEvent, FormEvent, useState } from 'react';
import BlueBtn from '../shared/btn/BlueBtn';
import { BASIC_INPUT_STYLE } from '@/utils/tailwindcss';
import { notifyToast } from '@/service/notify';
import { MAIN_PATH } from '@/utils/const';

export default function LoginForm() {
const router = useRouter();
Expand All @@ -28,7 +29,7 @@ export default function LoginForm() {
login(formdata).then((data) => {
notifyToast(data.message, data.isSuccess ? 'success' : 'error');
if (data.isSuccess) {
router.push('/memos');
router.push(MAIN_PATH);
router.refresh();
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/me/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { ModalContext } from '@/context/ModalProvider';
import { withdraw } from '@/service/auth';
import { notifyToast } from '@/service/notify';
import { MAIN_PATH } from '@/utils/const';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useContext } from 'react';
Expand Down Expand Up @@ -31,7 +32,7 @@ export default function Setting({ myId }: Props) {
return;
}
notifyToast('성공적으로 탈퇴되었습니다.', 'success');
router.push('/memos');
router.push(MAIN_PATH);
router.refresh();
});
}
Expand Down
41 changes: 21 additions & 20 deletions src/components/shared/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import RelativeDate from './RelativeDate';
import { checkNotifications } from '@/service/notification';
import { FaRankingStar } from 'react-icons/fa6';
import '@/styles/headerScrollbar.css';
import { MAIN_PATH } from '@/utils/const';

type Props = {
isLogin: boolean;
Expand Down Expand Up @@ -66,38 +67,38 @@ export default function Header({
alt="logo"
width={120}
onClick={() => {
router.push('/memos');
router.push(MAIN_PATH);
router.refresh();
}}
className="cursor-pointer absolute left-1 sm:left-3"
/>
<div className="sm:flex gap-4 font-semibold text-soma-grey-50 sm:text-lg hidden">
<Link
href="/memos"
href="/series"
className={`${
currentPage === 'memos' && 'text-soma-blue-40'
currentPage === 'series' && 'text-soma-blue-40'
} hover:text-soma-blue-40 transition-all`}
prefetch={false}
>
Memos
Series
</Link>
<Link
href="/questions"
href="/memos"
className={`${
currentPage === 'questions' && 'text-soma-blue-40'
currentPage === 'memos' && 'text-soma-blue-40'
} hover:text-soma-blue-40 transition-all`}
prefetch={false}
>
Q&A
Memos
</Link>
<Link
href="/series"
href="/questions"
className={`${
currentPage === 'series' && 'text-soma-blue-40'
currentPage === 'questions' && 'text-soma-blue-40'
} hover:text-soma-blue-40 transition-all`}
prefetch={false}
>
Series
Q&A
</Link>
</div>
{isLogin ? (
Expand Down Expand Up @@ -249,7 +250,7 @@ export default function Header({
setIsActive(false);
open('로그아웃 하시겠습니까?', () => {
logout().then(() => {
router.push('/memos');
router.push(MAIN_PATH);
router.refresh();
});
});
Expand Down Expand Up @@ -287,31 +288,31 @@ export default function Header({
</div>
<div className="sm:hidden gap-4 font-semibold text-soma-grey-50 sm:text-lg flex justify-center my-2">
<Link
href="/memos"
href="/series"
className={`${
currentPage === 'memos' && 'text-soma-blue-40'
currentPage === 'series' && 'text-soma-blue-40'
} hover:text-soma-blue-40 transition-all`}
prefetch={false}
>
Memos
Series
</Link>
<Link
href="/questions"
href="/memos"
className={`${
currentPage === 'questions' && 'text-soma-blue-40'
currentPage === 'memos' && 'text-soma-blue-40'
} hover:text-soma-blue-40 transition-all`}
prefetch={false}
>
Questions
Memos
</Link>
<Link
href="/series"
href="/questions"
className={`${
currentPage === 'series' && 'text-soma-blue-40'
currentPage === 'questions' && 'text-soma-blue-40'
} hover:text-soma-blue-40 transition-all`}
prefetch={false}
>
Series
Questions
</Link>
</div>
</header>
Expand Down
2 changes: 2 additions & 0 deletions src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export const MAX_IMAGE_BYTE = 10485760;
export const MEMO_NUMBER_PER_PAGE_FOR_INFINITY_SCROLL = 20;
export const SERIES_NUMBER_PER_PAGE_FOR_INFINITY_SCROLL = 20;
export const QUESTION_NUMBER_PER_PAGE_FOR_INFINITY_SCROLL = 10;

export const MAIN_PATH = '/series';

0 comments on commit 7a8c406

Please sign in to comment.