-
Notifications
You must be signed in to change notification settings - Fork 26
[정상인] sprint7 #117
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
The head ref may contain hidden characters: "React-\uC815\uC0C1\uC778-sprint7"
[정상인] sprint7 #117
Changes from all commits
f4953f1
43b8527
e49c41c
0450059
b91d9b9
ff63e22
df24567
50b004a
76c1f90
7d76bd0
8708240
e2c5a09
cafb4fa
2efefe6
1a55ab5
2727a11
2163fe8
b623604
edd0640
0cdd8b2
82c6a30
645dfd3
2eebc08
ce74b65
c5a838b
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,19 +1,15 @@ | ||
| import React, { useState } from "react"; | ||
| const DropDown = ({ children, className }) => { | ||
| return <div className={`dropdown ${className}`}>{children}</div>; | ||
| }; | ||
|
|
||
| const DropDown = ({ children }) => { | ||
| return <div className="dropdown">{children}</div>; | ||
| DropDown.header = ({ children }) => { | ||
| return <div>{children}</div>; | ||
| }; | ||
|
|
||
| DropDown.header = ({ children, onClick }) => { | ||
| DropDown.menus = ({ children, isOpen, className }) => { | ||
| return ( | ||
| <button onClick={onClick} className="button dropdown-btn"> | ||
| {children} | ||
| </button> | ||
| isOpen && <ul className={`dropdown-menus ${className}`}>{children}</ul> | ||
| ); | ||
| }; | ||
|
|
||
| DropDown.menus = ({ children, isOpen }) => { | ||
| return isOpen && <ul className="dropdown-menus">{children}</ul>; | ||
| }; | ||
|
|
||
| export default DropDown; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import React from "react"; | ||
| import "./ProductCard.style.css"; | ||
|
|
||
| const ProductCard = ({ product, category }) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||||||||||||||||||||||
| import { useEffect } from "react"; | ||||||||||||||||||||||||||||||||||
| import { useLocation } from "react-router"; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const ScrollToTop = () => { | ||||||||||||||||||||||||||||||||||
| const { pathname } = useLocation(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||
| window.scrollTo(0, 0); | ||||||||||||||||||||||||||||||||||
| }, [pathname]); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+12
Collaborator
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
컴포넌트는 보통 실체하는 ui가 있을 때 사용되는건데 이건 컴포넌트로 보긴 어렵겠네요. |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export default ScrollToTop; | ||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| display: inline-flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| white-space: nowrap; | ||
| gap: 10px; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| .tag-area { | ||
| display: flex; | ||
| gap: 16px; | ||
| flex-wrap: wrap; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,10 @@ const TagList = ({ tags, onDelete }) => { | |||||
| <ul className="tag-area"> | ||||||
| {tags?.map((tag, index) => ( | ||||||
| <li key={tag}> | ||||||
| <TagBadge name={tag} onDelete={() => onDelete(index)} /> | ||||||
| <TagBadge | ||||||
| name={tag} | ||||||
| onDelete={onDelete ? () => onDelete(index) : undefined} | ||||||
|
Collaborator
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
어떻게 이게 가능할까요?
|
||||||
| /> | ||||||
| </li> | ||||||
| ))} | ||||||
| </ul> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| .userInfo-badge { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 16px; | ||
| } | ||
|
|
||
| .userInfo-badge-name-date { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 2px; | ||
| font-size: 14px; | ||
| } | ||
|
|
||
| .userInfo-badge-name { | ||
| color: var(--secondary600); | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| .userInfo-badge-createdAt { | ||
| color: var(--gray400); | ||
| font-weight: 400; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import "./Userinfo.style.css"; | ||
|
|
||
| const UserInfo = ({ image, name, date }) => { | ||
| const imageSrc = image || "/images/nav-panda.svg"; | ||
| return ( | ||
| <div className="userInfo-badge"> | ||
| <img src={imageSrc} alt="이미지" /> | ||
| <div className="userInfo-badge-name-date"> | ||
| <span className="userInfo-badge-name">{name}</span> | ||
| <span className="userInfo-badge-date">{date}</span> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default UserInfo; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export const QUESTION_PLACEHOLDER = | ||
| "개인정보를 공유 및 요청하거나, 명예 훼손, 무단 광고, 불법 정보 유포시 모니터링 후 삭제될 수 있으며, 이에 대한 민형사상 책임은 게시자에게 있습니다."; | ||
|
Comment on lines
+1
to
+2
Collaborator
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. 해당 상수는 파일을 분리함으로써 어떤 이득을 취할 수 있을까요? 🤔사용되는 컴포넌트와 멀리 떨어져 있기에 개발 경험이 떨어질 수 있으며 유지보수를 위하기에는 재사용될 가능성이 낮아보일 것으로 사료되는군요 ..! |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
| import instance from "../api/axiosInstance"; | ||
|
|
||
| const deleteProductComment = ({ commentId }) => { | ||
| return instance.delete(`comments/${commentId}`); | ||
| }; | ||
|
|
||
| export const useDeleteProductCommentQuery = () => { | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| return useMutation({ | ||
| mutationFn: deleteProductComment, | ||
| onSuccess: () => { | ||
| queryClient.invalidateQueries(["getProductComments"]); | ||
| }, | ||
| onError: (error) => { | ||
| console.log(error); | ||
| }, | ||
| }); | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||
| import { useQuery } from "@tanstack/react-query"; | ||||||
| import instance from "../api/axiosInstance"; | ||||||
|
|
||||||
| const getProductComments = ({ productId, limit, cursor }) => { | ||||||
| return instance.get(`products/${productId}/comments`, { | ||||||
| params: { limit, cursor }, | ||||||
| }); | ||||||
| }; | ||||||
|
|
||||||
| export const useGetProductCommentsQuery = ({ productId, limit, cursor }) => { | ||||||
| return useQuery({ | ||||||
| queryKey: ["getProductComments", productId, limit], | ||||||
|
Collaborator
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. 그런데,
|
||||||
| queryKey: ["getProductComments", productId, limit], | |
| queryKey: ["getProductComments", productId, limit, cursor], |
두 번째 커서, 세 번째 커서, 각기 다른 결과값을 가져올 것으로 보여서요 !
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.
크으.. 기초 프로젝트 때 익히신 react-query를 사용해보셨군요 ! 😊
배우신 것을 바로 응용해보시는 상인님의 학습 열정 리스펙합니다 👍👍
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import instance from "../api/axiosInstance"; | ||
|
|
||
| const getProductDetail = ({ productId }) => { | ||
| return instance.get(`products/${productId}`); | ||
| }; | ||
|
|
||
| export const useGetProductDetailQuery = ({ productId }) => { | ||
| return useQuery({ | ||
| queryKey: ["getProductDetail", productId], | ||
| queryFn: () => getProductDetail({ productId }), | ||
| staleTime: 300000, | ||
| select: (response) => response.data, | ||
| }); | ||
| }; |
This file was deleted.
This file was deleted.
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.
크으.. 상인님 코드를 볼 때마다 느끼는거지만 유지보수에 신경을 많이 쓰시는 것 같아요.
그냥
Dorpdownchildren에<div>로처리하셨을 수도 있었을텐데, 드롭다운이 공통적으로 변경되는 것도 고려하여 이렇게 설계하신게 느껴집니다.. 👍