-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Refactor] 모달 띄우는 로직, 데이터 상태 로직 리팩토링.. #197
Changes from 1 commit
23e3d6d
2f33596
1034e74
f566a02
13021a7
52a7280
73ca6e8
77ee9fc
5974228
50f68e9
da808c4
2535167
3a1feff
a741a89
44f9b0c
503f75f
bedbb83
f68a155
f825ceb
764eacc
404f9a5
aa418e7
6ae06bc
8b41e31
fb23c44
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Modal from '@/common/component/Modal/Modal'; | ||
|
||
import { useModalStore } from '@/shared/store/modal'; | ||
import { BlockFlow, BlockProvider } from '@/shared/store/useBlockContext'; | ||
import { WorkSpaceFlow, WorkSpaceProvider } from '@/shared/store/useWorkSpaceContext'; | ||
|
||
const ModalManager = () => { | ||
const { isOpen, content, closeModal, id } = useModalStore(); | ||
|
||
if (!isOpen || !content) return null; | ||
|
||
let ModalContent; | ||
|
||
switch (id) { | ||
case 'workspace': | ||
ModalContent = ( | ||
<WorkSpaceProvider> | ||
<WorkSpaceFlow /> | ||
</WorkSpaceProvider> | ||
); | ||
break; | ||
case 'block': | ||
ModalContent = ( | ||
<BlockProvider> | ||
<BlockFlow /> | ||
</BlockProvider> | ||
); | ||
break; | ||
default: | ||
return null; | ||
} | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={closeModal}> | ||
{content} | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ModalManager; |
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. 추가적으로 폴더명이
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. 좋습니다! 변경완료 했습니다! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import Text from '@/common/component/Text/Text'; | |
|
||
import { cancelStyle, deleteStyle } from '@/shared/component/DeleteModal/DeleteModal.style'; | ||
import { DELETE_DETAIL, DELETE_TITLE } from '@/shared/constant'; | ||
import { useDeleteModalStore } from '@/shared/store/modal'; | ||
import { useModalStore } from '@/shared/store/modal'; | ||
|
||
interface DeleteModalProps { | ||
title: 'block' | 'docs'; | ||
|
@@ -22,7 +22,7 @@ const DeleteModal = ({ title, detail, teamId, id }: DeleteModalProps) => { | |
const { mutateAsync: blockMutate } = useDeleteBlockMutation(); | ||
const { mutateAsync: documentMutate } = useDeleteDocumentMutation(); | ||
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. 반환되는 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. 넵!! mutate로 수정 완료 했습니다! |
||
|
||
const { isOpen, closeModal } = useDeleteModalStore(); | ||
const { closeModal } = useModalStore(); | ||
|
||
const handleDeleteBlock = (teamId: number, id: number) => { | ||
blockMutate( | ||
|
@@ -49,32 +49,30 @@ const DeleteModal = ({ title, detail, teamId, id }: DeleteModalProps) => { | |
const handleDelete = title === 'block' ? handleDeleteBlock : handleDeleteDocs; | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={closeModal}> | ||
<Flex | ||
styles={{ | ||
direction: 'column', | ||
align: 'center', | ||
justify: 'center', | ||
paddingRight: '9.35rem', | ||
paddingLeft: '9.35rem', | ||
}}> | ||
<Heading tag="H5" css={{ fontWeight: 600 }}> | ||
{DELETE_TITLE[title.toUpperCase() as keyof typeof DELETE_TITLE]} | ||
</Heading> | ||
<Text tag="body4" css={{ marginTop: '1rem', fontWeight: 400 }}> | ||
{DELETE_DETAIL[detail.toUpperCase() as keyof typeof DELETE_DETAIL]} | ||
</Text> | ||
<Flex | ||
styles={{ | ||
direction: 'column', | ||
align: 'center', | ||
justify: 'center', | ||
paddingRight: '9.35rem', | ||
paddingLeft: '9.35rem', | ||
}}> | ||
<Heading tag="H5" css={{ fontWeight: 600 }}> | ||
{DELETE_TITLE[title.toUpperCase() as keyof typeof DELETE_TITLE]} | ||
</Heading> | ||
<Text tag="body4" css={{ marginTop: '1rem', fontWeight: 400 }}> | ||
{DELETE_DETAIL[detail.toUpperCase() as keyof typeof DELETE_DETAIL]} | ||
</Text> | ||
|
||
<Flex styles={{ direction: 'row', align: 'center', justify: 'center', gap: '0.8rem', marginTop: '2.4rem' }}> | ||
<Button variant="secondary" size="large" onClick={closeModal} css={cancelStyle}> | ||
취소 | ||
</Button> | ||
<Button variant="primary" size="large" onClick={() => handleDelete(teamId, id)} css={deleteStyle}> | ||
삭제 | ||
</Button> | ||
</Flex> | ||
<Flex styles={{ direction: 'row', align: 'center', justify: 'center', gap: '0.8rem', marginTop: '2.4rem' }}> | ||
<Button variant="secondary" size="large" onClick={() => closeModal()} css={cancelStyle}> | ||
취소 | ||
</Button> | ||
<Button variant="primary" size="large" onClick={() => handleDelete(teamId, id)} css={deleteStyle}> | ||
삭제 | ||
</Button> | ||
</Flex> | ||
</Modal> | ||
</Flex> | ||
); | ||
}; | ||
|
||
|
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.
그렇다면 하나의 폴더안에서 관리하는 것이 훨씬 더 가독성에 좋을 것 같아요. 특정 폴더 하위에, 각 컨텐츠에 해당하는 컴포넌트들을 모아 둔다면 훨씬 더 알아보기 쉬울 것 같아요 ! 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. 주용님 말에 동의합니다! 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. 저도 동의합니다! 현재 createWorkSpaceModal 폴더안에 modalContents 폴더를 생성하여 그 안에 category, image, name과 같은 모달 폼 과정의 코드들을 넣었는데요..! 이렇게 바꾸는 거 괜찮을까요?? |
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.
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. 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. 좋아융 ~ |
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.
if 조건문 안에 or 연산 넣은거 깔끔하고 이해도 잘되네용 👍
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.
감사합니당!