-
Notifications
You must be signed in to change notification settings - Fork 4
[Refactor] 마이페이지 카드 디자인 수정 | 모달창 개선 | 폴더 구조 일부 리팩토링 제안 | 리액트 쿼리 훅 #258
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8168056
feat: 마이페이지 질문지 카드 컴포넌트 생성
yiseungyun 7f2b9d0
feat: 마이페이지 질문지 카드 카테고리 추가
yiseungyun 0796265
Merge branch 'dev' of https://github.com/boostcampwm-2024/web27-Previ…
yiseungyun 1e6fa84
refactor: 마이페이지 UI 분리
yiseungyun 4dd4783
refactor: api 요청 함수 이름 직관적으로 변경
yiseungyun fd3355a
feat: 질문지 api 관련 함수 작성
yiseungyun 03a2736
refactor: 마이페이지 구조 리팩토링
yiseungyun ceda6bb
fix: 모달창 개선
yiseungyun 7eb8dfd
feat: 마이페이지에서 질문지 삭제 구현
yiseungyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or 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,7 @@ | ||
| import axios from "axios"; | ||
|
|
||
| export const deleteQuestionList = async (questionListId: number) => { | ||
| const response = await axios.delete(`api/question-list/${questionListId}`); | ||
|
|
||
| return response.data; | ||
| }; |
This file contains hidden or 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,19 @@ | ||
| import axios from "axios"; | ||
|
|
||
| interface QuestionMetadataRequest { | ||
| title?: string; | ||
| categoryNames?: string[]; | ||
| isPublic?: boolean; | ||
| } | ||
|
|
||
| export const editQuestionMetadata = async ( | ||
| questionListId: string, | ||
| data: QuestionMetadataRequest | ||
| ) => { | ||
| const response = await axios.patch( | ||
| `/api/question-list/${questionListId}`, | ||
| data | ||
| ); | ||
|
|
||
| return response.data; | ||
| }; |
This file contains hidden or 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 hidden or 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 axios from "axios"; | ||
|
|
||
| interface QuestionListProps { | ||
| page: number; | ||
| limit: number; | ||
| } | ||
|
|
||
| export const getQuestionList = async ({ page, limit }: QuestionListProps) => { | ||
| const response = await axios.get("/api/question-list", { | ||
| params: { | ||
| page, | ||
| limit, | ||
| }, | ||
| }); | ||
| return response.data; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| interface TitleProps { | ||
| title: string; | ||
| } | ||
|
|
||
| const PageTitle = ({ title }: TitleProps) => { | ||
| return ( | ||
| <h1 className={"text-bold-l mb-6 text-gray-black dark:text-white"}> | ||
| {title} | ||
| </h1> | ||
| ); | ||
| }; | ||
|
|
||
| export default PageTitle; |
This file contains hidden or 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 hidden or 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,15 @@ | ||
| import useModalStore from "@/stores/useModalStore"; | ||
| import Button from "@components/common/Button"; | ||
|
|
||
| const ButtonSection = () => { | ||
| const { closeModal } = useModalStore(); | ||
|
|
||
| return ( | ||
| <div className="flex w-full gap-4 my-4 px-8"> | ||
| <Button text="취소하기" type="gray" onClick={closeModal} /> | ||
| <Button text="수정하기" type="green" onClick={() => {}} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ButtonSection; |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
frontend/src/components/mypage/ProfileEditModal/ButtonSection.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,10 @@ | ||
| const ProfileIcon = () => { | ||
| return ( | ||
| <div className="relative bg-gray-50 rounded-full w-32 h-32 border-2 border-gray-100 overflow-hidden"> | ||
| <div className="absolute rounded-full w-12 h-12 bg-gray-500 top-5 left-1/2 -translate-x-1/2"></div> | ||
| <div className="absolute rounded-custom-3xl w-32 h-32 bg-gray-500 top-[4.75rem]"></div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ProfileIcon; |
13 changes: 13 additions & 0 deletions
13
frontend/src/components/mypage/QuestionList/QuestionItem/Category.tsx
This file contains hidden or 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,13 @@ | ||
| interface CategoryProps { | ||
| text: string; | ||
| } | ||
|
|
||
| const Category = ({ text }: CategoryProps) => { | ||
| return ( | ||
| <span className="px-3 py-1 bg-green-50 text-green-600 dark:bg-green-600/20 dark:text-green-400 text-medium-s rounded-full"> | ||
| {text} | ||
| </span> | ||
| ); | ||
| }; | ||
|
|
||
| export default Category; |
90 changes: 90 additions & 0 deletions
90
frontend/src/components/mypage/QuestionList/QuestionItem/index.tsx
This file contains hidden or 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,90 @@ | ||
| import { useNavigate } from "react-router-dom"; | ||
| import { MdEdit } from "react-icons/md"; | ||
| import { RiDeleteBin6Fill } from "react-icons/ri"; | ||
| import { FaBookmark } from "react-icons/fa"; | ||
| import Category from "./Category"; | ||
| import { useDeleteQuesitonList } from "@hooks/api/useDeleteQuestionList"; | ||
| import Modal from "@components/common/Modal"; | ||
| import useModal from "@/hooks/useModal"; | ||
|
|
||
| interface ItemProps { | ||
| questionListId: number; | ||
| type: "my" | "saved"; | ||
| page: number; | ||
| } | ||
|
|
||
| const ITEM_PER_PAGE = 8; | ||
|
|
||
| const QuestionItem = ({ questionListId, type, page }: ItemProps) => { | ||
| const navigate = useNavigate(); | ||
| const modal = useModal(); | ||
| const deleteQuestions = useDeleteQuesitonList({ page, limit: ITEM_PER_PAGE }); | ||
|
|
||
| const openDeleteModal = (e: React.MouseEvent) => { | ||
| e.stopPropagation(); | ||
| modal.openModal(); | ||
| } | ||
|
|
||
| const deleteHandler = () => { | ||
| deleteQuestions(questionListId); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <Modal | ||
| modal={modal} | ||
| title="해당 질문지를 삭제하실건까요?" | ||
| subtitle="삭제하면 복구할 수 없어요!" | ||
| leftButton="취소하기" | ||
| rightButton="삭제하기" | ||
| type="red" | ||
| onLeftClick={() => { }} | ||
| onRightClick={deleteHandler} | ||
| /> | ||
| <div | ||
| className="flex items-center w-full h-32 p-4 border-custom-s border-gray-200 rounded-custom-m cursor-pointer" | ||
| onClick={() => { | ||
| navigate(`/questions/${questionListId}`); | ||
| }} | ||
| > | ||
| <div className="relative flex flex-col w-full gap-1"> | ||
| <div className="relative"> | ||
| <div className="flex flex-row gap-1 mb-2"> | ||
| <Category text="네트워크" /> | ||
| <Category text="운영체제" /> | ||
| </div> | ||
| <div className="px-1"> | ||
| <p className="text-gray-black text-semibold-m"> | ||
| 프론트엔드프론트엔드프론트엔드프론트엔드 | ||
| </p> | ||
| <div className="absolute top-0 right-0 text-gray-400 flex flex-row gap-1"> | ||
| {type === "my" ? ( | ||
| <> | ||
| <button | ||
| className="w-5 h-5" | ||
| onClick={() => navigate("/")} // TODO: 질문지 수정 페이지로 이동 | ||
| > | ||
| <MdEdit className="w-5 h-5 mt-1" /> | ||
| </button> | ||
| <button className="w-5 h-5" onClick={openDeleteModal}> | ||
| <RiDeleteBin6Fill className="w-5 h-5 mt-1" /> | ||
| </button> | ||
| </> | ||
| ) : ( | ||
| <button className="w-5 h-5"> | ||
| <FaBookmark className="w-5 h-5 mt-1" /> | ||
| </button> | ||
| )} | ||
| </div> | ||
| <span className="text-gray-600 text-medium-m"> | ||
| 작성자 눈드뮴눈드뮴눈드뮴눈드뮴눈드뮴눈드뮴눈드 | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default QuestionItem; |
This file contains hidden or 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,25 @@ | ||
| import QuestionItem from "./QuestionItem"; | ||
|
|
||
| interface ListProps { | ||
| tab: "myList" | "savedList"; | ||
| page: number; | ||
| } | ||
|
|
||
| const QuestionList = ({ tab, page }: ListProps) => { | ||
| return ( | ||
| <div className="my-4 grid grid-cols-2 gap-3"> | ||
| {tab === "myList" ? ( | ||
| <> | ||
| <QuestionItem questionListId={1} type="my" page={page} /> | ||
| <QuestionItem questionListId={2} type="my" page={page} /> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <QuestionItem questionListId={3} type="saved" page={page} /> | ||
| </> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default QuestionList; |
23 changes: 0 additions & 23 deletions
23
frontend/src/components/mypage/QuestionSection/QuestionList/QuestionItem/index.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
모달 개선과 마이페이지 바뀐 UI도 좋은 것 같습니다!