Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy: Release #283

Merged
merged 5 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading