Skip to content

Commit

Permalink
feat: 리다이렉트 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
im-na0 committed Jan 28, 2024
1 parent 3ea162d commit 4e66c67
Show file tree
Hide file tree
Showing 5 changed files with 386 additions and 356 deletions.
25 changes: 25 additions & 0 deletions src/components/redirect/Redirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PATH } from "@/constants/path";
import useAuthStore from "@/store/authStore";
import { useUserInfoStore } from "@/store/store";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";

interface RedirectProps {
children: React.ReactNode;
}

const Redirect = ({ children }: RedirectProps) => {
const isLoggedIn = useAuthStore((state) => state.isLoggedIn);
const userInfo = useUserInfoStore((state) => state.userInfo);
const navigate = useNavigate();

useEffect(() => {
if (!isLoggedIn || !userInfo || userInfo.linkedToYanolja) {
navigate(PATH.ROOT);
}
}, [isLoggedIn, userInfo, navigate]);

return <>{children}</>;
};

export default Redirect;
2 changes: 1 addition & 1 deletion src/hooks/api/useUserInfoQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface AccountQueryProps {

export const useAccountQuery = () => {
const accountQuery = useSuspenseQuery<ProfileData, Error, AccountQueryProps>({
queryKey: ["myProfile"],
queryKey: ["userInfo", "account"],
queryFn: async () => await fetchUserInfo(),
refetchOnWindowFocus: false,
refetchOnReconnect: false,
Expand Down
7 changes: 6 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { hydrate } from "react-dom";
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 0,
retry: 1,
throwOnError: true,
},
mutations: {
retry: 1,
throwOnError: true,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TermsAgreementSection from "@pages/connectYanoljaPage/verificationPage/co
import VerificationSection from "@pages/connectYanoljaPage/verificationPage/components/verificationSection/VerificationSection";
import { FormProvider, useForm } from "react-hook-form";

import * as S from "./VerificationPage.style.ts";
import * as S from "./VerificationPage.style";

const VerificationPage = () => {
const methods = useForm({
Expand Down
Loading

0 comments on commit 4e66c67

Please sign in to comment.