Skip to content
Open
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
4 changes: 3 additions & 1 deletion next/app/board/[id]/boardItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@
color: #9ca3af;
}
.backBtn {
display: block;
display: flex;
align-items: center;
justify-content: center;
width: 240px;
height: 48px;
background: #3692ff;
Expand Down
15 changes: 12 additions & 3 deletions next/app/board/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
'use client';
import Layout, { LayoutInput } from '@/app/shared/components/layout';
import { UserId, CreatedAt, ItemTitle, Favorite } from '@/app/board/_components';
import {
UserId,
CreatedAt,
ItemTitle,
Favorite,
} from '@/app/board/_components';
import './boardItem.css';
import { useParams } from 'next/navigation';
import { useEffect, useState } from 'react';
import { boardGetItem, ReturnData } from '@/app/shared/api/board';
import { useRouter } from 'next/navigation';
import EtcBox from '../_components/etcBox';
import Link from 'next/link';

export default function BoardItem() {
const params = useParams();
Expand All @@ -16,6 +22,7 @@ export default function BoardItem() {
content: '',
createdAt: new Date(),
user: {
name: '',
id: '',
},
favorite: 0,
Expand All @@ -40,7 +47,7 @@ export default function BoardItem() {
<ItemTitle title={item.title} />
<div className="infoLine2">
<div className="box">
<UserId userId={item.user.id} img={'/img/ic_big_profile.png'} />
<UserId userId={item.user.name} img={'/img/ic_big_profile.png'} />
<CreatedAt date={item.createdAt} />
</div>
<div className="box">
Expand All @@ -52,7 +59,9 @@ export default function BoardItem() {
</div>
<Coment />
<ComentList coment={[1, 2, 3, 4, 6, 7, 8]} />
<button className="backBtn">목록으로 돌아가기</button>
<Link href="/board" className="backBtn">
목록으로 돌아가기
</Link>
</Layout>
);
}
Expand Down
20 changes: 17 additions & 3 deletions next/app/board/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import Link from 'next/link';
import { useEffect, useState } from 'react';
import { getData } from './_hook/hook';
import { BestItem, Item } from './_components';
import { useAuth } from '../shared/contexts/AuthContext';
import { useRouter } from 'next/navigation';

export default function Board() {
const { user } = useAuth();
const searchHandle = useChange();
const [data, setData] = useState([]);
const [bestData, setBestData] = useState([]);
const [pageSize, setPageSize] = useState(6);
const [keyword, setKeyword] = useState('');
const [orderBy, setOrderBy] = useState<'recent' | 'favorite'>('recent');
const router = useRouter();
const searchKewordHandle = (e: any) => {
if (e.keyCode === 13 || e.type.toString() === 'click') {
setPageSize(6);
Expand All @@ -24,6 +28,12 @@ export default function Board() {
e.preventDefault();
setOrderBy(e.target.value);
};
const writeHandle = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault();
const { href } = e.currentTarget;
if (!!user) router.push(href);
else alert('로그인해주세요');
};
useEffect(() => {
getData({ setFn: setData, pageSize, orderBy, keyword });
getData({ setFn: setBestData, pageSize: 3, orderBy: 'favorite' });
Expand All @@ -40,7 +50,7 @@ export default function Board() {
title={v.title}
content={v.content}
createdAt={v.createdAt}
userId={v.user.id}
userId={v.user.name}
favorite={v.favorite}
boardNumber={v.boardNumber}
/>
Expand All @@ -50,7 +60,11 @@ export default function Board() {
</div>
<div className="boardLine">
<TitleLine text={'베스트 게시글'}>
<Link className="writeBoard" href={'/board/write'}>
<Link
className="writeBoard"
href={'/board/write'}
onClick={writeHandle}
>
글쓰기
</Link>
</TitleLine>
Expand Down Expand Up @@ -87,7 +101,7 @@ export default function Board() {
title={v.title}
content={v.content}
createdAt={v.createdAt}
userId={v.user.id}
userId={v.user.name}
favorite={v.favorite}
boardNumber={v.boardNumber}
/>
Expand Down
4 changes: 3 additions & 1 deletion next/app/board/write/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import './board.css';
import { useEffect, useState } from 'react';
import { boardCreateData, CreateBoard } from '@/app/shared/api/board';
import { useRouter } from 'next/navigation';
import { useAuth } from '@/app/shared/contexts/AuthContext';
interface T_Input {
value: string;
onchange: React.ReactEventHandler;
Expand All @@ -25,6 +26,7 @@ export default function WriteBoard({
imagesValue?: string[];
btnText?: string;
}) {
const { user } = useAuth();
const subject = useChange();
const content = useChange();
const [on, setOn] = useState('');
Expand Down Expand Up @@ -63,7 +65,7 @@ export default function WriteBoard({
title: subject.value,
content: content.value,
images,
userUuid: '9cd3b725-e623-43a3-8ade-1f5a394fb43f',
userUuid: user.uuid,
};
boardCreateData(body)
.then((res: any) => {
Expand Down
21 changes: 13 additions & 8 deletions next/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
@font-face {
font-family: "Pretendard";
font-family: 'Pretendard';
font-weight: 400;
font-display: swap;
src: local("Pretendard Regular"),
url(./font/Pretendard-Regular.woff2) format("woff2"),
url(./font/Pretendard-Regular.woff) format("woff");
src:
local('Pretendard Regular'),
url(./font/Pretendard-Regular.woff2) format('woff2'),
url(./font/Pretendard-Regular.woff) format('woff');
}
/* reset */
* {
padding: 0;
margin: 0;
line-height: 150%;
box-sizing: border-box;
font-family: "Pretendard";
font-family: 'Pretendard';
}
a {
text-decoration: none;
Expand Down Expand Up @@ -50,7 +51,12 @@ img {
--gray100: #f3f4f6;
--gray50: #f9fafb;
}

.bgPrimary100 {
background-color: var(--primary100) !important;
}
.bgPrimary200 {
background-color: var(--primary200) !important;
}
header {
width: 100%;
height: 70px;
Expand Down Expand Up @@ -384,7 +390,6 @@ footer .content .icon img {
}
}


.inputBox {
margin-bottom: 32px;
}
Expand Down Expand Up @@ -425,4 +430,4 @@ footer .content .icon img {
padding-top: 16px;
font-size: 16px;
margin-bottom: 16px;
}
}
61 changes: 32 additions & 29 deletions next/app/items/page.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
"use client"
'use client';
// import "../css/app.css";
import { useEffect, useRef, useState } from "react";
import MarketSection, { MarketPageNavi } from "../shared/components/marketSection";
import {
useChange,
useItmeList,
usePageNavi,
useScreenSize,
} from "../shared/hook/hook";
import Layout from '../shared/components/layout'
import Link from "next/link";
import { productsGet } from "../shared/api/product";
import { useEffect, useRef, useState } from 'react';
import MarketSection, {
MarketPageNavi,
} from '../shared/components/marketSection';
import { useChange, useItmeList, usePageNavi } from '../shared/hook/hook';
import Layout from '../shared/components/layout';
import Link from 'next/link';
import { productsGet } from '../shared/api/product';
import Image from 'next/image';

export default function UsedMarket() {
const naviLimit = 5;
const [sellLimit, setSellLimit] = useState(10);
const sellProduct = useItmeList([{}], sellLimit);
const [sellItmeSize, setSellItemSize] = useState("220px");
const [arrType, setArrType] = useState("recent");
const [sellItmeSize, setSellItemSize] = useState('220px');
const [arrType, setArrType] = useState('recent');
const [onTarget, setOnTarget] = useState(1);
const [total, setTotal] = useState(0);
const [keyword, setKeyword] = useState("");
const [keyword, setKeyword] = useState('');
const pageNavi = usePageNavi(1, 5);
const searchHandle = useChange();
const searchRef = useRef(null);

function GetItems(page:any, pageSize:any, orderBy:any, keyword:any) {
productsGet(page, pageSize, orderBy, keyword)
.then((res:any) => {
function GetItems(page: any, pageSize: any, orderBy: any, keyword: any) {
productsGet({ page, pageSize, orderBy, keyword })
.then((res: any) => {
if (res.success) {
sellProduct.setValue(res.data);
setTotal(res.totalCount / sellLimit);
}
})
.catch((err:any) => console.error(err));
.catch((err: any) => console.error(err));
}
useEffect(() => {
GetItems(onTarget, sellLimit, arrType, searchHandle.value);
}, [onTarget]);

const searchKewordHandle = (e:any) => {
if (e.keyCode === 13 || e.type.toString() === "click") {
const searchKewordHandle = (e: any) => {
if (e.keyCode === 13 || e.type.toString() === 'click') {
setOnTarget(1);
pageNavi.setStart(1);
pageNavi.setLast(5);
GetItems(1, sellLimit, arrType, searchHandle.value);
}
};
const selectHandle = (e:any) => {
const selectHandle = (e: any) => {
e.preventDefault();
setArrType(e.target.value);
};
const pageNaviEvent = (e:any) => {
const pageNaviEvent = (e: any) => {
setOnTarget(Number(e.target.textContent));
};
const nextEvent = (e:any) => {
const nextEvent = (e: any) => {
e.preventDefault();
const pageNum = Math.floor(onTarget / naviLimit);
if (onTarget % naviLimit === 0) {
Expand All @@ -63,7 +61,7 @@ export default function UsedMarket() {
}
setOnTarget(onTarget + 1);
};
const privousEvent = (e:any) => {
const privousEvent = (e: any) => {
e.preventDefault();
if (onTarget % naviLimit === 1) {
pageNavi.setStart(onTarget - naviLimit);
Expand All @@ -74,15 +72,20 @@ export default function UsedMarket() {
return (
<Layout>
<MarketSection
className={"sell"}
title={"판매 중인 상품"}
className={'sell'}
title={'판매 중인 상품'}
data={sellProduct.value}
itemMaxWidth={sellItmeSize}
>
<div className="marketEtc">
<div className="searchBox">
<button className="submit" onClick={searchKewordHandle}>
<img src="./img/ic_search.svg" alt="search" />
<Image
src="/img/ic_search.svg"
alt="search"
width={24}
height={24}
/>
</button>
<input
type="text"
Expand All @@ -93,7 +96,7 @@ export default function UsedMarket() {
placeholder="검색할 상품을 입력해주세요"
/>
</div>
<Link href="/registration">상품등록하기</Link>
<Link href="/items/write">상품등록하기</Link>
<select onChange={selectHandle}>
<option value="recent" defaultChecked>
최신순
Expand Down
Loading