Skip to content

Commit

Permalink
Revert "[#608] 페이지 접근 권한 부여 (#611)"
Browse files Browse the repository at this point in the history
This reverts commit 7f1cd21.
  • Loading branch information
gxxrxn authored Aug 20, 2024
1 parent 4e13500 commit 921ab74
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 76 deletions.
18 changes: 9 additions & 9 deletions src/app/group/[groupId]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import {
import type { APIGroupDetail, APIEditBookGroup } from '@/types/group';

import { SERVICE_ERROR_MESSAGE } from '@/constants';
import { isAxiosErrorWithCustomCode } from '@/utils/helpers';
import useToast from '@/v1/base/Toast/useToast';
import {
checkAuthentication,
isAxiosErrorWithCustomCode,
} from '@/utils/helpers';

import withAuthRequired from '@/hocs/withAuthRequired';
import useToast from '@/v1/base/Toast/useToast';
import BookGroupEditDateForm from '@/v1/bookGroup/edit/BookGroupEditDateForm';
import BookGroupEditIntroduceForm from '@/v1/bookGroup/edit/BookGroupEditIntroduceForm';
import BookGroupEditTitleForm from '@/v1/bookGroup/edit/BookGroupEditTitleForm';
Expand All @@ -26,15 +28,13 @@ const BookGroupEditPage = ({
}) => {
const router = useRouter();

const isAuthenticated = checkAuthentication();

const { data: bookGroupData } = useBookGroupEditCurrentInfo(groupId);
const { isOwner, title, description, maxMemberCount, startDate, endDate } =
bookGroupData;

/**
* @todo
* 401 페이지 만들기 (접근 권한이 없어요)
*/
if (!isOwner) {
if (!isAuthenticated || !isOwner) {
notFound();
}

Expand Down Expand Up @@ -99,4 +99,4 @@ const BookGroupEditPage = ({
);
};

export default withAuthRequired(BookGroupEditPage);
export default BookGroupEditPage;
6 changes: 2 additions & 4 deletions src/app/group/[groupId]/join/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { SubmitHandler, useForm } from 'react-hook-form';
import useJoinBookGroup from '@/hooks/group/useJoinBookGroup';

import SSRSafeSuspense from '@/components/SSRSafeSuspense';
import withAuthRequired from '@/hocs/withAuthRequired';

import Loading from '@/v1/base/Loading';
import Input from '@/v1/base/Input';
import InputLength from '@/v1/base/InputLength';
Expand Down Expand Up @@ -38,8 +36,6 @@ const JoinBookGroupPage = ({
);
};

export default withAuthRequired(JoinBookGroupPage);

const BookGroupJoinForm = ({ groupId }: { groupId: number }) => {
const router = useRouter();
const { isMember, hasPassword, question, joinBookGroup } =
Expand Down Expand Up @@ -104,3 +100,5 @@ const BookGroupJoinForm = ({ groupId }: { groupId: number }) => {
</form>
);
};

export default JoinBookGroupPage;
6 changes: 1 addition & 5 deletions src/app/group/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use client';

import withAuthRequired from '@/hocs/withAuthRequired';

import CreateBookGroupFunnel from '@/v1/bookGroup/create/CreateBookGroupFunnel';

const GroupCreateFunnelPage = () => {
return <CreateBookGroupFunnel />;
};

export default withAuthRequired(GroupCreateFunnelPage);
export default GroupCreateFunnelPage;
8 changes: 3 additions & 5 deletions src/app/profile/me/add/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import useAllJobQuery from '@/queries/job/useAllJobQuery';

import { checkAuthentication } from '@/utils/helpers';

import SSRSafeSuspense from '@/components/SSRSafeSuspense';
import withAuthRequired from '@/hocs/withAuthRequired';

import AddJobProfile from '@/v1/profile/AddJobProfile';
import SSRSafeSuspense from '@/components/SSRSafeSuspense';

const AddJobProfilePage = () => {
return (
Expand All @@ -17,8 +15,6 @@ const AddJobProfilePage = () => {
);
};

export default withAuthRequired(AddJobProfilePage);

const Contents = () => {
const isAuthenticated = checkAuthentication();
const allJobQuery = useAllJobQuery({ enabled: isAuthenticated });
Expand All @@ -27,3 +23,5 @@ const Contents = () => {
<AddJobProfile jobCategories={allJobQuery.data.jobGroups} />
) : null;
};

export default AddJobProfilePage;
14 changes: 8 additions & 6 deletions src/app/profile/me/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import useMyProfileQuery from '@/queries/user/useMyProfileQuery';

import { checkAuthentication } from '@/utils/helpers';

import EditProfile from '@/v1/profile/EditProfile';
import SSRSafeSuspense from '@/components/SSRSafeSuspense';
import withAuthRequired from '@/hocs/withAuthRequired';

import EditProfile from '@/v1/profile/EditProfile';
import Loading from '@/v1/base/Loading';
/**
* @todo
* Fallback UI 추가하기
*/

const EditProfilePage = () => {
return (
<SSRSafeSuspense fallback={<Loading fullpage />}>
<SSRSafeSuspense fallback={null}>
<Contents />
</SSRSafeSuspense>
);
};

export default withAuthRequired(EditProfilePage);

const Contents = () => {
const isAuthenticated = checkAuthentication();
const allJobQuery = useAllJobQuery({ enabled: isAuthenticated });
Expand All @@ -30,3 +30,5 @@ const Contents = () => {
<EditProfile profile={profileData} jobGroups={allJobQuery.data.jobGroups} />
) : null;
};

export default EditProfilePage;
6 changes: 2 additions & 4 deletions src/app/profile/me/group/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import useMyGroupsQuery from '@/queries/group/useMyGroupQuery';
import { checkAuthentication } from '@/utils/helpers';

import SSRSafeSuspense from '@/components/SSRSafeSuspense';
import withAuthRequired from '@/hocs/withAuthRequired';

import BackButton from '@/v1/base/BackButton';
import TopNavigation from '@/v1/base/TopNavigation';
import DetailBookGroupCard from '@/v1/bookGroup/DetailBookGroupCard';
Expand All @@ -26,8 +24,6 @@ const UserGroupPage = () => {
);
};

export default withAuthRequired(UserGroupPage);

const UserGroupContent = () => {
const isAuthenticated = checkAuthentication();
const { data } = useMyGroupsQuery({ enabled: isAuthenticated });
Expand Down Expand Up @@ -69,6 +65,8 @@ const UserGroupContent = () => {
);
};

export default UserGroupPage;

const PageSkeleton = () => (
<ul className="flex animate-pulse flex-col gap-[1rem] pt-[2rem]">
{Array.from({ length: 4 }).map((_, index) => (
Expand Down
36 changes: 0 additions & 36 deletions src/hocs/withAuthRequired.tsx

This file was deleted.

9 changes: 2 additions & 7 deletions src/v1/profile/group/ProfileGroupContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import useMyGroupsQuery from '@/queries/group/useMyGroupQuery';
import useMyProfileQuery from '@/queries/user/useMyProfileQuery';
import type { APIUser } from '@/types/user';

import { checkAuthentication } from '@/utils/helpers';

import { APIUser } from '@/types/user';
import ProfileGroupPresenter from './ProfileGroupPresenter';

const ProfileGroupContainer = ({
userId,
}: {
userId: 'me' | APIUser['userId'];
}) => {
const isAuthenticated = checkAuthentication();

const { data } = useMyGroupsQuery({ enabled: isAuthenticated });
const { data } = useMyGroupsQuery();
const {
data: { userId: myId },
} = useMyProfileQuery({ enabled: userId === 'me' });
Expand Down

0 comments on commit 921ab74

Please sign in to comment.