-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feature/BAR-155] 참고하는 레이아웃 수정 및 폴더 저장 삭제 기능 추가 #63
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,68 @@ | ||
import { useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { type Folder } from '@api/memoFolder/types'; | ||
import Button from '@components/Button'; | ||
import Dropdown from '@components/Dropdown'; | ||
import Icon from '@components/Icon'; | ||
import * as styles from '@domain/참고하는/components/FolderDialog.css'; | ||
import { useModalStore } from '@stores/modal'; | ||
import { useToastStore } from '@stores/toast'; | ||
import { COLORS } from '@styles/tokens'; | ||
|
||
import useDeleteTemplate from '../queries/useDeleteTemplate'; | ||
import useSaveTemplate from '../queries/useSaveTemplate'; | ||
|
||
interface FolderDialogProps { | ||
templateId: number; | ||
isArchived: boolean; | ||
memoFolders: Folder[]; | ||
} | ||
|
||
const FolderDialog = ({ templateId, memoFolders }: FolderDialogProps) => { | ||
const FolderDialog = ({ | ||
templateId, | ||
isArchived, | ||
memoFolders, | ||
}: FolderDialogProps) => { | ||
const { openModal } = useModalStore(); | ||
const { mutateAsync } = useSaveTemplate(); | ||
const { mutateAsync: saveTemplate } = useSaveTemplate(); | ||
const { mutateAsync: deleteTemplate } = useDeleteTemplate(); | ||
|
||
const queryClient = useQueryClient(); | ||
const { showToast } = useToastStore(); | ||
|
||
const handleFolderClick = (memoFolderId: number) => async () => | ||
await mutateAsync({ templateId, memoFolderId }); | ||
await saveTemplate( | ||
{ templateId, memoFolderId }, | ||
{ | ||
onSuccess: async () => { | ||
await queryClient.invalidateQueries({ | ||
queryKey: ['templates'], | ||
}); | ||
showToast({ message: '글이 저장됐어요.' }); | ||
}, | ||
}, | ||
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. 해당 부분 반영해보았습니다 감사합니다 ㅎㅎ |
||
); | ||
|
||
const handleDeleteTemplateClick = async () => { | ||
await deleteTemplate(templateId, { | ||
onSuccess: async () => { | ||
await queryClient.invalidateQueries({ | ||
queryKey: ['templates'], | ||
}); | ||
}, | ||
}); | ||
}; | ||
|
||
if (isArchived) | ||
return ( | ||
<Button onClick={handleDeleteTemplateClick}> | ||
<Icon | ||
icon="bookmarkRefer" | ||
className={styles.hoverBlue} | ||
color={COLORS['Grey/300']} | ||
/> | ||
</Button> | ||
); | ||
|
||
return ( | ||
<Dropdown size="medium" placement="bottom-center"> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,5 @@ | ||||||||||||||||
import { useState } from 'react'; | ||||||||||||||||
import Masonry, { ResponsiveMasonry } from 'react-responsive-masonry'; | ||||||||||||||||
|
||||||||||||||||
import FilterButtons from '@domain/참고하는/components/FilterButtons'; | ||||||||||||||||
import FilterHeader from '@domain/참고하는/components/FilterHeader'; | ||||||||||||||||
|
@@ -28,6 +29,8 @@ const 참고하는TabContent = () => { | |||||||||||||||
const handleFilterButtonSelect = (type: FilterButton) => () => | ||||||||||||||||
setSelectedFilterButton(type); | ||||||||||||||||
|
||||||||||||||||
if (!data) return null; | ||||||||||||||||
|
||||||||||||||||
return ( | ||||||||||||||||
<div className={styles.referPageTabWrapper}> | ||||||||||||||||
<FilterHeader | ||||||||||||||||
|
@@ -38,15 +41,17 @@ const 참고하는TabContent = () => { | |||||||||||||||
selectedFilterButton={selectedFilterButton} | ||||||||||||||||
handleFilterButtonSelect={handleFilterButtonSelect} | ||||||||||||||||
/> | ||||||||||||||||
<ul className={styles.referCardsWrapper}> | ||||||||||||||||
{data?.content.map((data) => ( | ||||||||||||||||
<참고하는TemplateCard | ||||||||||||||||
key={data.templateId} | ||||||||||||||||
data={data} | ||||||||||||||||
memoFolders={memoFoldersData} | ||||||||||||||||
/> | ||||||||||||||||
))} | ||||||||||||||||
</ul> | ||||||||||||||||
<ResponsiveMasonry columnsCountBreakPoints={{ 768: 2, 1080: 3 }}> | ||||||||||||||||
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. @dmswl98 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. 엇 아뇨!! 다른 페이지도 768px일 때 2줄, 1080일 때 3줄이라 const Responsive = ({ children }) => {
return <ResponsiveMasonry columnsCountBreakPoints={{ 768: 2, 1080: 3 }}>{children}</ResponsiveMasonry>
} 이렇게 구현해두면 어디에서든 쓸 수 있을 것 같아서요 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. @dmswl98 |
||||||||||||||||
<Masonry className={styles.referCardsWrapper} gutter="16px"> | ||||||||||||||||
{data.content.map((data) => ( | ||||||||||||||||
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. 어떤 코드인지 불명확해서...! 아래처럼 변경되면 좋을 것 같아요
Suggested change
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. 해당 부분 반영해보았습니다 감사합니다 ㅎㅎ |
||||||||||||||||
<참고하는TemplateCard | ||||||||||||||||
key={data.templateId} | ||||||||||||||||
data={data} | ||||||||||||||||
memoFolders={memoFoldersData} | ||||||||||||||||
/> | ||||||||||||||||
))} | ||||||||||||||||
</Masonry> | ||||||||||||||||
</ResponsiveMasonry> | ||||||||||||||||
</div> | ||||||||||||||||
); | ||||||||||||||||
}; | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import { deleteTemplate } from '../api'; | ||
|
||
const useDeleteTemplate = () => | ||
useMutation({ | ||
mutationFn: deleteTemplate, | ||
}); | ||
|
||
export default useDeleteTemplate; |
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.
요런 것도 정의된 타입에 의존시켜 작성하는 건 어떨까요?
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.
해당 부분 반영해보았습니다 감사합니다 ㅎㅎ