Skip to content

Commit

Permalink
유저 불러오기 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
alsendrha committed Jun 2, 2024
1 parent be92976 commit bc26977
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/api/userApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useGetUser = () => {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
}
})
return useQuery({ queryKey: ['user'], queryFn, enabled: false });
return useQuery({ queryKey: ['user'], queryFn });
}

export const useUserEmailCheck = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/payment/confirmation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useRouter } from "next/navigation";
import { useEffect } from "react";

const ConfirmationPage = () => {
const { data, refetch } = useGetUser();
const { data } = useGetUser();
const router = useRouter();
const { paymentUserProducts } = useProductStore();
const totalPrice = paymentUserProducts.reduce(
Expand All @@ -29,7 +29,7 @@ const ConfirmationPage = () => {
router.push('/');
return;
}
refetch();

}, [paymentUserProducts])

return (
Expand Down
3 changes: 1 addition & 2 deletions src/app/payment/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useEffect, useState } from "react";

function PaymentPage() {
const router = useRouter();
const { data, refetch } = useGetUser();
const { data } = useGetUser();
const [isClick, setIsClick] = useState(false);
const { paymentUserProducts } = useProductStore();
const [totalCoins, setTotalCoins] = useState(100000); // 보유한 코인
Expand All @@ -21,7 +21,6 @@ function PaymentPage() {
router.push('/');
return;
}
refetch();
}, [paymentUserProducts])


Expand Down
8 changes: 1 addition & 7 deletions src/components/community/Detail/DetailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type DetailFormProps = {

const DetailForm = ({ paramsId }: DetailFormProps) => {
const [isDetailClicked, setIsDetailClicked] = useState(false);
const { data, refetch: userRefetch } = useGetUser();
const { data } = useGetUser();
const { data: communityItem, isLoading, refetch } = useGetCommunity(paramsId);
const router = useRouter();
const [date, setdate] = useState('');
Expand All @@ -35,12 +35,6 @@ const DetailForm = ({ paramsId }: DetailFormProps) => {
return src;
};

useEffect(() => {
if (!localStorage.getItem('access_token')) return;
userRefetch();
}, [])


useEffect(() => {
setToken(localStorage.getItem('access_token'));
refetch();
Expand Down
3 changes: 1 addition & 2 deletions src/components/community/Insert/InsertForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type InsertFormProps = {

const InsertForm = ({ paramsId }: InsertFormProps) => {
const fileInput = useRef<HTMLInputElement>(null);
const { data, isLoading, refetch: userRefetch } = useGetUser();
const { data, isLoading } = useGetUser();
const { data: communityItem, isLoading: communityLoading, refetch } = useGetCommunity(paramsId.replace('update%3D', ''));
const [file, setFile] = useState<File>();
const [renderImage, setRenderImage] = useState<string>('');
Expand All @@ -40,7 +40,6 @@ const InsertForm = ({ paramsId }: InsertFormProps) => {
router.push('/login');
return;
}
userRefetch();
if (paramsId === 'insert') return;
if (!paramsId || typeof paramsId !== 'string' || !paramsId.startsWith('update%') || paramsId.length !== 19) {
// 유효하지 않은 ID이거나 존재하지 않는 경우 리디렉션
Expand Down
8 changes: 1 addition & 7 deletions src/components/myPage/MyPageProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useRouter } from "next/navigation";
import { useEffect } from "react";
import ProfileButton from "./ProfileButton";
const MyPageProfile = () => {
const { data, isLoading, refetch } = useGetUser();
const { data, isLoading } = useGetUser();
const router = useRouter();
useEffect(() => {
if (!localStorage.getItem('access_token')) {
Expand All @@ -16,12 +16,6 @@ const MyPageProfile = () => {
}
}, [])

useEffect(() => {
if (!localStorage.getItem('access_token')) return;
refetch();
}, [])


return (
<div className="flex items-center justify-between w-full border rounded-xl px-8 py-4 bg-white mb-5">
{
Expand Down
8 changes: 1 addition & 7 deletions src/components/productDetail/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ChatTypeProps = {

const Chat = ({ productId, auctionId, finalPrice, refetch }: ChatTypeProps) => {
const [isChat, setIsChat] = useState('');
const { data, refetch: userRefetch } = useGetUser();
const { data } = useGetUser();
const { mutate: postBidding } = usePostWinner();

const buttonMenu = [
Expand All @@ -26,12 +26,6 @@ const Chat = ({ productId, auctionId, finalPrice, refetch }: ChatTypeProps) => {
const { mutate: userChatRoom } = useChatRoom();
const { messages, isConnected, sendMessage } = useWebSocket();

useEffect(() => {
if (!localStorage.getItem('access_token')) return;
userRefetch();
}, [])


useEffect(() => {
if (isConnected) {
setTimeout(() => {
Expand Down
6 changes: 1 addition & 5 deletions src/components/productDetail/FinalModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const FinalModal = ({ auctionId, itemRefetch }: FinalModalProps) => {
const loader = ({ src }: { src: string }) => {
return src;
};
const { data, refetch } = useGetUser();
const { data } = useGetUser();
const { winner } = useWinnerStore();
const { mutate: activeStatus } = useAuctionPutStatus();
const router = useRouter();
Expand Down Expand Up @@ -62,10 +62,6 @@ const FinalModal = ({ auctionId, itemRefetch }: FinalModalProps) => {
}

useEffect(() => {
if (!localStorage.getItem('access_token')) {
return;
}
refetch();
const random = Math.floor(Math.random() * auctionList?.data.length);
setRandomItem(auctionList?.data[random]);
}, [auctionList])
Expand Down

0 comments on commit bc26977

Please sign in to comment.