Skip to content

Commit

Permalink
Merge pull request #283 from UPbrella/release-dev
Browse files Browse the repository at this point in the history
Deploy: Release
  • Loading branch information
ShinChanU authored Dec 17, 2023
2 parents 7ea72f9 + f1be0e6 commit 04ca350
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/pages/rent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const RentPage = () => {
<div>
<ErrorComponent
error="죄송합니다. 페이지를 찾을 수 없어요:("
subError="존재하지 않는 우산 고유 번호입니다."
subError="[ERROR] 해당 우산은 대여 불가능한 우산입니다."
/>
</div>
);
Expand Down
21 changes: 9 additions & 12 deletions src/utils/PrivateRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { loginState, redirectUrl } from "@/recoil";
import React, { useLayoutEffect } from "react";
import { useGetUserStatus } from "@/hooks/queries/userQueries";
import { redirectUrl } from "@/recoil";
import React from "react";
import { Navigate, Outlet, useLocation } from "react-router-dom";
import { useRecoilValue, useSetRecoilState } from "recoil";
import { useSetRecoilState } from "recoil";

const PrivateRoutes: React.FC = () => {
const authState = useRecoilValue(loginState);
const { pathname, search } = useLocation();
const path = pathname + search;
const { isLoading, isError } = useGetUserStatus();

const path = pathname + search;
const setRedirectUrl = useSetRecoilState(redirectUrl);

useLayoutEffect(() => {
if (!authState) {
setRedirectUrl(path);
}
}, [authState, path, setRedirectUrl]);

if (!authState) {
if (isLoading) return <></>;
if (isError) {
setRedirectUrl(path);
return <Navigate to="/login" replace={true} />;
}

Expand Down

0 comments on commit 04ca350

Please sign in to comment.