Skip to content

Commit

Permalink
Post-list-server연결 (#25)
Browse files Browse the repository at this point in the history
* New : asset 추가

* New : Dayjs , Intersection Observer 추가

* New : 모킹 제거

* Refactor : 인터페이스 변경

* New : 검색기능, 포스트리스트 서버연결
  • Loading branch information
jobkaeHenry authored Nov 11, 2023
1 parent 5966970 commit ba525f0
Show file tree
Hide file tree
Showing 36 changed files with 643 additions and 221 deletions.
17 changes: 16 additions & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
"@tanstack/react-query": "^5.8.1",
"@tanstack/react-query-devtools": "^5.8.1",
"axios": "^1.6.0",
"dayjs": "^1.11.10",
"framer-motion": "^10.16.4",
"next": "14.0.0",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"react-intersection-observer": "^9.5.3"
},
"devDependencies": {
"@storybook/addon-essentials": "7.5.2",
Expand Down
94 changes: 93 additions & 1 deletion client/src/app/(protectedRoute)/new-post/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,95 @@
"use client";

import {
AppBar,
Avatar,
Box,
ButtonBase,
Container,
Paper,
TextField,
Toolbar,
Typography,
} from "@mui/material";
import GoBackIcon from "@/assets/icons/GoBackIcon.svg";
import InputSearchIcon from "@/assets/icons/InputSearchIcon.svg";
import AlcholeSearchIcon from "@/assets/icons/AlcholeSearchIcon.svg";
import { useRouter } from "next/navigation";
import { ChangeEvent, useState } from "react";
import { useUserInfoQuery } from "@/queries/auth/useUserInfoQuery";

export default function NewpostPage() {
return <>페지이</>;
const router = useRouter();
const [formValue, setFormValue] = useState({
alcoholNo: "",
alcoholFeature: "",
postContent: "",
postType: "BASIC",
positionInfo: "",
tagList: ["string"],
});
const changeHadler = ({
target,
}: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
setFormValue((prev) => ({ ...prev, [target.name]: target.value }));
};

return (
<>
<AppBar position={"static"}>
<Toolbar sx={{ display: "flex", justifyContent: "space-between" }}>
<ButtonBase onClick={() => router.back()}>
<GoBackIcon></GoBackIcon>
</ButtonBase>
<Typography variant="subtitle2" fontWeight={"bold"}>
포스팅
</Typography>
<Typography variant="subtitle2" color={"primary.main"}>
공유
</Typography>
</Toolbar>
</AppBar>
<Container sx={{ px: { xs: 0, sm: 4 } }} maxWidth={"lg"}>
<Paper
sx={{
minHeight: "calc(100vh - 112px)",
display: "flex",
flexDirection: "column",
gap: 2,
p: 2,
}}
component="form"
>
<TextField
placeholder="검색어를 입력해주세요"
autoFocus
InputProps={{
startAdornment: (
<AlcholeSearchIcon style={{ marginRight: "8px" }} />
),
endAdornment: <InputSearchIcon />,
}}
/>

<Box>
<TextField
id="filled-multiline-flexible"
placeholder="입력해주세요"
multiline
name={"postContent"}
onChange={changeHadler}
value={formValue.postContent}
rows={6}
/>
</Box>
<Typography variant="label" sx={{ textAlign: "right" }}>
{formValue.postContent.length} /{" "}
<Typography variant="label" color="primary.main" component="span">
200자
</Typography>
</Typography>
</Paper>
</Container>
</>
);
}
5 changes: 3 additions & 2 deletions client/src/app/@Modal/(.)post/[userId]/[postId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import PostDetailPage from "@/app/post/[userId]/[postId]/page";
import ModalWrapper from "@/components/ModalWrapper";

const page = (props: { params: { userId: string; postId: string } }) => {
const page = async ({ ...context }) => {
const parsedPostId = context.params.postId
return (
<ModalWrapper disableBox>
<PostDetailPage {...props} />
<PostDetailPage {...context} postNo={parsedPostId} />
</ModalWrapper>
);
};
Expand Down
29 changes: 29 additions & 0 deletions client/src/app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use client'

import { useEffect } from 'react'

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
useEffect(() => {
// Log the error to an error reporting service
console.error(error)
}, [error])

return (
<div>
<h2>Something went wrong!</h2>
<button
onClick={
() => reset()
}
>
Try again
</button>
</div>
)
}
3 changes: 2 additions & 1 deletion client/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default function RootLayout({
overflow: "auto",
}}
>
<MSWInit>{children}</MSWInit>
<MSWInit></MSWInit>
{children}
</Box>
<NavigationBar />
</ThemeRegistry>
Expand Down
27 changes: 15 additions & 12 deletions client/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@

"use server";
import PostCardList from "@/components/post/PostCardList";
// import { getPostListQueryFn } from "@/queries/post/useGetPostListQuery";
import { Container } from "@mui/material";
import { Suspense } from "react";
import { getPostListQueryFn } from "@/queries/post/useGetPostListInfiniteQuery";
import { Container, Paper } from "@mui/material";

export default async function Home() {
const initialData = await getPostListQueryFn({ page: 0, size: 10 });

export default function Home() {
// const initialData = await getPostListQueryFn();
return (
<Container sx={{ px: { xs: 0, sm: 4 } }} maxWidth={"lg"}>
<Suspense fallback={<>로딩중</>}>
{/* FIXME */}{/* @ts-ignore*/}
<PostCardList
// initialData={initialData}
/>
</Suspense>
<Paper
sx={{
minHeight: "calc(100vh - 56px)",
display: "flex",
flexDirection: "column",
}}
>
<PostCardList initialData={initialData} />
</Paper>
</Container>
);
}
30 changes: 11 additions & 19 deletions client/src/app/post/[userId]/[postId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
"use server";
import PostDetail from "@/components/post/PostDetail";
import { Suspense } from "react";
import { getPostDetailQueryFn } from "@/queries/post/useGetPostDetailQuery";
import { redirect } from "next/navigation";

const PostDetailPage = ({
params,
}: {
params: { userId: string; postId: string };
}) => {
// FIXME @로 시작되는 경우만 슬라이스 하도록 추후에 고치고, 함수화 해야함
const parsedUserId = params.userId.slice(1, params.userId.length);
const parsedPostId = params.postId;
return (
<div>
userId:{parsedUserId}
postId:{parsedPostId}
<br />
<Suspense fallback={<>로딩</>}>
<PostDetail />
</Suspense>
</div>
);
const PostDetailPage = async ({ ...context }) => {
const parsedPostId = context.params.postId;
try {
const initialData = await getPostDetailQueryFn(parsedPostId);
return <PostDetail postNo={parsedPostId} initialData={initialData} />;
} catch {
redirect("/not-found");
}
};

export default PostDetailPage;
21 changes: 18 additions & 3 deletions client/src/app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
const SearchPage = ({
"use server";
import SearchArea from "@/components/search/SearchArea";
import { getPostListQueryFn } from "@/queries/post/useGetPostListInfiniteQuery";
import { Container } from "@mui/material";

const SearchPage = async ({
searchParams,
}: {
searchParams?: { [key: string]: string | string[] | undefined };
searchParams?: { [key: string]: string | undefined };
}) => {
return <div>{searchParams?.keyword}</div>;
const initialData = await getPostListQueryFn({
searchKeyword: searchParams?.keyword,
});
return (
<Container sx={{ px: { xs: 0, sm: 4 } }} maxWidth={"lg"}>
<SearchArea
initialData={initialData}
searchKeyword={searchParams?.keyword}
/>
</Container>
);
};

export default SearchPage;
8 changes: 8 additions & 0 deletions client/src/assets/icons/AlcholeSearchIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions client/src/assets/icons/CommentIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions client/src/assets/icons/GoBackIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions client/src/assets/icons/InputSearchIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions client/src/assets/icons/LikeIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions client/src/assets/icons/PostSeeMoreIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions client/src/assets/icons/QuoteIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions client/src/assets/icons/ShareIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/developing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/hasError.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/noResult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ba525f0

Please sign in to comment.