-
Notifications
You must be signed in to change notification settings - Fork 114
[김태진] week20 #1068
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
Open
kimtaejin3
wants to merge
14
commits into
codeit-bootcamp-frontend:part3-김태진
Choose a base branch
from
kimtaejin3:part3-김태진
base: part3-김태진
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "part3-\uAE40\uD0DC\uC9C4"
Open
[김태진] week20 #1068
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e6f64b3
Feat: add reactQuery to share page
kimtaejin3 f892a1f
Feat: add reactQuery to folder page
kimtaejin3 073626c
Feat: add reactQuery to signin page
kimtaejin3 a1bd407
Feat: add reactQuery to signup page
kimtaejin3 c5fdce2
Fix: chage positions of success and error handle logic
kimtaejin3 0f67c73
Feat: implement to add folder
kimtaejin3 3c4869a
Feat: implement to modify folder
kimtaejin3 d4f6e41
Feat: implement to delete folder
kimtaejin3 ce23f45
Feat: implement to add link
kimtaejin3 f83fcfd
Fix: change get links url path
kimtaejin3 5d0f1ef
Fix: change folderId to selectedId
kimtaejin3 d9f095d
Feat: implement to delete link
kimtaejin3 a9abd04
Chore: resolve build error
kimtaejin3 13c5086
Chore: remove useless console.log
kimtaejin3 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
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 |
---|---|---|
|
@@ -2,8 +2,7 @@ import { getCookie } from "@/utils/cookie"; | |
import axios from "axios"; | ||
|
||
export const instance = axios.create({ | ||
baseURL: "https://bootcamp-api.codeit.kr/api", | ||
timeout: 1000, | ||
baseURL: " https://bootcamp-api.codeit.kr/api/linkbrary/v1", | ||
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. 👍 |
||
}); | ||
|
||
instance.interceptors.request.use( | ||
|
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 @@ | ||
import { instance } from "./axios"; | ||
|
||
export async function addFolder(name: string) { | ||
return instance.post("/folders", { name }); | ||
} | ||
|
||
export async function modifyFolder(id: string, name: string) { | ||
return instance.put(`/folders/${id}`, { name }); | ||
} | ||
|
||
export async function deleteFolder(id: string) { | ||
return instance.delete(`/folders/${id}`); | ||
} |
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,9 @@ | ||
import { instance } from "./axios"; | ||
|
||
export async function addLink(url: string, folderId: number) { | ||
return instance.post("/links", { url, folderId }); | ||
} | ||
|
||
export async function deleteLink(linkId: number) { | ||
return instance.delete(`/links/${linkId}`); | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { User } from "@/types"; | ||
import { instance } from "./axios"; | ||
|
||
export async function getUser() { | ||
export async function getUser(): Promise<User[]> { | ||
return (await instance.get("/users")).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 |
---|---|---|
@@ -1,11 +1,43 @@ | ||
import { | ||
QueryClient, | ||
useMutation, | ||
useQueryClient, | ||
} from "@tanstack/react-query"; | ||
import styles from "./styles.module.css"; | ||
import { addFolder } from "@/api/folder"; | ||
import { useState } from "react"; | ||
|
||
export const AddModal = () => { | ||
const [name, setName] = useState(""); | ||
const queryClient = useQueryClient(); | ||
|
||
const mutation = useMutation({ | ||
mutationFn: (name: string) => addFolder(name), | ||
onError: () => { | ||
alert("폴더를 추가하는데 실패하였습니다."); | ||
}, | ||
onSuccess: () => { | ||
alert("폴더를 성공적으로 추가했습니다."); | ||
queryClient.invalidateQueries({ queryKey: ["folders"] }); | ||
}, | ||
}); | ||
|
||
const handleAddFolder = () => { | ||
mutation.mutate(name); | ||
}; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<h2 className={styles.title}>폴더 추가</h2> | ||
<input className={styles.input} type="text" placeholder="내용 입력" /> | ||
<button className={styles.btn}>변경하기</button> | ||
<input | ||
className={styles.input} | ||
onChange={(e) => setName(e.target.value)} | ||
type="text" | ||
placeholder="내용 입력" | ||
/> | ||
<button className={styles.btn} onClick={handleAddFolder}> | ||
추가하기 | ||
</button> | ||
</div> | ||
); | ||
}; |
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,37 @@ | ||
import { deleteFolder } from "@/api/folder"; | ||
import styles from "./styles.module.css"; | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { deleteLink } from "@/api/links"; | ||
|
||
interface Props { | ||
linkId: number; | ||
linkUrl: string; | ||
} | ||
|
||
export const DeleteLinkModal = ({ linkUrl, linkId }: Props) => { | ||
const queryClient = useQueryClient(); | ||
|
||
const mutation = useMutation({ | ||
mutationFn: (linkId: number) => deleteLink(linkId), | ||
onError: () => { | ||
alert("링크를 삭제하는데 실패하였습니다."); | ||
}, | ||
onSuccess: () => { | ||
alert("링크를 성공적으로 삭제했습니다."); | ||
}, | ||
}); | ||
|
||
const handleDeleteLink = () => { | ||
mutation.mutate(linkId); | ||
}; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<h2 className={styles.title}>링크 삭제</h2> | ||
<p className={styles.description}>{linkUrl}</p> | ||
<button className={styles.btn} onClick={handleDeleteLink}> | ||
삭제하기 | ||
</button> | ||
</div> | ||
); | ||
}; |
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,24 @@ | ||
.container { | ||
text-align: center; | ||
} | ||
|
||
.title { | ||
font-weight: bold; | ||
font-size: 1.9rem; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.description { | ||
font-size: 1.4rem; | ||
margin-bottom: 20px; | ||
color: #9fa6b2; | ||
} | ||
|
||
.btn { | ||
width: 100%; | ||
padding: 15px 0; | ||
color: white; | ||
background-color: #ff5b56; | ||
font-size: 1.5rem; | ||
border-radius: 10px; | ||
} |
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 |
---|---|---|
@@ -1,16 +1,38 @@ | ||
import { deleteFolder } from "@/api/folder"; | ||
import styles from "./styles.module.css"; | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
|
||
interface Props { | ||
title: string; | ||
description: string; | ||
folderId: string; | ||
} | ||
|
||
export const DeleteModal = ({ title, description }: Props) => { | ||
export const DeleteModal = ({ folderId, title, description }: Props) => { | ||
const queryClient = useQueryClient(); | ||
|
||
const mutation = useMutation({ | ||
mutationFn: (folderId: string) => deleteFolder(folderId), | ||
onError: () => { | ||
alert("폴더를 삭제하는데 실패하였습니다."); | ||
}, | ||
onSuccess: () => { | ||
alert("폴더를 성공적으로 삭제했습니다."); | ||
queryClient.invalidateQueries({ queryKey: ["folders"] }); | ||
}, | ||
}); | ||
|
||
const handleDeleteFolder = () => { | ||
mutation.mutate(folderId); | ||
}; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<h2 className={styles.title}>{title}</h2> | ||
<p className={styles.description}>{description}</p> | ||
<button className={styles.btn}>삭제하기</button> | ||
<button className={styles.btn} onClick={handleDeleteFolder}> | ||
삭제하기 | ||
</button> | ||
</div> | ||
); | ||
}; |
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
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.
http client로 axios를 사용한다면, 특별한 경우를 제외하고는 통일하시는게 일반적으로 좋습니다