Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 프로젝트 전체 Redirect 설정 #188

Merged
merged 5 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wdyta",
"version": "0.6.0",
"version": "1.0.0",
"type": "module",
"private": true,
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions src/app/@modal/(.)modal/common/authAlert/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AlertModal } from '@/components/@common/modal';
import { Modal } from '@/shared/ui/Modal';

const AuthAlertModal = () => {
return (
<Modal size="xsmall" closeIcon={false}>
<AlertModal
errorMessage="이미 로그인된 상태입니다"
buttonText="홈으로 가기"
path="/"
/>
</Modal>
);
};

export default AuthAlertModal;
16 changes: 16 additions & 0 deletions src/app/@modal/(.)modal/common/loginAlert/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AlertModal } from '@/components/@common/modal';
import { Modal } from '@/shared/ui/Modal';

const LoginAlertModal = () => {
return (
<Modal size="small" closeIcon={false}>
<AlertModal
errorMessage="로그인 후 이용해 주세요"
buttonText="로그인 하러 가기"
path="/login"
/>
</Modal>
);
};

export default LoginAlertModal;
6 changes: 6 additions & 0 deletions src/app/@modal/(.)modal/detail/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { EditModal } from '@/components/Detail/modal';
import { Modal } from '@/shared/ui/Modal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductEditModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="large" closeIcon>
<EditModal accessToken={accessToken} />
Expand Down
6 changes: 6 additions & 0 deletions src/app/@modal/(.)modal/detail/review/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { ReviewModal } from '@/components/Detail/modal';
import { Modal } from '@/shared/ui/Modal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductReviewModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="medium" closeIcon>
<ReviewModal accessToken={accessToken} />
Expand Down
5 changes: 5 additions & 0 deletions src/app/@modal/(.)modal/detail/reviewEdit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { ReviewEditModal } from '@/components/Detail/modal';
import { Modal } from '@/shared/ui/Modal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductReviewEditModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="medium" closeIcon>
<ReviewEditModal accessToken={accessToken} />
Expand Down
6 changes: 6 additions & 0 deletions src/app/@modal/(.)modal/home/productAdd/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Modal } from '@/shared/ui/Modal';
import { AddModal } from '@/components/Home/modal/AddModal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductAddModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="medium" closeIcon>
<AddModal accessToken={accessToken} title="상품 추가" />
Expand Down
12 changes: 0 additions & 12 deletions src/app/@modal/(.)modal/profile/loginAlert/page.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions src/app/@modal/(.)modal/profile/profileEdit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import EditModal from '@/components/Profile/modal/EditModal';
import { getUserCookies } from '@/shared/@common/utils/getUserCookies';
import { Modal } from '@/shared/ui/Modal';
import { redirect } from 'next/navigation';

const ProfileEdit = () => {
const { accessToken, loginedId } = getUserCookies();

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="large" closeIcon>
<EditModal accessToken={accessToken} loginedId={loginedId} />
Expand Down
5 changes: 5 additions & 0 deletions src/app/@modal/(.)modal/profile/userFollowList/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import UserListModal from '@/components/Profile/modal/UserListModal';
import { SkeletonUserListModal } from '@/components/Profile/skeleton';
import { getUserCookies } from '@/shared/@common/utils/getUserCookies';
import { Modal } from '@/shared/ui/Modal';
import { redirect } from 'next/navigation';
import { Suspense } from 'react';

const UserFollowList = () => {
const { accessToken, loginedId } = getUserCookies();

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="small" closeIcon>
<Suspense fallback={<SkeletonUserListModal />}>
Expand Down
6 changes: 6 additions & 0 deletions src/app/[category]/[product]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
} from '@/components/Detail/skeletons';
import { ProductStatistics } from '@/components/Detail/ProductStatistics';
import { ProductReviews } from '@/components/Detail/ProductReviews';
import { URL_CATEGORIES } from '@/shared/@common/constants';
import { notFound } from 'next/navigation';

const DetailPage = ({
params,
Expand All @@ -29,6 +31,10 @@ const DetailPage = ({
const accessToken = cookies().get('accessToken')?.value ?? '';
const userId = Number(cookies().get('userId')?.value);

if (!URL_CATEGORIES.includes(category)) {
notFound();
}

const queryClient = getQueryClient();
queryClient.prefetchQuery(productOptions(productId, accessToken));
queryClient.prefetchInfiniteQuery(
Expand Down
6 changes: 6 additions & 0 deletions src/app/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { SkeletonReviewerRanking } from '@/components/Home/skeletons/SkeletonRev
import { ReviewerRanking } from '@/components/Home/ReviewerRanking/ReviewerRanking';
import { convertCategoryToId } from '@/shared/@common/utils';
import { SideMenu } from '@/shared/ui/Menu/SideMenu';
import { URL_CATEGORIES } from '@/shared/@common/constants';
import { notFound } from 'next/navigation';
import { homeProductOptions, rankingOptions } from './homeQueryOptions';

const FilteredHome = ({
Expand All @@ -22,6 +24,10 @@ const FilteredHome = ({
const currentSearchWord = searchParams.keyword;
const currentFilter = searchParams.order;

if (!URL_CATEGORIES.includes(category)) {
notFound();
}

const queryClient = getQueryClient();
queryClient.prefetchQuery(rankingOptions());
queryClient.prefetchInfiniteQuery(
Expand Down
16 changes: 16 additions & 0 deletions src/app/modal/common/authAlert/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AlertModal } from '@/components/@common/modal';
import { Modal } from '@/shared/ui/Modal';

const AuthAlertModal = () => {
return (
<Modal size="xsmall" closeIcon={false}>
<AlertModal
errorMessage="이미 로그인된 상태입니다"
buttonText="홈으로 가기"
path="/"
/>
</Modal>
);
};

export default AuthAlertModal;
16 changes: 16 additions & 0 deletions src/app/modal/common/loginAlert/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AlertModal } from '@/components/@common/modal';
import { Modal } from '@/shared/ui/Modal';

const LoginAlertModal = () => {
return (
<Modal size="small" closeIcon={false}>
<AlertModal
errorMessage="로그인 후 이용해 주세요"
buttonText="로그인 하러 가기"
path="/login"
/>
</Modal>
);
};

export default LoginAlertModal;
6 changes: 6 additions & 0 deletions src/app/modal/detail/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { EditModal } from '@/components/Detail/modal';
import { Modal } from '@/shared/ui/Modal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductEditModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="large" closeIcon>
<EditModal accessToken={accessToken} />
Expand Down
6 changes: 6 additions & 0 deletions src/app/modal/detail/review/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { ReviewModal } from '@/components/Detail/modal';
import { Modal } from '@/shared/ui/Modal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductReviewModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="medium" closeIcon>
<ReviewModal accessToken={accessToken} />
Expand Down
5 changes: 5 additions & 0 deletions src/app/modal/detail/reviewEdit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { ReviewEditModal } from '@/components/Detail/modal';
import { Modal } from '@/shared/ui/Modal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductReviewEditModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="medium" closeIcon>
<ReviewEditModal accessToken={accessToken} />
Expand Down
6 changes: 6 additions & 0 deletions src/app/modal/home/productAdd/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Modal } from '@/shared/ui/Modal';
import { AddModal } from '@/components/Home/modal/AddModal';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

const ProductAddModal = () => {
const accessToken = cookies().get('accessToken')?.value ?? '';

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="medium" closeIcon>
<AddModal accessToken={accessToken} title="상품 추가" />
Expand Down
12 changes: 0 additions & 12 deletions src/app/modal/profile/loginAlert/page.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions src/app/modal/profile/profileEdit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import EditModal from '@/components/Profile/modal/EditModal';
import { getUserCookies } from '@/shared/@common/utils/getUserCookies';
import { Modal } from '@/shared/ui/Modal';
import { redirect } from 'next/navigation';

const ProfileEdit = () => {
const { accessToken, loginedId } = getUserCookies();

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="large" closeIcon>
<EditModal accessToken={accessToken} loginedId={loginedId} />
Expand Down
5 changes: 5 additions & 0 deletions src/app/modal/profile/userFollowList/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import UserListModal from '@/components/Profile/modal/UserListModal';
import { SkeletonUserListModal } from '@/components/Profile/skeleton';
import { getUserCookies } from '@/shared/@common/utils/getUserCookies';
import { Modal } from '@/shared/ui/Modal';
import { redirect } from 'next/navigation';
import { Suspense } from 'react';

const UserFollowList = () => {
const { accessToken, loginedId } = getUserCookies();

if (!accessToken) {
redirect('/modal/common/loginAlert');
}

return (
<Modal size="small" closeIcon>
<Suspense fallback={<SkeletonUserListModal />}>
Expand Down
2 changes: 1 addition & 1 deletion src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function Profile({ searchParams }: ProfileProps) {
),
);
if (!accessToken && !userId) {
redirect('/login');
redirect('/modal/common/loginAlert');
}
return (
<main className="flex justify-center items-start md:flex-col mobile:flex-col md:items-center mobile:items-center md:min-w-[509px] mobile:min-w-[335px] lg:gap-[70px] gap-[60px] py-[52px] lg:px-[120px] md:px-[30px] mobile:px-[21px] ">
Expand Down
4 changes: 3 additions & 1 deletion src/components/Detail/ProductDetail/FavoriteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const FavoriteButton = ({

const handleClick = () => {
if (!accessToken) {
router.push('/login');
router.push('/modal/common/loginAlert', {
scroll: false,
});
}
favoriteMutation.mutate();
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/Detail/ProductReviews/LikeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export const LikeButton = ({

const handleClick = () => {
if (!accessToken) {
router.push('/login');
router.push('/modal/common/loginAlert', {
scroll: false,
});
}
likeMutation.mutate();
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/Profile/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export const ProfileCard = ({ loginedId, accessToken }: ProfileCardProps) => {

const handleClickFollow = () => {
if (!accessToken) {
router.push(`modal/profile/loginAlert?userId=${currentProfileId}`);
router.push(`/modal/common/loginAlert?userId=${currentProfileId}`, {
scroll: false,
});
return;
}
followMutation.mutate({ isFollowing });
Expand Down
Loading