Skip to content

Commit

Permalink
Merge branch 'feature-community' of https://github.com/nori-dongsan/n…
Browse files Browse the repository at this point in the history
…ori-client into feature-community
  • Loading branch information
Brokyeom committed Jul 21, 2022
2 parents 6960398 + 1585959 commit a484b1c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
4 changes: 1 addition & 3 deletions components/community/ContentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import styled from '@emotion/styled';
import { IcReply, IcHeart, IcDot } from '../../public/assets/icons';
import CommunityCategory from './CommunityCategory';
import Router from 'next/router';
import { useRouter } from 'next/router';
import Link from 'next/link';

interface ContentInfoProps {
id: string;
Expand Down Expand Up @@ -41,7 +39,7 @@ export default function ContentCard(props: ContentInfoProps) {
<StWriteInfo>
<span>{userNickname}</span>
<IcDot />
<span>{createdAt}</span>
<span>{createdAt?.split('T')[0]}</span>
</StWriteInfo>
<StReplyInfo>
<IcHeart />
Expand Down
19 changes: 12 additions & 7 deletions components/community/ReplyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function ReplyList(props: ReplyListProps) {
});
const [currentPage, setCurrentPage] = useState<number>(1);
const [pageReplyList, setPageReplyList] = useState<ReplyData[]>([]);
const [isFirst, setIsFirst] = useState<boolean>(true);

const handleInputText = (e: React.ChangeEvent<HTMLInputElement>) => {
setReplyText(e.target.value);
Expand Down Expand Up @@ -55,13 +56,17 @@ export default function ReplyList(props: ReplyListProps) {
};

useEffect(() => {
if (replyList) {
setPageReplyList(
replyList.filter(
(_, idx) => (currentPage - 1) * 10 <= idx && idx < currentPage * 10,
),
);
window.scrollTo({ top: 750 });
if (!isFirst) {
if (replyList) {
setPageReplyList(
replyList.filter(
(_, idx) => (currentPage - 1) * 10 <= idx && idx < currentPage * 10,
),
);
window.scrollTo({ top: 750 });
}
} else {
setIsFirst((prev) => !prev);
}
}, [replyList, currentPage]);
return (
Expand Down
2 changes: 1 addition & 1 deletion core/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ baseInstance.interceptors.request.use((config) => {
const headers = {
...config.headers,
accessToken:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzAsImlhdCI6MTY1ODM4NDEwMCwiZXhwIjoxNjU4MzkxMzAwLCJpc3MiOiJub3JpIn0.ZNRxtGPFJpVCHJzlK0HdcgPcZWvkkCt3FZ_VHu8sz7M',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzAsImlhdCI6MTY1ODM5MjA1NCwiZXhwIjoxNjU4Mzk5MjU0LCJpc3MiOiJub3JpIn0.-4zFiA6OVE5L86D0LWyEkyKf7RKvm7qlOG5NWCXcSYM',
refreshToken:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzAsImlhdCI6MTY1ODM4NDEwMCwiZXhwIjoxNjU5NTkzNzAwLCJpc3MiOiJub3JpIn0.AeuhSmM1ZqItojeM3O0SwrELog-Qfq91r_ii0EMgPig',
};
Expand Down
4 changes: 2 additions & 2 deletions pages/community/[cid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function CommunityDetail({
'삭제하시겠어요? 삭제 시, 해당 글과 댓글은 복구되지 않습니다.',
);

if (val) {
if (val && cid) {
const status = await deleteCommunity(cid);
if (status === 200) router.push('/community');
}
Expand Down Expand Up @@ -140,7 +140,7 @@ export const getServerSideProps: GetServerSideProps<Props, Params> = async ({
const res = await getCommunityDetail(params!.cid);
return {
props: {
data: res.data.data,
data: { ...res.data.data, id: params!.cid },
},
};
};
Expand Down
1 change: 0 additions & 1 deletion pages/community/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const limit = 20;

export const getServerSideProps: GetServerSideProps = async () => {
const res = await getCommunity();
// const data: CommunityData[] = communityMockData;
return {
props: res.data,
};
Expand Down

0 comments on commit a484b1c

Please sign in to comment.