-
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 14 commits
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,21 @@ | ||
import Modal from '@/common/component/Modal/Modal'; | ||
|
||
import { BlockProvider } from '@/shared/hook/common/useBlockContext'; | ||
import { WorkSpaceProvider } from '@/shared/hook/common/useWorkSpaceContext'; | ||
import { useModalStore } from '@/shared/store/modal'; | ||
|
||
const ModalContainer = () => { | ||
const { isOpen, content, closeModal } = useModalStore(); | ||
|
||
if (!isOpen || !content) return null; | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={closeModal}> | ||
<WorkSpaceProvider> | ||
<BlockProvider>{content}</BlockProvider> | ||
</WorkSpaceProvider> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ModalContainer; |
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ import BlockItem from '@/page/archiving/createTimeBlock/component/Upload/File/Li | |
import { flexStyle, scrollStyle } from '@/page/archiving/createTimeBlock/component/Upload/UploadModal.style'; | ||
import { useDeleteFileMutation } from '@/page/archiving/createTimeBlock/hook/api/useDeleteFileMutation'; | ||
import { usePostTimeBlockMutation } from '@/page/archiving/createTimeBlock/hook/api/usePostTimeBlockMutation'; | ||
import { BlockData } from '@/page/archiving/createTimeBlock/type/blockType'; | ||
import { formatDatePost } from '@/page/archiving/createTimeBlock/util/date'; | ||
import { getRandomColor } from '@/page/archiving/index/util/color'; | ||
|
||
|
@@ -13,23 +12,24 @@ import Button from '@/common/component/Button/Button'; | |
import Flex from '@/common/component/Flex/Flex'; | ||
|
||
import { Files } from '@/shared/api/time-blocks/team/time-block/type'; | ||
import WorkSapceInfo from '@/shared/component/createWorkSpace/info/WorkSpaceInfo'; | ||
import WorkSapceInfo from '@/shared/component/createWorkSpaceModal/info/WorkSpaceInfo'; | ||
import { useBlockContext } from '@/shared/hook/common/useBlockContext'; | ||
import { useModalStore } from '@/shared/store/modal'; | ||
import { useTeamStore } from '@/shared/store/team'; | ||
import { useToastStore } from '@/shared/store/toast'; | ||
|
||
interface UploadModalProps { | ||
onClose: () => void; | ||
teamId: number; | ||
type: string; | ||
blockData: BlockData; | ||
} | ||
const UploadModal = () => { | ||
const { teamId } = useTeamStore(); | ||
|
||
const { formData, reset } = useBlockContext(); | ||
const { closeModal } = useModalStore(); | ||
|
||
const UploadModal = ({ onClose, teamId, type, blockData }: UploadModalProps) => { | ||
const [files, setFiles] = useState<File[]>([]); | ||
const [fileUrls, setFileUrls] = useState<Files>({}); | ||
const [uploadStatus, setUploadStatus] = useState<{ [key: string]: boolean }>({}); | ||
const [isAllUploaded, setIsAllUploaded] = useState(true); | ||
|
||
const { mutate: timeBlockMutate } = usePostTimeBlockMutation(teamId, type); | ||
const { mutate: timeBlockMutate } = usePostTimeBlockMutation(+teamId, 'executive'); | ||
const { mutate: fileDeleteMutate } = useDeleteFileMutation(); | ||
const { createToast } = useToastStore(); | ||
|
||
|
@@ -77,19 +77,20 @@ const UploadModal = ({ onClose, teamId, type, blockData }: UploadModalProps) => | |
}; | ||
|
||
const data = { | ||
name: blockData.blockName, | ||
name: formData.blockName, | ||
color: getRandomColor(), | ||
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. 수정 완료 했습니다! |
||
startDate: formatDatePost(blockData.dates.startDate), | ||
endDate: formatDatePost(blockData.dates.endDate), | ||
blockType: blockData.blockType, | ||
startDate: formatDatePost(formData.startDate), | ||
endDate: formatDatePost(formData.endDate), | ||
blockType: formData.blockType, | ||
files: fileUrls, | ||
}; | ||
|
||
const handleSave = () => { | ||
timeBlockMutate(data, { | ||
onSuccess: () => { | ||
onClose(); | ||
createToast('활동 블록이 생성되었습니다', 'success'); | ||
closeModal(); | ||
reset(); | ||
}, | ||
}); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,10 @@ import { ReactNode } from 'react'; | |
import Download from '@/common/asset/svg/download.svg?react'; | ||
import TrashBox from '@/common/asset/svg/trash_box.svg?react'; | ||
import Flex from '@/common/component/Flex/Flex'; | ||
import Modal from '@/common/component/Modal/Modal'; | ||
import Text from '@/common/component/Text/Text'; | ||
import { useModal } from '@/common/hook'; | ||
|
||
import DeleteModal from '@/shared/component/DeleteModal/DeleteModal'; | ||
import { useModalStore } from '@/shared/store/modal'; | ||
import { useTeamStore } from '@/shared/store/team'; | ||
|
||
interface DocumentItemProps { | ||
|
@@ -28,8 +27,6 @@ interface DocumentItemProps { | |
} | ||
|
||
const DocumentItem = ({ documentId, children, selectedId, blockName, fileUrl, color }: DocumentItemProps) => { | ||
const { isOpen, openModal, closeModal, currentContent } = useModal(); | ||
|
||
const fileName = children?.toString(); | ||
|
||
const { teamId } = useTeamStore(); | ||
|
@@ -46,30 +43,29 @@ const DocumentItem = ({ documentId, children, selectedId, blockName, fileUrl, co | |
|
||
const handleTrashClick = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => { | ||
e.stopPropagation(); | ||
openModal(<DeleteModal title="docs" detail="docs" onClose={closeModal} teamId={+teamId} id={documentId} />); | ||
// 모달 띄우기 | ||
const modalContent = <DeleteModal title="docs" detail="docs" teamId={+teamId} id={documentId} />; | ||
useModalStore.getState().openModal(modalContent); | ||
}; | ||
|
||
return ( | ||
<> | ||
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */} | ||
<li css={containerStyle(selectedId)} onClick={onClickDocumentItem}> | ||
{color && ( | ||
<div> | ||
<Text tag="body8" css={blockNameTextStyle(color)}> | ||
{blockName} | ||
</Text> | ||
</div> | ||
)} | ||
<Flex> | ||
<Text tag="body6" css={fileNameStyle}> | ||
{fileName} | ||
/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ | ||
<li css={containerStyle(selectedId)} onClick={onClickDocumentItem}> | ||
{color && ( | ||
<div> | ||
<Text tag="body8" css={blockNameTextStyle(color)}> | ||
{blockName} | ||
</Text> | ||
<Download width={20} height={20} css={{ cursor: 'pointer' }} onClick={handleDownloadClick} /> | ||
<TrashBox width={20} height={20} onClick={(e) => handleTrashClick(e)} css={{ cursor: 'pointer' }} /> | ||
</Flex> | ||
</li> | ||
<Modal isOpen={isOpen} children={currentContent} onClose={closeModal} /> | ||
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. 오 요 modal 컴포넌트가 굉장히 애매했는데 이제 없앨수 있군요! 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. 맞아요! 빈태그도 지워줬습니다!! |
||
</> | ||
</div> | ||
)} | ||
<Flex> | ||
<Text tag="body6" css={fileNameStyle}> | ||
{fileName} | ||
</Text> | ||
<Download width={20} height={20} css={{ cursor: 'pointer' }} onClick={handleDownloadClick} /> | ||
<TrashBox width={20} height={20} onClick={(e) => handleTrashClick(e)} css={{ cursor: 'pointer' }} /> | ||
</Flex> | ||
</li> | ||
); | ||
}; | ||
export default DocumentItem; |
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.
ModalContainer
는 사실 블록 생성과 워크스페이스 생성이라는 비즈니스 로직을 담고 있으니까common/components
에 두는 건 아닌 거 같애 !shared
로 뺍시당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.
넵!!