-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from Eagle2gle/dev
[release] 3차 배포
- Loading branch information
Showing
27 changed files
with
900 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useRouter } from 'next/router'; | ||
|
||
import { useTypeSelector } from '@/store'; | ||
|
||
interface LayoutProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const RouteGuard = ({ children }: LayoutProps) => { | ||
const router = useRouter(); | ||
const id = useTypeSelector((state) => state.user.id); | ||
|
||
if (!id) { | ||
router?.push({ | ||
pathname: '/login', | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
<div>{id && children}</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default RouteGuard; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import Image from 'next/image'; | ||
import { useRouter } from 'next/router'; | ||
|
||
import { useSuspendedQuery } from '@/hooks/useSuspendedQuery'; | ||
import { api } from '@/libs/client/api'; | ||
import { useTypeSelector } from '@/store'; | ||
import type { MarketDetailType } from '@/types/market'; | ||
import type { Response } from '@/types/response'; | ||
|
||
import InterestButton from '../common/InterestButton'; | ||
|
||
const DetailHeader = () => { | ||
const { | ||
query: { id }, | ||
} = useRouter(); | ||
const { | ||
data: { | ||
data: { title, location, expectedRateOfReturn, pictures, price, shortDescription, userIds }, | ||
}, | ||
} = useSuspendedQuery<Response<MarketDetailType>>(['market/detail', id], () => | ||
api.get(`markets/${id}`).json() | ||
); | ||
const userId = useTypeSelector((state) => state.user.id); | ||
|
||
return ( | ||
<div className="mx-4 mt-4 flex gap-3 md:mx-0 md:gap-5"> | ||
<div className="avatar"> | ||
<div className="relative h-36 w-full bg-grey md:h-80"> | ||
{pictures[0] && ( | ||
<Image | ||
alt="image" | ||
src={pictures[0]} | ||
className="object-contain" | ||
fill | ||
placeholder="blur" | ||
blurDataURL={pictures[0]} | ||
sizes="(max-width: 768px) 100vw, | ||
(max-width: 1200px) 50vw, | ||
33vw" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<div className="border-l border-black/50"></div> | ||
<div className="flex w-full flex-col justify-between text-lg font-bold"> | ||
<div className="flex flex-col gap-1"> | ||
<span className="underline underline-offset-2">{title}</span> | ||
<div className="flex flex-col-reverse gap-1 md:flex-col"> | ||
<span className="text-xs font-medium md:text-lg">{location}</span> | ||
</div> | ||
</div> | ||
<div className="hidden flex-col text-black md:flex"> | ||
소개 | ||
<span className="text-sm font-medium">{shortDescription}</span> | ||
</div> | ||
<div className="relative flex flex-col gap-2 text-xs md:text-lg"> | ||
<div className="flex justify-between text-black/50"> | ||
예상 수익률 | ||
<span className="text-black">{expectedRateOfReturn}%</span> | ||
</div> | ||
<div className="flex justify-between text-black/50"> | ||
현재가 | ||
<span className="text-black">{price.toLocaleString()}원</span> | ||
</div> | ||
{userId && ( | ||
<InterestButton | ||
size="large" | ||
isInterest={userIds.includes(userId)} | ||
id={parseInt(String(id))} | ||
hideOnMobile | ||
type="market" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DetailHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import Link from 'next/link'; | ||
|
||
import { STATUS } from '@/constants/mypage'; | ||
import { useSuspendedQuery } from '@/hooks/useSuspendedQuery'; | ||
import { api } from '@/libs/client/api'; | ||
import { useTypeSelector } from '@/store'; | ||
import { Response } from '@/types/response'; | ||
import { ParticipatedContestType } from '@/types/user'; | ||
import classNames from '@/utils/classnames'; | ||
|
||
interface PropsType { | ||
printAllData: boolean; | ||
border?: boolean; | ||
} | ||
|
||
// 공모 내역 테이블 | ||
const ContestTable = ({ printAllData, border }: PropsType) => { | ||
const token = useTypeSelector((state) => state.user.token); | ||
const { data } = useSuspendedQuery<Response<ParticipatedContestType>>( | ||
[`user/contest`], | ||
() => | ||
api | ||
.get(`auth/contestParticipation/me`, { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}) | ||
.json<Response<ParticipatedContestType>>(), | ||
{ enabled: !!token } | ||
); | ||
|
||
if (!data || data?.data.result.length === 0) { | ||
return <div className="ml-auto mr-auto w-48 py-8 font-bold">아직 참여한 공모가 없어요!</div>; | ||
} | ||
|
||
return ( | ||
<> | ||
<div | ||
className={`${ | ||
border ? 'rounded border border-grey' : '' | ||
} w-full max-w-4xl overflow-x-auto text-xs`} | ||
> | ||
<table className={`table-compact table w-full text-center`}> | ||
<thead className={`${border ? 'border-b border-grey' : ''}`}> | ||
<tr className="text-bold text-dark-grey"> | ||
<th className="bg-white px-5">공모명</th> | ||
<th className="bg-white px-5">거래 시간</th> | ||
<th className="bg-white px-5">가격</th> | ||
<th className="bg-white px-5">수량(주)</th> | ||
<th className="bg-white px-5">진행도</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{data?.data.result.map((item, idx) => { | ||
if (printAllData || (!printAllData && idx < 3)) { | ||
return ( | ||
<tr key={idx}> | ||
<td className="w-full truncate">{item.title}</td> | ||
<td>{item.createdAt.split('T')[0].substring(2)}</td> | ||
<td>{item.price.toLocaleString()}</td> | ||
<td>{item.amount.toLocaleString()}</td> | ||
<td> | ||
<div | ||
className={classNames( | ||
'badge w-full border-transparent text-white', | ||
STATUS[item.status as keyof typeof STATUS].COLOR | ||
)} | ||
> | ||
{STATUS[item.status as keyof typeof STATUS].TEXT} | ||
</div> | ||
</td> | ||
</tr> | ||
); | ||
} | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
{!printAllData && data && data?.data.result.length > 3 && ( | ||
<Link href="/mypage/cahoots" className="font-medium"> | ||
<button className="btn-primary btn-block btn-sm btn">More</button> | ||
</Link> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ContestTable; |
Oops, something went wrong.