-
Notifications
You must be signed in to change notification settings - Fork 4
feat: 밸런스게임 모바일 페이지 수정, 삭제 기능 연결 #306
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
Changes from all commits
e1c0024
ff7859c
ead7442
4e2a70c
7f269ba
31db187
11ad597
59eef3e
69e3da0
74f1f44
6813b27
9797d2f
d4ffaf3
34d01af
e7c0e2f
bb5c1d7
cb28cc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import React, { useState } from 'react'; | ||
| import { BUTTON_TEXT, MAX_STAGE } from '@/constants/game'; | ||
| import { GameSet } from '@/types/game'; | ||
| import ToastModal from '@/components/atoms/ToastModal/ToastModal'; | ||
| import Button from '@/components/mobile/atoms/Button/Button'; | ||
| import GameStageLabel from '@/components/mobile/atoms/GameStageLabel/GameStageLabel'; | ||
|
|
@@ -12,7 +13,15 @@ import TempGameModal from '@/components/mobile/molecules/TempGameModal/TempGameM | |
| import { usePostBalanceGameForm } from '@/hooks/game/usePostBalanceGameForm'; | ||
| import * as S from './BalanceGameCreateSection.style'; | ||
|
|
||
| const BalanceGameCreateSection = () => { | ||
| interface BalanceGameCreateSectionProps { | ||
| existingGame?: GameSet; | ||
| gameSetId?: number; | ||
| } | ||
|
|
||
| const BalanceGameCreateSection = ({ | ||
| existingGame, | ||
| gameSetId, | ||
|
Comment on lines
+17
to
+23
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 organisms의 props는 전부 옵셔널인데, default 설정이 없으면 어떻게 처리되고 있는지 궁금합니다!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 게임이 존재할 때는 게임 수정, 존재하지 않을 때는 게임 생성이 수행됩니다! |
||
| }: BalanceGameCreateSectionProps) => { | ||
| const [gameStage, setGameStage] = useState<number>(0); | ||
|
|
||
| const [tagModalOpen, setTagModalOpen] = useState<boolean>(false); | ||
|
|
@@ -34,7 +43,13 @@ const BalanceGameCreateSection = () => { | |
| handleBalanceGame, | ||
| handleTempBalanceGame, | ||
| handleDraftButton, | ||
| } = usePostBalanceGameForm(gameStage, setGameStage, setTagModalOpen); | ||
| } = usePostBalanceGameForm( | ||
| gameStage, | ||
| setGameStage, | ||
| setTagModalOpen, | ||
| existingGame, | ||
| gameSetId, | ||
| ); | ||
|
|
||
| return ( | ||
| <form css={S.balanceGameStyling}> | ||
|
|
@@ -79,7 +94,8 @@ const BalanceGameCreateSection = () => { | |
| }} | ||
| onConfirm={() => { | ||
| handleDeleteImg( | ||
| form.games[gameStage].gameOptions[selectedOptionId].fileId, | ||
| form.games[gameStage].gameOptions[selectedOptionId].fileId ?? | ||
| null, | ||
| selectedOptionId, | ||
| ); | ||
| setImgDeleteModalOpen(false); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ import { | |
| } from '@/assets'; | ||
| import { PATH } from '@/constants/path'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import { useNewSelector } from '@/store'; | ||
| import { selectAccessToken } from '@/store/auth'; | ||
| import { useGameEndBookmark } from '@/hooks/game/useBalanceGameBookmark'; | ||
| import useToastModal from '@/hooks/modal/useToastModal'; | ||
| import ToastModal from '@/components/atoms/ToastModal/ToastModal'; | ||
|
|
@@ -29,7 +31,7 @@ const BalanceGameEndingSection = ({ | |
| isMyEndBookmark, | ||
| }: BalanceGameEndingSectionProps) => { | ||
| const navigate = useNavigate(); | ||
| const isGuest = !localStorage.getItem('accessToken'); | ||
| const isGuest = !useNewSelector(selectAccessToken); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 리덕스로 일원화 한 점 아주 좋습니다~ |
||
|
|
||
| const [shareModalOpen, setShareModalOpen] = useState<boolean>(false); | ||
| const { isVisible, modalText, showToastModal } = useToastModal(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,12 @@ | ||||||||||||||||||||||||||||
| import React, { useState, useEffect, useRef } from 'react'; | ||||||||||||||||||||||||||||
| import { MobileBookmarkDF, MobileBookmarkPR, MobileShare } from '@/assets'; | ||||||||||||||||||||||||||||
| import { useNavigate } from 'react-router-dom'; | ||||||||||||||||||||||||||||
| import { useNewSelector } from '@/store'; | ||||||||||||||||||||||||||||
| import { selectAccessToken } from '@/store/auth'; | ||||||||||||||||||||||||||||
| import { GameDetail, GameSet } from '@/types/game'; | ||||||||||||||||||||||||||||
| import { createArrayFromCommaString } from '@/utils/array'; | ||||||||||||||||||||||||||||
| import { PATH } from '@/constants/path'; | ||||||||||||||||||||||||||||
| import { ERROR, PROMPT } from '@/constants/message'; | ||||||||||||||||||||||||||||
| import MenuTap, { MenuItem } from '@/components/atoms/MenuTap/MenuTap'; | ||||||||||||||||||||||||||||
| import useToastModal from '@/hooks/modal/useToastModal'; | ||||||||||||||||||||||||||||
| import { VoteRecord } from '@/types/vote'; | ||||||||||||||||||||||||||||
|
|
@@ -15,7 +19,10 @@ import ToastModal from '@/components/atoms/ToastModal/ToastModal'; | |||||||||||||||||||||||||||
| import BalanceGameBox from '@/components/mobile/molecules/BalanceGameBox/BalanceGameBox'; | ||||||||||||||||||||||||||||
| import { useGuestGameVote } from '@/hooks/game/useBalanceGameVote'; | ||||||||||||||||||||||||||||
| import { useGameBookmark } from '@/hooks/game/useBalanceGameBookmark'; | ||||||||||||||||||||||||||||
| import ShareModal from '../../molecules/ShareModal/ShareModal'; | ||||||||||||||||||||||||||||
| import { useDeleteGameSetMutation } from '@/hooks/api/game/useDeleteGameSetMutation'; | ||||||||||||||||||||||||||||
| import ShareModal from '@/components/mobile/molecules/ShareModal/ShareModal'; | ||||||||||||||||||||||||||||
| import TextModal from '@/components/mobile/molecules/TextModal/TextModal'; | ||||||||||||||||||||||||||||
| import ReportModal from '@/components/mobile/molecules/ReportModal/ReportModal'; | ||||||||||||||||||||||||||||
| import * as S from './BalanceGameSection.style'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export interface BalanceGameSectionProps { | ||||||||||||||||||||||||||||
|
|
@@ -51,11 +58,13 @@ const BalanceGameSection = ({ | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const gameStages: GameDetail[] = | ||||||||||||||||||||||||||||
| game?.gameDetailResponses ?? gameDefaultDetail; | ||||||||||||||||||||||||||||
| const isGuest = !localStorage.getItem('accessToken'); | ||||||||||||||||||||||||||||
| const isGuest = !useNewSelector(selectAccessToken); | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 옵셔널 체이닝을 통한 안전한 접근이 필요합니다.
다음과 같이 수정을 제안합니다: - const subTagList = createArrayFromCommaString(game?.subTag ?? '');
+ const subTagList = game ? createArrayFromCommaString(game.subTag ?? '') : [];Also applies to: 65-65 |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const [guestVotedList, setGuestVotedList] = useState<VoteRecord[]>([]); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const currentGame: GameDetail = gameStages[currentStage]; | ||||||||||||||||||||||||||||
| const subTagList = createArrayFromCommaString(game?.subTag ?? ''); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const { handleGuestGameVote } = useGuestGameVote( | ||||||||||||||||||||||||||||
| guestVotedList, | ||||||||||||||||||||||||||||
| setGuestVotedList, | ||||||||||||||||||||||||||||
|
|
@@ -64,8 +73,16 @@ const BalanceGameSection = ({ | |||||||||||||||||||||||||||
| game, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const [shareModalOpen, setShareModalOpen] = useState<boolean>(false); | ||||||||||||||||||||||||||||
| const { isVisible, modalText, showToastModal } = useToastModal(); | ||||||||||||||||||||||||||||
| const { mutate: deleteBalanceGame } = useDeleteGameSetMutation(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const [activeModal, setActiveModal] = useState< | ||||||||||||||||||||||||||||
| 'reportGame' | 'reportText' | 'deleteText' | 'share' | 'none' | ||||||||||||||||||||||||||||
| >('none'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const onCloseModal = () => { | ||||||||||||||||||||||||||||
| setActiveModal('none'); | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||
| if (game && initialRender.current) { | ||||||||||||||||||||||||||||
|
|
@@ -89,6 +106,20 @@ const BalanceGameSection = ({ | |||||||||||||||||||||||||||
| changeStage(1); | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const handleGameDeleteButton = () => { | ||||||||||||||||||||||||||||
| deleteBalanceGame( | ||||||||||||||||||||||||||||
| { gameSetId }, | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| onSuccess: () => { | ||||||||||||||||||||||||||||
| navigate('/'); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| onError: () => { | ||||||||||||||||||||||||||||
| showToastModal(ERROR.DELETEGAME.FAIL); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const { handleBookmarkClick } = useGameBookmark( | ||||||||||||||||||||||||||||
| isGuest, | ||||||||||||||||||||||||||||
| isMyGame, | ||||||||||||||||||||||||||||
|
|
@@ -99,8 +130,28 @@ const BalanceGameSection = ({ | |||||||||||||||||||||||||||
| game, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const myGameItem: MenuItem[] = [{ label: '수정' }, { label: '삭제' }]; | ||||||||||||||||||||||||||||
| const otherGameItem: MenuItem[] = [{ label: '신고' }]; | ||||||||||||||||||||||||||||
| const myGameItem: MenuItem[] = [ | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| label: '수정', | ||||||||||||||||||||||||||||
| onClick: () => { | ||||||||||||||||||||||||||||
| navigate(`/${PATH.CREATE.GAME}`, { state: { game, gameSetId } }); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| label: '삭제', | ||||||||||||||||||||||||||||
| onClick: () => { | ||||||||||||||||||||||||||||
| setActiveModal('deleteText'); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| const otherGameItem: MenuItem[] = [ | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| label: '신고', | ||||||||||||||||||||||||||||
| onClick: () => { | ||||||||||||||||||||||||||||
| setActiveModal('reportText'); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||
| <div css={S.balanceGameStyling}> | ||||||||||||||||||||||||||||
|
|
@@ -111,17 +162,34 @@ const BalanceGameSection = ({ | |||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||
| <div css={S.centerStyling}> | ||||||||||||||||||||||||||||
| <ShareModal | ||||||||||||||||||||||||||||
| isOpen={shareModalOpen} | ||||||||||||||||||||||||||||
| isOpen={activeModal === 'share'} | ||||||||||||||||||||||||||||
| onConfirm={() => {}} | ||||||||||||||||||||||||||||
| onClose={onCloseModal} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| <TextModal | ||||||||||||||||||||||||||||
| text={PROMPT.GAME.DELETE} | ||||||||||||||||||||||||||||
| isOpen={activeModal === 'deleteText'} | ||||||||||||||||||||||||||||
| onConfirm={handleGameDeleteButton} | ||||||||||||||||||||||||||||
| onClose={onCloseModal} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| <TextModal | ||||||||||||||||||||||||||||
| text={PROMPT.GAME.REPORT} | ||||||||||||||||||||||||||||
| isOpen={activeModal === 'reportText'} | ||||||||||||||||||||||||||||
| onConfirm={() => setActiveModal('reportGame')} | ||||||||||||||||||||||||||||
| onClose={onCloseModal} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| <ReportModal | ||||||||||||||||||||||||||||
| isOpen={activeModal === 'reportGame'} | ||||||||||||||||||||||||||||
| onConfirm={() => {}} | ||||||||||||||||||||||||||||
| onClose={() => setShareModalOpen(false)} | ||||||||||||||||||||||||||||
| onClose={onCloseModal} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
|
Comment on lines
+181
to
185
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion ReportModal 컴포넌트에 대한 확인 핸들러 구현이 필요합니다. ReportModal의 onConfirm 핸들러가 빈 함수로 설정되어 있습니다. 실제 신고 기능을 구현하거나 해당 기능이 아직 준비되지 않았다면 TODO 주석을 추가하는 것이 좋습니다. - onConfirm={() => {}}
+ onConfirm={() => {
+ // TODO: 신고 API 연동 구현 필요
+ }}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| <div css={S.balancGameTopWrapper}> | ||||||||||||||||||||||||||||
| <GameTag tag={game?.mainTag ?? ''} /> | ||||||||||||||||||||||||||||
| <div css={S.iconButtonWrapper}> | ||||||||||||||||||||||||||||
| <IconButton | ||||||||||||||||||||||||||||
| icon={<MobileShare />} | ||||||||||||||||||||||||||||
| onClick={() => setShareModalOpen(true)} | ||||||||||||||||||||||||||||
| onClick={() => setActiveModal('share')} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| <IconButton | ||||||||||||||||||||||||||||
| icon={ | ||||||||||||||||||||||||||||
|
|
@@ -164,7 +232,8 @@ const BalanceGameSection = ({ | |||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| <div css={S.subTagWrapper}> | ||||||||||||||||||||||||||||
| {game.subTag && <GameTagChip tag={game.subTag} />} | ||||||||||||||||||||||||||||
| {game.subTag && | ||||||||||||||||||||||||||||
| subTagList.map((tag) => <GameTagChip key={tag} tag={tag} />)} | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런 표현 좋네요~