-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1069 from codingaring/part4-김유경-week20
[김유경] Week20
- Loading branch information
Showing
60 changed files
with
775 additions
and
604 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,39 @@ | ||
import { ModalInput } from "../ModalElements/ModalInput"; | ||
import Modal from "../Modal"; | ||
import { BaseModalProps } from "../ModalProp"; | ||
import { PrimaryButton } from "@styles/common/PrimaryButton"; | ||
import { postNewFolder } from "@data-access/axios/postNewFolder"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { useInputValue } from "@hooks/useInputValue"; | ||
import { MouseEvent } from "react"; | ||
|
||
export function AddFolder({ handleCloseModal }: BaseModalProps) { | ||
const { insertValue, onChange } = useInputValue(); | ||
const createFolderMutation = useMutation({ | ||
mutationFn: (createFolderName: string) => | ||
postNewFolder({ folderName: createFolderName }), | ||
}); | ||
|
||
const handleCreateNewFolder = async ( | ||
event: MouseEvent<HTMLButtonElement> | ||
) => { | ||
const createFolderName = insertValue; | ||
|
||
createFolderMutation.mutate(createFolderName); | ||
handleCloseModal(event); | ||
}; | ||
|
||
return ( | ||
<Modal title={"폴더 추가"} handleCloseModal={handleCloseModal}> | ||
<ModalInput | ||
value={insertValue} | ||
onChange={onChange} | ||
placeholder="내용 입력" | ||
type="text" | ||
></ModalInput> | ||
<PrimaryButton type="button" onClick={handleCreateNewFolder}> | ||
추가하기 | ||
</PrimaryButton> | ||
</Modal> | ||
); | ||
} |
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 @@ | ||
export * from "./AddFolder"; |
11 changes: 0 additions & 11 deletions
11
components/common/Modals/AddFolderContent/AddFolderContent.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,21 +1,51 @@ | ||
import { ModalButtonBlue } from "../ModalElements/ModalButtonBlue"; | ||
import * as S from "./AddToFolderStyled"; | ||
import Modal from "../Modal"; | ||
import { AddToFolderProps } from "../ModalProp"; | ||
import { PrimaryButton } from "@styles/common/PrimaryButton"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { postAddToFolder } from "@data-access/axios/postAddToFolder"; | ||
import { MouseEvent, useState } from "react"; | ||
|
||
export function AddToFolder({ | ||
linkURL, | ||
folderList, | ||
handleCloseModal, | ||
}: AddToFolderProps) { | ||
const [selectFolderId, setSelectFolderId] = useState<number>(); | ||
const addToFolderMutation = useMutation({ | ||
mutationFn: ({ url, folderId }: { url: string; folderId: number }) => | ||
postAddToFolder({ url: url, folderId: folderId }), | ||
}); | ||
|
||
const handleFolderId = (event: MouseEvent<HTMLButtonElement>) => { | ||
setSelectFolderId(Number(event.currentTarget.id)); | ||
}; | ||
|
||
const handleAddToFolder = async (event: MouseEvent<HTMLButtonElement>) => { | ||
if (linkURL && selectFolderId) { | ||
addToFolderMutation.mutate({ url: linkURL, folderId: selectFolderId }); | ||
} | ||
}; | ||
|
||
export function AddToFolder({ linkURL, data }: AddToFolderProps) { | ||
return ( | ||
<> | ||
<Modal handleCloseModal={handleCloseModal} title={"폴더에 추가"}> | ||
<S.SelectLink>{linkURL}</S.SelectLink> | ||
<S.FolderListContainer> | ||
{data?.map((folder) => ( | ||
<S.SelectFolder key={folder.id}> | ||
{folderList?.map((folder) => ( | ||
<S.SelectFolder | ||
id={folder.id} | ||
key={folder.id} | ||
onClick={handleFolderId} | ||
> | ||
<S.FolderName>{folder.name}</S.FolderName> | ||
<S.FolderCount>{folder.link.count}개 링크</S.FolderCount> | ||
<S.FolderCount>{folder.link_count}개 링크</S.FolderCount> | ||
<S.SelectFolderIcon /> | ||
</S.SelectFolder> | ||
))} | ||
</S.FolderListContainer> | ||
<ModalButtonBlue type="button">삭제하기</ModalButtonBlue> | ||
</> | ||
<PrimaryButton type="button" onClick={handleAddToFolder}> | ||
추가하기 | ||
</PrimaryButton> | ||
</Modal> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,12 +1,30 @@ | ||
import * as S from "./DeleteFolderStyled"; | ||
import { ModalButtonRed } from "../ModalElements/ModalButtonRed"; | ||
import { DeleteFolderProps } from "../ModalProp"; | ||
import Modal from "../Modal"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { deleteFolder } from "@data-access/axios/deleteFolder"; | ||
import { MouseEvent } from "react"; | ||
|
||
export default function DeleteFolder({ | ||
selectFolder, | ||
folderId, | ||
handleCloseModal, | ||
}: DeleteFolderProps) { | ||
const deleteFolderMutation = useMutation({ | ||
mutationFn: ({ folderId }: { folderId: number | string }) => | ||
deleteFolder({ folderId }), | ||
}); | ||
|
||
const handleDeleteFolder = (event: MouseEvent<HTMLButtonElement>) => { | ||
deleteFolderMutation.mutate({ folderId: folderId }); | ||
handleCloseModal(event); | ||
}; | ||
|
||
export default function DeleteFolder({ selectFolder }: DeleteFolderProps) { | ||
return ( | ||
<> | ||
<Modal title="폴더 삭제" handleCloseModal={handleCloseModal}> | ||
<S.DeleteFolderSubtitle>{selectFolder}</S.DeleteFolderSubtitle> | ||
<ModalButtonRed>삭제하기</ModalButtonRed> | ||
</> | ||
<ModalButtonRed onClick={handleDeleteFolder}>삭제하기</ModalButtonRed> | ||
</Modal> | ||
); | ||
} |
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,12 +1,30 @@ | ||
import { ModalButtonRed } from "../ModalElements/ModalButtonRed"; | ||
import * as S from "./DeleteLinkStyled"; | ||
import { DeleteLinkProps } from "../ModalProp"; | ||
import Modal from "../Modal"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { deleteLink } from "@data-access/axios/deleteLink"; | ||
import { MouseEvent } from "react"; | ||
|
||
export default function DeleteLink({ | ||
deleteURL, | ||
handleCloseModal, | ||
linkId, | ||
}: DeleteLinkProps) { | ||
const deleteLinkMutation = useMutation({ | ||
mutationFn: ({ linkId }: { linkId: number }) => deleteLink({ linkId }), | ||
}); | ||
|
||
const handleDeleteLink = (event: MouseEvent<HTMLButtonElement>) => { | ||
deleteLinkMutation.mutate({ linkId: Number(event.currentTarget.id) }); | ||
}; | ||
|
||
export default function DeleteLink({ deleteURL }: DeleteLinkProps) { | ||
return ( | ||
<> | ||
<Modal title="삭제하기" handleCloseModal={handleCloseModal}> | ||
<S.DeleteLinkURL>{deleteURL}</S.DeleteLinkURL> | ||
<ModalButtonRed type="button">삭제하기</ModalButtonRed> | ||
</> | ||
<ModalButtonRed type="button" id={linkId} onClick={handleDeleteLink}> | ||
삭제하기 | ||
</ModalButtonRed> | ||
</Modal> | ||
); | ||
} |
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.
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
Oops, something went wrong.