-
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.
Browse files
Browse the repository at this point in the history
[#264] 상세 페이지 QA 및 에러 해결
- Loading branch information
Showing
34 changed files
with
243 additions
and
190 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { Outlet } from "react-router-dom"; | ||
import ScrollToTop from "@components/scrollToTop/ScrollToTop"; | ||
import Toast from "./components/toast/Toast"; | ||
import Toast from "@components/toast/Toast"; | ||
import "./firebase.ts"; | ||
|
||
import { useToastStore } from "./store/store"; | ||
import { AnimatePresence } from "framer-motion"; | ||
import IsLogin from "@components/isLogin/IsLogin"; | ||
|
||
function App() { | ||
const App = () => { | ||
const toastConfig = useToastStore((state) => state.config); | ||
|
||
return ( | ||
<> | ||
<IsLogin> | ||
<ScrollToTop /> | ||
<AnimatePresence>{toastConfig.isShow && <Toast />}</AnimatePresence> | ||
<Outlet /> | ||
</> | ||
</IsLogin> | ||
); | ||
} | ||
}; | ||
|
||
export default App; |
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,11 +1,26 @@ | ||
import { BASE_URL, END_POINTS } from "@constants/api"; | ||
import axios from "axios"; | ||
import { ACCESS_TOKEN, BASE_URL, END_POINTS } from "@constants/api"; | ||
import type { ResponseData } from "@type/responseType"; | ||
import type { RoomData } from "@type/room"; | ||
import axios from "axios"; | ||
import { ResponseError } from "@/components/error/Error"; | ||
|
||
export const getRoom = async ( | ||
productId: string, | ||
isLoggedIn: boolean, | ||
): Promise<RoomData> => { | ||
const headers: { [key: string]: string } = {}; | ||
|
||
if (isLoggedIn) { | ||
const accessToken = localStorage.getItem(ACCESS_TOKEN); | ||
if (!accessToken) throw new ResponseError(401, "토큰이 없습니다."); | ||
|
||
headers["Authorization"] = accessToken; | ||
} | ||
|
||
export const getRoom = async (productId: string): Promise<RoomData> => { | ||
const { data } = await axios.get<ResponseData<RoomData>>( | ||
BASE_URL + END_POINTS.ROOM(productId), | ||
`${BASE_URL}${END_POINTS.ROOM(productId)}`, | ||
{ headers }, | ||
); | ||
|
||
return data.data; | ||
}; |
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,21 @@ | ||
import { ACCESS_TOKEN } from "@/constants/api"; | ||
import useAuthStore from "@/store/authStore"; | ||
import { useLayoutEffect } from "react"; | ||
|
||
interface IsLoginProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const IsLogin = ({ children }: IsLoginProps) => { | ||
const setIsLoggedIn = useAuthStore((state) => state.setIsLoggedIn); | ||
|
||
useLayoutEffect(() => { | ||
if (localStorage.getItem(ACCESS_TOKEN)) { | ||
setIsLoggedIn(true); | ||
} | ||
}, [setIsLoggedIn]); | ||
|
||
return <>{children}</>; | ||
}; | ||
|
||
export default IsLogin; |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
68 changes: 34 additions & 34 deletions
68
src/hooks/useIntersectionObserver.ts → src/hooks/common/useIntersectionObserver.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
interface UseIntersectionObserverProps { | ||
root?: null; | ||
rootMargin?: string; | ||
threshold?: number; | ||
onIntersect: IntersectionObserverCallback; | ||
} | ||
|
||
const UseIntersectionObserver = ({ | ||
root, | ||
rootMargin = "0px", | ||
threshold = 0.5, | ||
onIntersect, | ||
}: UseIntersectionObserverProps) => { | ||
const [target, setTarget] = useState<HTMLElement | null | undefined>(null); | ||
|
||
useEffect(() => { | ||
if (!target) return; | ||
|
||
const observer = new IntersectionObserver(onIntersect, { | ||
root, | ||
rootMargin, | ||
threshold, | ||
}); | ||
observer.observe(target); | ||
|
||
return () => observer.unobserve(target); | ||
}, [onIntersect, root, rootMargin, target, threshold]); | ||
|
||
return { setTarget }; | ||
}; | ||
|
||
export default UseIntersectionObserver; | ||
import { useEffect, useState } from "react"; | ||
|
||
interface UseIntersectionObserverProps { | ||
root?: null; | ||
rootMargin?: string; | ||
threshold?: number; | ||
onIntersect: IntersectionObserverCallback; | ||
} | ||
|
||
const UseIntersectionObserver = ({ | ||
root, | ||
rootMargin = "0px", | ||
threshold = 0.5, | ||
onIntersect, | ||
}: UseIntersectionObserverProps) => { | ||
const [target, setTarget] = useState<HTMLElement | null | undefined>(null); | ||
|
||
useEffect(() => { | ||
if (!target) return; | ||
|
||
const observer = new IntersectionObserver(onIntersect, { | ||
root, | ||
rootMargin, | ||
threshold, | ||
}); | ||
observer.observe(target); | ||
|
||
return () => observer.unobserve(target); | ||
}, [onIntersect, root, rootMargin, target, threshold]); | ||
|
||
return { setTarget }; | ||
}; | ||
|
||
export default UseIntersectionObserver; |
98 changes: 49 additions & 49 deletions
98
src/hooks/useOnClickOutside.ts → src/hooks/common/useOnClickOutside.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
import { useEffect, RefObject } from "react"; | ||
|
||
interface UseOnClickOutsideProps { | ||
ref: RefObject<HTMLElement>; | ||
handler: () => void; | ||
isModalTwoOpen: boolean; | ||
refTwo: RefObject<HTMLElement>; | ||
handlerTwo: () => void; | ||
} | ||
const useOnClickOutside = ({ | ||
ref, | ||
handler, | ||
isModalTwoOpen, | ||
refTwo, | ||
handlerTwo, | ||
}: UseOnClickOutsideProps) => { | ||
useEffect(() => { | ||
const listener = (event: MouseEvent | TouchEvent) => { | ||
if (!ref.current || ref.current.contains(event.target as Node)) { | ||
return; | ||
} | ||
if (!isModalTwoOpen) { | ||
handler(); | ||
} | ||
}; | ||
const listenerTwo = (event: MouseEvent | TouchEvent) => { | ||
if (!refTwo.current || refTwo.current.contains(event.target as Node)) { | ||
return; | ||
} | ||
if (isModalTwoOpen) { | ||
handlerTwo(); | ||
} | ||
}; | ||
document.addEventListener("mousedown", listener); | ||
document.addEventListener("touchstart", listener); | ||
document.addEventListener("mousedown", listenerTwo); | ||
document.addEventListener("touchstart", listenerTwo); | ||
|
||
return () => { | ||
document.removeEventListener("mousedown", listener); | ||
document.removeEventListener("touchstart", listener); | ||
document.removeEventListener("mousedown", listenerTwo); | ||
document.removeEventListener("touchstart", listenerTwo); | ||
}; | ||
// eslint-disable-next-line | ||
}, [ref, handler, refTwo, handlerTwo]); | ||
}; | ||
|
||
export default useOnClickOutside; | ||
import { useEffect, RefObject } from "react"; | ||
|
||
interface UseOnClickOutsideProps { | ||
ref: RefObject<HTMLElement>; | ||
handler: () => void; | ||
isModalTwoOpen: boolean; | ||
refTwo: RefObject<HTMLElement>; | ||
handlerTwo: () => void; | ||
} | ||
const useOnClickOutside = ({ | ||
ref, | ||
handler, | ||
isModalTwoOpen, | ||
refTwo, | ||
handlerTwo, | ||
}: UseOnClickOutsideProps) => { | ||
useEffect(() => { | ||
const listener = (event: MouseEvent | TouchEvent) => { | ||
if (!ref.current || ref.current.contains(event.target as Node)) { | ||
return; | ||
} | ||
if (!isModalTwoOpen) { | ||
handler(); | ||
} | ||
}; | ||
const listenerTwo = (event: MouseEvent | TouchEvent) => { | ||
if (!refTwo.current || refTwo.current.contains(event.target as Node)) { | ||
return; | ||
} | ||
if (isModalTwoOpen) { | ||
handlerTwo(); | ||
} | ||
}; | ||
document.addEventListener("mousedown", listener); | ||
document.addEventListener("touchstart", listener); | ||
document.addEventListener("mousedown", listenerTwo); | ||
document.addEventListener("touchstart", listenerTwo); | ||
|
||
return () => { | ||
document.removeEventListener("mousedown", listener); | ||
document.removeEventListener("touchstart", listener); | ||
document.removeEventListener("mousedown", listenerTwo); | ||
document.removeEventListener("touchstart", listenerTwo); | ||
}; | ||
// eslint-disable-next-line | ||
}, [ref, handler, refTwo, handlerTwo]); | ||
}; | ||
|
||
export default useOnClickOutside; |
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: 1 addition & 1 deletion
2
src/pages/connectYanoljaPage/verificationPage/components/submitButton/SubmitButton.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
2 changes: 1 addition & 1 deletion
2
...onnectYanoljaPage/verificationPage/components/verificationSection/VerificationSection.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
Oops, something went wrong.