Skip to content

Commit

Permalink
๐Ÿšš Rename: ํ”„๋กœํ•„ ํผ ์ปดํฌ๋„ŒํŠธํ™”์— ๋”ฐ๋ฅธ ๊ฒฝ๋กœ ๋ณ€๊ฒฝ
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-paik committed Nov 22, 2023
1 parent b9e1d1e commit 17446a6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 106 deletions.
71 changes: 0 additions & 71 deletions src/pages/ProfilePage/ProfileEditPage/ProfileEditPageStyle.jsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,29 @@ import React, { useState, useEffect, lazy, Suspense } from 'react';
import styled from 'styled-components';
import { useParams, useNavigate } from 'react-router-dom';
import { useRecoilValue, useRecoilCallback, useSetRecoilState } from 'recoil';
import { useQuery } from 'react-query';
import Header from '../../components/Header/TopBasicNavHeader';
import Footer from '../../components/Footer/TabMenu';
import Loading from '../../components/common/Loading/Loading';
import Modal from '../../components/common/Modal/PostModal';
import IconPostModal from '../../components/common/Modal/IconPostModal';
import { useQuery, useInfiniteQuery } from 'react-query';
import Header from '../../../components/Header/TopBasicNavHeader';
import Footer from '../../../components/Footer/TabMenu';
import Loading from '../../../components/common/Loading/Loading';
import Modal from '../../../components/common/Modal/PostModal';
import IconPostModal from '../../../components/common/Modal/IconPostModal';
import {
deletePostData,
resetProfile,
logOut,
reportUserPost,
sharePost,
} from '../../components/common/Modal/ModalFunction';
import PostPage from '../PostPage/PostPage';
import { getUserProfile } from '../../api/profile';
import { getMyPost } from '../../api/post';
import { loginAtom } from '../../atoms/LoginAtom';
import { userInfoAtom } from '../../atoms/UserAtom';
import ProfileCard from '../../components/Profile/ProfileCard/ProfileCard';
} from '../../../components/common/Modal/ModalFunction';
import PostPage from '../../PostPage/PostPage';
import { getUserProfile } from '../../../api/profile';
import { getMyPost } from '../../../api/post';
import { loginAtom } from '../../../atoms/LoginAtom';
import { userInfoAtom } from '../../../atoms/UserAtom';
import ProfileCard from '../../../components/Profile/ProfileCard/ProfileCard';

const ProfilePage = () => {

const { accountname: accountName } = useParams();
const navigate = useNavigate();
const [posts, setPosts] = useState([]);
const [isModalOpen, setIsModalOpen] = useState(false);
const userToken = localStorage.getItem('token');
const userInfo = useRecoilValue(userInfoAtom);
Expand All @@ -36,26 +34,23 @@ const ProfilePage = () => {
const [modalText, setModalText] = useState([]);
const [modalFunc, setModalFunc] = useState([]);


useEffect(() => {
setIsDelete(false);
setIsModalOpen(false);
}, [isDelete]);

const { data: userProfile, isLoading } = useQuery([
'getUserProfile', accountName],
() => getUserProfile(accountName));

const { data: userProfile, isLoading } = useQuery(['getUserProfile', accountName], () => getUserProfile(accountName));

// ๋‚ด ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก
const getPost = async () => {
try {
const postData = await getMyPost(accountName, 10, 0);
setPosts(postData.post);
} catch (error) {
console.error('Error fetching user posts:', error);
// Infinite scroll
const { data: postData, fetchNextPage, hasNextPage, isFetchingNextPage } = useInfiniteQuery(
['getMyPost', accountName],
({ pageParam = 0 }) => getMyPost(accountName, 5, pageParam),
{
getNextPageParam: (lastPage, pages) => lastPage.hasMore ? pages.length : undefined,
}
};
);

const posts = postData ? postData.pages.flatMap(page => page.post) : [];

const handleResetState = useRecoilCallback(({ reset }) => () => {
reset(userInfoAtom);
Expand Down Expand Up @@ -104,13 +99,12 @@ const ProfilePage = () => {
}
};


if (isLoading) {
return (
<>
<h1>isLoading</h1>
<h1>isLoading</h1>
</>
)
);
}

return (
Expand All @@ -130,6 +124,11 @@ const ProfilePage = () => {
posts.map((post, index) => (
<PostPage key={index} data={post} showModal={onShowModal} />
))}
{hasNextPage && (
<button onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
{isFetchingNextPage ? 'Loading more...' : 'Load More'}
</button>
)}
</Section>
{isModalOpen && (
<Modal setIsModalOpen={setIsModalOpen}>
Expand All @@ -150,9 +149,8 @@ const ProfilePage = () => {

export default ProfilePage;

const Container = styled.div`
`
const Container = styled.div``;

const Section = styled.section`
margin-bottom: 6rem;
`
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from 'styled-components';
import { useNavigate, useLocation } from 'react-router-dom';
import { useMutation } from 'react-query';
import { postAccountnameDuplicate, postUserSignup } from '../../../api/auth';
import ProfileForm from '../../../components/Profile/ProfileForm';
import ProfileForm from '../../../components/Profile/ProfileForm/ProfileForm';

const ProfileSettingPage = () => {
const [isError, setIsError] = useState(false);
Expand Down

0 comments on commit 17446a6

Please sign in to comment.