Skip to content

Commit

Permalink
[7/3] Develop -> main 최신화 (#210)
Browse files Browse the repository at this point in the history
* Feat: 에러바운더리 디자인 수정 (#183)

* 마이페이지 관련 수정 (버튼 동작 및 ui 수정) (#185)

* feat: 마이페이지에서 행성 만들기 버튼 동작 수정

* refactor: icon에 fill 제거

* refactor: 주민증없는 경우 ui 수정

* Fix/comment 3 (#192)

* Fix: response type 수정

* Fix: comment error 수정 #159

* 404 페이지 (#194)

* feat: error-ufo

* feat: not-found page

* Community route (#195)

* feat: 행성 만들기 routing #170

* feat: #172 행성 id 기본값, communityTitle 제거

* refactor: switchCommunity 타입변경 반영

* style: cspell 추가

* feat: 마이페이지 행성 분기 로직

* feat: 행성 목록 user id

* fix: coverImageUrl type null 처리

* feat: 행성 로고 기본 이미지 적용

* feat: 행성 기본 이미지

* feat: 행성 꾸미기 페이지

* feat: community -> planet 경로 수정

* feat: community -> planet 경로 수정

* feat: 행성 꾸미기 후 라우팅

* feat: 행성 꾸미기 설명 추가

* Add routing logic (#196)

* Feat: Add routing logic when planet is created

* Fix: Fix dev command

* Feat: 행성 홈에서 주민증을 만드는 버튼 routing 로직 추가

* Feat: 주민증 생성 완료한 후 routing 로직 추가

* Feat: 행성 관리에서 수정 버튼 routing 로직 추가

---------

Co-authored-by: hyehyeon-moon <[email protected]>

* Feat: 서비스 전체 에러페이지 (#197)

* Feat/husky pre push (#201)

* refactor: CommentInput 스토리 Props에러

* feat: pre-push build

* Issue#189 (#206)

* feat: gear icon

* feat: 행성 관리 페이지로 이동

* refactor: AdminCommunityEditPage 서버 컴포넌트로 변경

* refactor: 행성 꾸미기 기본값 누락

* 7월 3일 flow 수정 작업 (#209)

* refactor: getInvitationCodeIsValid(public -> private)

* refactor: TemplateWrapper h-screen 높이 제거

* refactor: InvitationCodeValidationModel 스키마 수정

coummunityId -> id

* refactor: middleware private api 관련 이슈 주석

* feat: root 경로 route로 처리

* refactor : UserInfoResponse 타입 수정 (dto)

* refactor: 주민증 수정 mock profileImageUrl제거

* feat: mypage home root로 라우팅

* refactor: my-page:id -> my-page:communityId

* feat: root url 변경

* refactor: CharacterCompleteStep에 useGetUserInfo타입 수정

---------

Co-authored-by: darae07 <[email protected]>

---------

Co-authored-by: 강지영 <[email protected]>
Co-authored-by: darae lee <[email protected]>
Co-authored-by: 문혜현 <[email protected]>
Co-authored-by: hyehyeon-moon <[email protected]>
Co-authored-by: darae07 <[email protected]>
  • Loading branch information
6 people authored Jul 3, 2023
1 parent 70bfd8c commit 776228e
Show file tree
Hide file tree
Showing 59 changed files with 466 additions and 195 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm build
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"editor.quickSuggestions": {
"strings": true
},
"cSpell.words": ["kakao", "PIPI", "signin", "TOBBY"],
"cSpell.words": ["Dtos", "kakao", "PIPI", "signin", "TOBBY"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "NEXT_PUBLIC_API_MOCKING=disable next dev",
"build": "next build",
"start": "node server.js",
"lint": "next lint",
Expand Down
Binary file added public/assets/images/error-ufo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/api/config/requestUrl.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const ROOT_API_URL = process.env.ROOT_API_URL ?? 'http://43.201.214.187/api';
export const ROOT_URL = process.env.ROOT_API_URL ?? 'http://43.201.214.187';
export const ROOT_API_URL = process.env.ROOT_API_URL ?? 'https://ding-dong-planet.com/api';
export const ROOT_URL = process.env.ROOT_API_URL ?? 'https://ding-dong-planet.com/';
2 changes: 1 addition & 1 deletion src/api/domain/comment/comment.api.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CommentGetResponse,
} from '~/types/comment';

export const getCommentsServer = ({ idCardId, pageParam }: CommentGetRequest) =>
export const getCommentsServer = ({ idCardId, pageParam = 0 }: CommentGetRequest) =>
privateApi.get<CommentGetResponse>(`/id-cards/${idCardId}/comments?page=${pageParam}&size=10`);

export const getCommentCountsServer = ({ idCardId }: CommentCountGetRequest) =>
Expand Down
80 changes: 46 additions & 34 deletions src/api/domain/comment/comment.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
updateCommentId,
updateReplyId,
} from '~/api/domain/comment/comment.helper';
import { communityQueryKey } from '~/api/domain/community.api';
import { useToastMessageStore } from '~/stores/toastMessage.store';
import {
CommentCountGetRequest,
Expand All @@ -44,7 +45,7 @@ import {
CommentReplyLikePostResponse,
CommentReplyLikeRequest,
} from '~/types/comment';
import { UserInfoModel } from '~/types/user';
import { CommunityUserInfoResponse } from '~/types/community';

export const commentQueryKey = {
comments: (idCardId: number) => ['comments', idCardId],
Expand All @@ -55,7 +56,7 @@ export const getComments = ({ idCardId, pageParam }: CommentGetRequest) =>
privateApi.get<CommentGetResponse>(`/id-cards/${idCardId}/comments?page=${pageParam}&size=10`);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const useGetComments = ({ idCardId, pageParam }: CommentGetRequest) => {
export const useGetComments = (idCardId: number) => {
return useInfiniteQuery(
commentQueryKey.comments(idCardId),
({ pageParam = 0 }) => getComments({ idCardId, pageParam }),
Expand All @@ -78,7 +79,7 @@ export const useGetCommentCounts = ({ idCardId }: CommentCountGetRequest) =>
export const postCommentCreate = ({ idCardId, contents }: CommentPostRequest) =>
privateApi.post<CommentPostResponse>(`id-cards/${idCardId}/comments`, { contents });

export const usePostCommentCreate = (idCardId: number, userInfo: UserInfoModel) => {
export const usePostCommentCreate = (idCardId: number, communityId: number) => {
const queryClient = useQueryClient();
const { errorToast } = useToastMessageStore();

Expand All @@ -87,29 +88,35 @@ export const usePostCommentCreate = (idCardId: number, userInfo: UserInfoModel)
onMutate: async (commentInfo: CommentPostRequest) => {
await queryClient.cancelQueries({ queryKey: commentQueryKey.comments(idCardId) });

const newComment = createNewComment({
idCardId: idCardId,
contents: commentInfo.contents,
nickname: userInfo.nickname,
profileImageUrl: userInfo.profileImageUrl,
userId: userInfo.userId,
});

const previousComments = queryClient.getQueryData<CommentPages>(
commentQueryKey.comments(idCardId),
const userInfo = queryClient.getQueryData<CommunityUserInfoResponse>(
communityQueryKey.communityUserInfo(communityId),
);

const previousCommentCount = queryClient.getQueryData<CommentCountGetResponse>(
commentQueryKey.commentCount(idCardId),
);
if (userInfo) {
const newComment = createNewComment({
idCardId: idCardId,
contents: commentInfo.contents,
nickname: userInfo.myInfoInInCommunityDto.nickname,
profileImageUrl: userInfo.myInfoInInCommunityDto.profileImageUrl,
userId: userInfo.myInfoInInCommunityDto.userId,
});

const previousComments = queryClient.getQueryData<CommentPages>(
commentQueryKey.comments(idCardId),
);

const updatedComments = addCommentToPages(previousComments, newComment);
queryClient.setQueryData(commentQueryKey.comments(idCardId), updatedComments);
const previousCommentCount = queryClient.getQueryData<CommentCountGetResponse>(
commentQueryKey.commentCount(idCardId),
);

const updatedCommentCount = increaseCommentCount(previousCommentCount);
queryClient.setQueryData(commentQueryKey.commentCount(idCardId), updatedCommentCount);
const updatedComments = addCommentToPages(previousComments, newComment);
queryClient.setQueryData(commentQueryKey.comments(idCardId), updatedComments);

return { previousComments, previousCommentCount };
const updatedCommentCount = increaseCommentCount(previousCommentCount);
queryClient.setQueryData(commentQueryKey.commentCount(idCardId), updatedCommentCount);

return { previousComments, previousCommentCount };
}
},
onError: (err, newComment, context) => {
if (context?.previousComments !== undefined && context?.previousCommentCount !== undefined) {
Expand Down Expand Up @@ -178,29 +185,34 @@ export const postReplyCreate = ({ idCardId, commentId, contents }: CommentPostRe
contents,
});

export const usePostReplyCreate = (idCardId: number, userInfo: UserInfoModel) => {
export const usePostReplyCreate = (idCardId: number, communityId: number) => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: (replyInfo: CommentPostReplyRequest) => postReplyCreate(replyInfo),
onMutate: async (commentInfo: CommentPostReplyRequest) => {
await queryClient.cancelQueries({ queryKey: commentQueryKey.comments(idCardId) });

const newReply = createNewReply({
contents: commentInfo.contents,
nickname: userInfo.nickname,
profileImageUrl: userInfo.profileImageUrl,
userId: userInfo.userId,
});

const previousComments = queryClient.getQueryData<CommentPages>(
commentQueryKey.comments(idCardId),
const userInfo = queryClient.getQueryData<CommunityUserInfoResponse>(
communityQueryKey.communityUserInfo(communityId),
);
if (userInfo) {
const newReply = createNewReply({
contents: commentInfo.contents,
nickname: userInfo.myInfoInInCommunityDto.nickname,
profileImageUrl: userInfo.myInfoInInCommunityDto.profileImageUrl,
userId: userInfo.myInfoInInCommunityDto.userId,
});

const previousComments = queryClient.getQueryData<CommentPages>(
commentQueryKey.comments(idCardId),
);

const updatedComments = addReplyToPages(previousComments, newReply, commentInfo.commentId);
queryClient.setQueryData(commentQueryKey.comments(idCardId), updatedComments);
const updatedComments = addReplyToPages(previousComments, newReply, commentInfo.commentId);
queryClient.setQueryData(commentQueryKey.comments(idCardId), updatedComments);

return { previousComments };
return { previousComments };
}
},
onError: (err, newComment, context) => {
if (context?.previousComments) {
Expand Down
42 changes: 19 additions & 23 deletions src/api/domain/comment/comment.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ export const createNewComment = ({

export type CommentPages = {
pages: {
data: {
content: CommentModel[];
hasNext: boolean;
page: number;
size: number;
};
content: CommentModel[];
hasNext: boolean;
page: number;
size: number;
}[];
pageParams: number[]; // 페이지 파라미터 타입을 사용하거나 필요에 맞게 수정해주세요
};
Expand All @@ -58,23 +56,21 @@ export const addCommentToPages = (

if (isCommentListEmpty) {
updatedPages.push({
data: {
content: [newComment],
hasNext: false,
page: 0,
size: 10,
},
content: [newComment],
hasNext: false,
page: 0,
size: 10,
});
} else {
const firstPage = updatedPages[0];
const firstPageData = firstPage.data;
const firstPageData = firstPage;
const updatedFirstPageData = {
content: [newComment, ...firstPageData.content],
hasNext: firstPageData.hasNext,
page: firstPageData.page,
size: firstPageData.size,
};
updatedPages[0] = { ...firstPage, data: updatedFirstPageData };
updatedPages[0] = { ...firstPage, ...updatedFirstPageData };
}

return { pages: updatedPages, pageParams: previousComments?.pageParams ?? [] };
Expand All @@ -90,9 +86,9 @@ export const updateCommentId = (
// commentId를 실제 요청 후 받은 id로 수정합니다.
if (pages.length > 0) {
const firstPage = pages[0];
const firstPageData = firstPage.data;
const firstPageData = firstPage;
firstPageData.content[0].commentId = commentId;
pages[0] = { ...firstPage, data: firstPageData };
pages[0] = { ...firstPage, ...firstPageData };
}

return {
Expand Down Expand Up @@ -140,7 +136,7 @@ export const addReplyToPages = (

if (updatedPages.length > 0) {
const firstPage = updatedPages[0];
const firstPageData = firstPage.data;
const firstPageData = firstPage;
const commentIndex = firstPageData.content.findIndex(
comment => comment.commentId === commentId,
);
Expand Down Expand Up @@ -168,8 +164,8 @@ export const updateReplyId = (

const updatedPages = pages.map(page => {
const updatedData = {
...page.data,
content: page.data.content.map(comment => {
...page,
content: page.content.map(comment => {
if (comment.commentId === commentId) {
const lastReplyIndex = comment.commentReplyInfos.length - 1;
if (lastReplyIndex >= 0) {
Expand Down Expand Up @@ -206,8 +202,8 @@ export const removeCommentToPages = (

const updatedPages = pages.map(page => {
const updatedData = {
...page.data,
content: page.data.content.filter(comment => comment.commentId !== commentId),
...page,
content: page.content.filter(comment => comment.commentId !== commentId),
};
return {
...page,
Expand All @@ -231,8 +227,8 @@ export const removeReplyToPages = (

const updatedPages = pages.map(page => {
const updatedData = {
...page.data,
content: page.data.content.map(comment => {
...page,
content: page.content.map(comment => {
if (comment.commentId !== commentId) {
return comment;
}
Expand Down
7 changes: 4 additions & 3 deletions src/api/domain/community.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { AxiosError } from 'axios';
import { useRouter } from 'next/navigation';

import privateApi from '~/api/config/privateApi';
import publicApi from '~/api/config/publicApi';
import { userQueryKey } from '~/api/domain/user.api';
import {
CheckIdCardResponse,
Expand Down Expand Up @@ -86,7 +85,7 @@ export const usePostCommunityCreate = () => {
onSuccess: data => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
queryClient.invalidateQueries(communityQueryKey.communityList(userId!));
router.replace(`/admin/community/create/result?communityId=${data.id}`);
router.replace(`/admin/planet/create/result?communityId=${data.id}`);
},
});
};
Expand All @@ -96,18 +95,20 @@ export const postCommunityUpdate = (communityId: number, community: CreateCommun
export const usePostCommunityUpdate = (communityId: number) => {
const queryClient = useQueryClient();
const userId = getUserIdClient();
const router = useRouter();

return useMutation({
mutationFn: (community: CreateCommunityRequest) => postCommunityUpdate(communityId, community),
onSuccess: () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
queryClient.invalidateQueries(communityQueryKey.communityList(userId!));
router.replace(`/admin/planet/${communityId}`);
},
});
};

export const getInvitationCodeIsValid = async (invitationCode: string) => {
return await publicApi.get<InvitationCodeValidationResponse>(`/communities/validate`, {
return await privateApi.get<InvitationCodeValidationResponse>(`/communities/validate`, {
params: { code: invitationCode },
});
};
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions src/app/admin/community/[id]/edit/page.tsx

This file was deleted.

18 changes: 18 additions & 0 deletions src/app/admin/planet/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'server-only';

import { getCommunityDetailServer } from '~/api/domain/community.api.server';
import { CommunityAdminEdit } from '~/modules/CommunityAdmin/CommunityAdminEdit.client';

type AdminCommunityEditPageProps = {
params: {
id: number;
};
};

const AdminCommunityEditPage = async ({ params: { id } }: AdminCommunityEditPageProps) => {
const { communityDetailsDto } = await getCommunityDetailServer(Number(id));

return <CommunityAdminEdit {...communityDetailsDto} />;
};

export default AdminCommunityEditPage;
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'server-only';

import { getCommunityDetailServer } from '~/api/domain/community.api.server';
import { CommunityAdmin } from '~/modules/CommunityAdmin/CommunityAdmin';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
'use client';
import Image from 'next/image';
import { useRouter } from 'next/navigation';
import { useRouter, useSearchParams } from 'next/navigation';
import { PropsWithChildren } from 'react';

import { TopNavigation } from '~/components/TopNavigation';

const Layout = ({ children }: PropsWithChildren) => {
const searchParams = useSearchParams();
const communityIdParam = searchParams.get('communityId');
const communityId = isNaN(Number(communityIdParam)) ? -1 : Number(communityIdParam);
const router = useRouter();
const onClickLaterButton = () => {
router.push('/');
router.push(`/planet/${communityId}`);
};
return (
<>
Expand Down
File renamed without changes.
Loading

0 comments on commit 776228e

Please sign in to comment.