Repository navigation
feat: 토너먼트 위시에서 가져오기에 폴더 칩 추가 #765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
apps/web/src/app/tournament/[id]/create/by-wish-v2/_components/ByWishV2Content.tsx
This file contains hidden or 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,99 @@ | ||
| 'use client'; | ||
|
|
||
| import { useState } from 'react'; | ||
| import { toast } from 'sonner'; | ||
|
|
||
| import { MOCK_FOLDERS, MOCK_WISHES } from '@/app/wish/_common/_consts/wishMock'; | ||
| import BottomCta from '@/components/bottom-cta'; | ||
| import Button from '@/components/button'; | ||
| import WishGrid from '@/components/common/wish-grid'; | ||
| import { ROUTES } from '@/consts/route'; | ||
| import { useBackWithFallback } from '@/hooks/useBackWithFallback'; | ||
|
|
||
| import { useGetTournament } from '../../../_common/_hooks/useGetTournament'; | ||
| import { MAX_SELECT } from '../../by-wish/_consts/selectLimits'; | ||
| import FolderChipFilter from './FolderChipFilter'; | ||
| import NoWishDialog from './NoWishDialog'; | ||
|
|
||
| type ByWishV2ContentProps = { | ||
| tournamentId: number; | ||
| }; | ||
|
|
||
| function ByWishV2Content({ tournamentId }: ByWishV2ContentProps) { | ||
| const backWithFallback = useBackWithFallback(); | ||
| const [activeFolderId, setActiveFolderId] = useState<number | null>(null); | ||
| const [selectedWishIds, setSelectedWishIds] = useState<Set<number>>(new Set()); | ||
| const { tournamentData } = useGetTournament(tournamentId); | ||
|
|
||
| const pending = 'pending' in tournamentData ? tournamentData.pending : null; | ||
| const addableCount = Math.max(MAX_SELECT - (pending?.items.length ?? 0), 0); | ||
| const isOverSelectionLimit = selectedWishIds.size > addableCount; | ||
|
|
||
| /** TEMP: 위시·폴더 API 연동 전까지 목 데이터 사용함 */ | ||
| const items = MOCK_WISHES; | ||
| const folders = MOCK_FOLDERS; | ||
| const activeFolder = folders.find(({ id }) => id === activeFolderId); | ||
| const visibleItems = activeFolder | ||
| ? items.filter(({ wish }) => activeFolder.wishIds.includes(wish.id)) | ||
| : items; | ||
|
|
||
| const hasNoWish = items.length === 0; | ||
|
|
||
| const handleToggleSelect = (wishId: number) => { | ||
| const isSelected = selectedWishIds.has(wishId); | ||
| if (!isSelected && selectedWishIds.size >= addableCount) { | ||
| toast.warning(`최대 ${addableCount}개까지 상품을 담을 수 있어요.`, { id: 'max-select' }); | ||
| return; | ||
| } | ||
|
|
||
| setSelectedWishIds(prev => { | ||
| const next = new Set(prev); | ||
| if (isSelected) next.delete(wishId); | ||
| else next.add(wishId); | ||
| return next; | ||
| }); | ||
| }; | ||
|
|
||
| const handleBackToCreate = () => backWithFallback(ROUTES.TOURNAMENT_CREATE(tournamentId)); | ||
|
|
||
| if (hasNoWish) return <NoWishDialog onBack={handleBackToCreate} />; | ||
|
|
||
| return ( | ||
| <> | ||
| <div className="flex flex-col gap-6 bg-bg-layer-default py-6"> | ||
| {folders.length > 0 && ( | ||
| <FolderChipFilter | ||
| folders={folders} | ||
| activeFolderId={activeFolderId} | ||
| onFolderChange={setActiveFolderId} | ||
| /> | ||
| )} | ||
| <p className="px-5 body-2-medium text-[#737373]"> | ||
| <span className="text-text-accent">{selectedWishIds.size}</span>/{addableCount}개 선택 | ||
| </p> | ||
| </div> | ||
|
|
||
| <main className="hide-scrollbar flex flex-1 flex-col overflow-y-auto bg-bg-layer-basement pb-32"> | ||
| <WishGrid | ||
| wishes={visibleItems} | ||
| selectedWishIds={selectedWishIds} | ||
| onToggleSelect={handleToggleSelect} | ||
| /> | ||
| </main> | ||
|
|
||
| <BottomCta hasGradient> | ||
| <Button | ||
| variant="primary" | ||
| size="lg" | ||
| disabled={selectedWishIds.size === 0 || isOverSelectionLimit} | ||
| /** TODO: 위시에서 토너먼트 후보 담기 API 연결 */ | ||
| onClick={handleBackToCreate} | ||
| > | ||
| 다음 | ||
| </Button> | ||
| </BottomCta> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default ByWishV2Content; |
42 changes: 42 additions & 0 deletions
42
apps/web/src/app/tournament/[id]/create/by-wish-v2/_components/FolderChipFilter.tsx
This file contains hidden or 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,42 @@ | ||
| import { cn } from '@/utils/cn'; | ||
|
|
||
| type FolderChipFilterProps = { | ||
| folders: { id: number; name: string }[]; | ||
| activeFolderId: number | null; | ||
| onFolderChange: (folderId: number | null) => void; | ||
| }; | ||
|
|
||
| function FolderChipFilter({ folders, activeFolderId, onFolderChange }: FolderChipFilterProps) { | ||
| const chips = [{ id: null, name: '전체' }, ...folders]; | ||
|
|
||
| return ( | ||
| <div | ||
| role="group" | ||
| aria-label="폴더 필터" | ||
| className="hide-scrollbar flex gap-2 overflow-x-auto px-5" | ||
| > | ||
| {chips.map(({ id, name }) => { | ||
| const isActive = activeFolderId === id; | ||
|
|
||
| return ( | ||
| <button | ||
| key={id ?? 'all'} | ||
| type="button" | ||
| aria-pressed={isActive} | ||
| onClick={() => onFolderChange(id)} | ||
| className={cn( | ||
| 'flex h-9 shrink-0 cursor-pointer items-center rounded-full border px-3 body-2-semibold transition-colors', | ||
| isActive | ||
| ? 'border-border-neutral-primary bg-bg-neutral-secondary text-text-neutral-inverse' | ||
| : 'border-gray-75 bg-bg-layer-default text-text-neutral-secondary' | ||
| )} | ||
| > | ||
| {name} | ||
| </button> | ||
| ); | ||
| })} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default FolderChipFilter; |
52 changes: 52 additions & 0 deletions
52
apps/web/src/app/tournament/[id]/create/by-wish-v2/_components/NoWishDialog.tsx
This file contains hidden or 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,52 @@ | ||
| import { InboxIconFill } from '@/assets/icons'; | ||
| import Button from '@/components/button'; | ||
| import ButtonLink from '@/components/button/ButtonLink'; | ||
| import { | ||
| Dialog, | ||
| DialogClose, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogFooter, | ||
| DialogTitle, | ||
| } from '@/components/dialog'; | ||
| import { ROUTES } from '@/consts/route'; | ||
|
|
||
| type NoWishDialogProps = { | ||
| onBack: () => void; | ||
| }; | ||
|
|
||
| function NoWishDialog({ onBack }: NoWishDialogProps) { | ||
| return ( | ||
| <Dialog open> | ||
| <DialogContent | ||
| showCloseButton={false} | ||
| closeOnDimClick={false} | ||
| className="flex flex-col items-center gap-5" | ||
| > | ||
| <div className="flex flex-col items-center gap-3"> | ||
| <InboxIconFill className="size-10 text-icon-neutral-secondary" /> | ||
| <div className="flex flex-col items-center gap-1 text-center"> | ||
| <DialogTitle className="heading-2-semibold break-keep text-text-neutral-primary"> | ||
| 가져올 위시가 없어요. | ||
| </DialogTitle> | ||
| <DialogDescription className="body-2-medium break-keep text-text-neutral-tertiary"> | ||
| 위시를 먼저 추가해 주세요. | ||
| </DialogDescription> | ||
| </div> | ||
| </div> | ||
| <DialogFooter className="flex w-full gap-2.5"> | ||
| <Button variant="secondary" size="lg" onClick={onBack}> | ||
| 돌아가기 | ||
| </Button> | ||
| <DialogClose asChild> | ||
| <ButtonLink size="lg" href={ROUTES.WISHLIST}> | ||
| 위시 담기 | ||
| </ButtonLink> | ||
| </DialogClose> | ||
| </DialogFooter> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| } | ||
|
|
||
| export default NoWishDialog; |
33 changes: 33 additions & 0 deletions
33
apps/web/src/app/tournament/[id]/create/by-wish-v2/page.tsx
This file contains hidden or 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,33 @@ | ||
| import { notFound } from 'next/navigation'; | ||
|
|
||
| import { Header, HeaderIcon } from '@/components/header'; | ||
|
|
||
| import ByWishV2Content from './_components/ByWishV2Content'; | ||
|
|
||
| type ByWishV2PageProps = { | ||
| params: Promise<{ id: string }>; | ||
| }; | ||
|
|
||
| /** TEMP: 폴더 칩 작업용 임시 경로. 완료 후 by-wish 로 합치고 삭제함 */ | ||
| async function ByWishV2Page({ params }: ByWishV2PageProps) { | ||
| if (process.env.NEXT_PUBLIC_STAGE === 'production') notFound(); | ||
|
|
||
| const { id } = await params; | ||
| const tournamentId = Number(id); | ||
|
|
||
| return ( | ||
| <div className="flex h-full flex-col bg-bg-layer-default"> | ||
| <div className="px-5 pt-padding-top"> | ||
| <Header | ||
| left={<HeaderIcon name="BACK" />} | ||
| center={ | ||
| <h1 className="heading-1-bold text-text-neutral-primary">내 위시에서 가져오기</h1> | ||
| } | ||
| /> | ||
| </div> | ||
| <ByWishV2Content tournamentId={tournamentId} /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default ByWishV2Page; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.