-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] 같은 폴더 내에서 Pick Drag&Drop 구현 (#420)
* chore: 백엔드 api 타입 최신화 * chore: util 스펠링 정확하게 변경 * feat: pickType 추가 * feat: getPicksByFolderId 추가 * refactor: viewTemplate 코드 변경 * refactor: 바로 호출이 아닌, useEffect 내에서 비동기함수 호출 * chore: git pull을 위한 커밋 * refactor: pickCardListViewer로 PickCard 컴포넌트 이동 * design: card link style 변경 * feat: 더블 클릭시 링크 이동 * feat: dnd가 가능한 list와 그렇지 않은 list분리 * refactor: dnd여부에 따라 PickListViewer분리 * refactor: DnDCurrentType을 dnd.type으로 이동 * refactor: 공통 utils함수로 추출 * feat: 픽에서 픽으로 이동(api 미연결) * feat: pick multi-select 구현 * feat: multi-select drag&drop 구현(api 미연결) * feat: 같은 폴더 내 픽 drag&drop api 연결
- Loading branch information
Showing
46 changed files
with
912 additions
and
226 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,46 @@ | ||
import { HTTPError } from 'ky'; | ||
import { apiClient, returnErrorFromHTTPError } from '@/apis'; | ||
import { API_URLS } from '../apiConstants'; | ||
import type { | ||
GetPicksByFolderIdResponseType, | ||
PickIdOrderedListType, | ||
PickInfoRecordType, | ||
PickListType, | ||
} from '@/types'; | ||
|
||
export const getPicksByFolderId = async (folderId: number) => { | ||
const data = await getPickListByFolderId(folderId); | ||
|
||
const pickRecordData = generatePickRecordData(data[0]['pickList']); | ||
|
||
return pickRecordData; | ||
}; | ||
|
||
const getPickListByFolderId = async (folderId: number) => { | ||
try { | ||
const response = await apiClient.get<GetPicksByFolderIdResponseType>( | ||
API_URLS.GET_PICKS_BY_FOLDER_ID(folderId) | ||
); | ||
const data = await response.json(); | ||
|
||
return data; | ||
} catch (httpError) { | ||
if (httpError instanceof HTTPError) { | ||
const error = returnErrorFromHTTPError(httpError); | ||
throw error; | ||
} | ||
throw httpError; | ||
} | ||
}; | ||
|
||
const generatePickRecordData = (pickList: PickListType) => { | ||
const pickIdOrderedList: PickIdOrderedListType = []; | ||
const pickInfoRecord = {} as PickInfoRecordType; | ||
|
||
for (const pickInfo of pickList) { | ||
pickIdOrderedList.push(pickInfo.id); | ||
pickInfoRecord[`${pickInfo.id}`] = pickInfo; | ||
} | ||
|
||
return { pickIdOrderedList, pickInfoRecord }; | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { useGetPickQuery } from './getPick/useGetPickQuery'; | ||
export { useUpdatePickMutation } from './updatePick/useUpdatePickMutation'; | ||
export { getPicksByFolderId } from './getPicksByFolderId'; | ||
export { movePicks } from './movePicks'; |
This file contains 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,16 @@ | ||
import { HTTPError } from 'ky'; | ||
import { apiClient, returnErrorFromHTTPError } from '@/apis'; | ||
import { API_URLS } from '../apiConstants'; | ||
import type { MovePicksRequestType } from '@/types'; | ||
|
||
export const movePicks = async (movePicksInfo: MovePicksRequestType) => { | ||
try { | ||
await apiClient.patch(API_URLS.MOVE_PICKS, { json: movePicksInfo }); | ||
} catch (httpError) { | ||
if (httpError instanceof HTTPError) { | ||
const error = returnErrorFromHTTPError(httpError); | ||
throw error; | ||
} | ||
throw httpError; | ||
} | ||
}; |
This file contains 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 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 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 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 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
2 changes: 0 additions & 2 deletions
2
frontend/techpick/src/components/FolderTree/folderListItem.util.ts
This file contains 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 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 was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
frontend/techpick/src/components/PickCardGridLayout/PickCardGridLayout.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
frontend/techpick/src/components/PickCardGridLayout/pickCardGridLayout.css.ts
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
frontend/techpick/src/components/PickListViewer/DraggablePickListViewer.tsx
This file contains 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,58 @@ | ||
import type { ReactNode } from 'react'; | ||
import { PickDnDCard } from './PickDnDCard'; | ||
import { PickDnDCardListLayout } from './PickDnDCardListLayout'; | ||
import type { | ||
PickViewItemComponentProps, | ||
PickViewItemListLayoutComponentProps, | ||
} from './PickListViewer'; | ||
import type { PickInfoType } from '@/types'; | ||
|
||
export function DraggablePickListViewer({ | ||
pickList, | ||
viewType = 'card', | ||
folderId, | ||
}: PickListViewerProps) { | ||
const { PickViewItemComponent, PickViewItemListLayoutComponent } = | ||
DND_PICK_LIST_VIEW_TEMPLATES[viewType]; | ||
|
||
return ( | ||
<PickViewItemListLayoutComponent folderId={folderId}> | ||
{pickList.map((pickInfo) => ( | ||
<PickViewItemComponent key={pickInfo.id} pickInfo={pickInfo} /> | ||
))} | ||
</PickViewItemListLayoutComponent> | ||
); | ||
} | ||
|
||
interface PickListViewerProps { | ||
pickList: PickInfoType[]; | ||
folderId: number; | ||
viewType?: DnDViewTemplateType; | ||
} | ||
|
||
const DND_PICK_LIST_VIEW_TEMPLATES: Record< | ||
DnDViewTemplateType, | ||
DnDViewTemplateValueType | ||
> = { | ||
card: { | ||
PickViewItemComponent: PickDnDCard, | ||
PickViewItemListLayoutComponent: PickDnDCardListLayout, | ||
}, | ||
}; | ||
|
||
/** | ||
* @description DnDViewTemplateType은 Drag&Drop이 가능한 UI 중 무엇을 보여줄지 나타냅니다. ex) card, list | ||
*/ | ||
type DnDViewTemplateType = 'card'; | ||
|
||
interface DnDViewTemplateValueType { | ||
PickViewItemListLayoutComponent: ( | ||
props: PickViewDnDItemListLayoutComponentProps | ||
) => ReactNode; | ||
PickViewItemComponent: (props: PickViewDnDItemComponentProps) => ReactNode; | ||
} | ||
|
||
export type PickViewDnDItemListLayoutComponentProps = | ||
PickViewItemListLayoutComponentProps<{ folderId: number }>; | ||
|
||
export type PickViewDnDItemComponentProps = PickViewItemComponentProps; |
Oops, something went wrong.