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

Refactor: 수정 페이지의 경로 activityId를 postId로 변경 #340

Merged
merged 1 commit into from
Apr 11, 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
6 changes: 3 additions & 3 deletions src/components/editPage/EditPageContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { useQuery } from '@tanstack/react-query';

import { getActivityDetail } from '@/apis/queryFunctions';
import { QUERY_KEYS } from '@/apis/queryKeys';
import { EditPageContentProps } from '@/pages/[game]/edit/[activityId]';
import { EditPageContentProps } from '@/pages/[game]/edit/[postId]';

import EditForm from '../EditForm';

import Banner from '@/components/layout/Banner';

const EditPageContent = ({ activityId, category }: EditPageContentProps) => {
const EditPageContent = ({ postId, category }: EditPageContentProps) => {
const { data } = useQuery({
queryKey: [QUERY_KEYS.activities.get, activityId],
queryKey: [QUERY_KEYS.activities.get, postId],
queryFn: getActivityDetail,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const { title, description, keywords } = META_DATA.edit;

export async function getServerSideProps(context: GetServerSidePropsContext) {
const game = context.params?.game;
const paramActivityId = context.params?.activityId;
const activityId = Number(paramActivityId);
const paramPostId = context.params?.postId;
const postId = Number(paramPostId);
const isValid = isValidGameName(game as string);

if (!isValid) {
Expand All @@ -36,26 +36,26 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
const category = GAME_T0_CATEGORY[gameName];

queryClient.prefetchQuery({
queryKey: [QUERY_KEYS.activities.get, activityId],
queryKey: [QUERY_KEYS.activities.get, postId],
queryFn: getActivityDetail,
});

return {
props: { dehydratedState: dehydrate(queryClient), activityId, gameName, category },
props: { dehydratedState: dehydrate(queryClient), postId, gameName, category },
};
}

export type EditPageContentProps = {
activityId: number;
postId: number;
gameName: GameNameEN;
category: Category;
};

const EditPage = ({ activityId, gameName, category }: EditPageContentProps) => {
const EditPage = ({ postId, gameName, category }: EditPageContentProps) => {
return (
<>
<MetaData title={title} description={description} keywords={keywords} />
<EditPageContent activityId={activityId} gameName={gameName} category={category} />
<EditPageContent postId={postId} gameName={gameName} category={category} />
</>
);
};
Expand Down