-
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.
Merge pull request #85 from Mogazoa-team20/feat/myPage
[#35] 마이페이지 유저 상호작용 데이터 무한스크롤 추가
- Loading branch information
Showing
34 changed files
with
331 additions
and
199 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
9 changes: 5 additions & 4 deletions
9
src/app/(auth)/_components/OauthSignInButton/OauthSignInButton.module.scss
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,13 @@ | ||
@import "@/styles/_index"; | ||
|
||
.container { | ||
width: 56px; | ||
height: 56px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
@include rounded-full; | ||
justify-content: center; | ||
width: 56px; | ||
height: 56px; | ||
background-color: transparent; | ||
border: 1px solid $gray-300; | ||
|
||
@include rounded-full; | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 11 additions & 11 deletions
22
src/app/(userpage)/types.tsx → src/app/(userpage)/types.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
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.
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.
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
34 changes: 34 additions & 0 deletions
34
src/app/(userpage)/user/[userId]/components/MyProfileButton/MyProfileButton.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { useState } from "react"; | ||
import Button from "@/components/Button/Button"; | ||
import Modal from "@/components/Modal/Modal"; | ||
import cn from "@/utils/classNames"; | ||
import styles from "./MyProfileButton.module.scss"; | ||
|
||
export default function MyProfileButton() { | ||
const [isModal, setIsModal] = useState(false); | ||
const handleClose = () => setIsModal(false); | ||
const handleOpen = () => setIsModal(true); | ||
|
||
return ( | ||
<div className={cn(styles.container)}> | ||
{isModal && ( | ||
<Modal onClose={handleClose}> | ||
<div className={styles.profileEdit}>모달 테스트</div> | ||
</Modal> | ||
)} | ||
<Button | ||
styleType='primary' | ||
onClick={handleOpen} | ||
className={styles.profile} | ||
> | ||
프로필 수정 | ||
</Button> | ||
<Button | ||
styleType='tertiary' | ||
className={styles.profile} | ||
> | ||
로그아웃 | ||
</Button> | ||
</div> | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
115 changes: 115 additions & 0 deletions
115
src/app/(userpage)/user/[userId]/components/UserActivityList/UserActivityList.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
"use client"; | ||
|
||
import { useInfiniteQuery } from "@tanstack/react-query"; | ||
import { useRouter } from "next/navigation"; | ||
import { useSession } from "next-auth/react"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { useInView } from "react-intersection-observer"; | ||
import { Dropdown } from "@/components/Dropdown"; | ||
import { ORDER, DROPDOWN } from "@/components/Dropdown/constants"; | ||
import useWindowSize from "@/hooks/useWindowSize"; | ||
import { ProductType, ProductsResponseType } from "@/types/global"; | ||
import cn from "@/utils/classNames"; | ||
import HttpClient from "@/utils/httpClient"; | ||
import styles from "./UserActivityList.module.scss"; | ||
// eslint-disable-next-line no-restricted-imports | ||
import TabButton from "../TabButton/TabButton"; | ||
// eslint-disable-next-line no-restricted-imports | ||
import UserProductList from "../UserProductList/UserProductList"; | ||
|
||
export default function UserActivityList() { | ||
const router = useRouter(); | ||
const [selectedButton, setSelectedButton] = useState<string>("reviewed"); | ||
const { data: session } = useSession(); | ||
const { width } = useWindowSize(); | ||
const { control, watch } = useForm({ mode: "onBlur" }); | ||
|
||
const { ref, inView } = useInView({ | ||
threshold: 0.5, | ||
}); | ||
|
||
const httpClient = new HttpClient(process.env.NEXT_PUBLIC_BASE_URL!); | ||
const userId = session?.user.id; | ||
const ACCESS_TOKEN = session?.accessToken ?? ""; | ||
|
||
const querySelectButton = (value: string) => { | ||
const params = new URLSearchParams(); | ||
params.set("order", value); | ||
|
||
return params.toString(); | ||
}; | ||
|
||
const { | ||
data: userProductData, | ||
fetchNextPage, | ||
hasNextPage, | ||
} = useInfiniteQuery({ | ||
queryKey: ["userProductData", selectedButton], | ||
queryFn: async ({ pageParam }) => { | ||
const res = await httpClient.get<ProductsResponseType>( | ||
`users/${userId}/${selectedButton}-products?cursor=${pageParam}`, | ||
{ | ||
headers: { Authorization: ACCESS_TOKEN }, | ||
cache: "no-cache", | ||
}, | ||
); | ||
return res; | ||
}, | ||
select: (data): ProductType[] => data.pages.map((page) => page.list).flat(), | ||
initialPageParam: 0, | ||
getNextPageParam: (lastPage) => lastPage.nextCursor ?? undefined, | ||
}); | ||
|
||
const selectTab = ORDER.PROFILE.filter((i) => i.value === selectedButton) ?? "reviewed"; | ||
|
||
useEffect(() => { | ||
if (width <= 1023 && watch("select") === "") { | ||
setSelectedButton("reviewed"); | ||
} | ||
if (width <= 1023 && watch("select") !== "") { | ||
setSelectedButton(watch("select")); | ||
} | ||
|
||
router.push(`${userId}/?${querySelectButton(selectedButton)}`); | ||
}, [selectedButton, watch("select")]); | ||
|
||
useEffect(() => { | ||
if (inView && hasNextPage) { | ||
fetchNextPage(); | ||
} | ||
}, [inView, fetchNextPage, hasNextPage]); | ||
|
||
const onSelectButtonHandler = (value: string) => { | ||
setSelectedButton(value); | ||
}; | ||
|
||
return ( | ||
<div className={cn(styles.container)}> | ||
{width > 1023 ? ( | ||
<TabButton | ||
onSelectButton={onSelectButtonHandler} | ||
button={selectedButton} | ||
/> | ||
) : ( | ||
<div> | ||
<Dropdown | ||
items={ORDER.PROFILE} | ||
control={control} | ||
name='select' | ||
variant={DROPDOWN.ORDER} | ||
placeholder={ | ||
ORDER.PROFILE[0].option !== selectTab[0].option ? selectTab[0].option : ORDER.PROFILE[0].option | ||
} | ||
/> | ||
</div> | ||
)} | ||
{userProductData && ( | ||
<UserProductList | ||
list={userProductData} | ||
lastRef={ref} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.