Skip to content

Commit

Permalink
Add useManipulate to AppContainer.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rmdnps10 committed Jul 21, 2024
1 parent a4fcaae commit b38987a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/components/Common/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styled from 'styled-components';
import { Grey6, White } from 'styles/color';
import { scrollLockState } from 'utils/atom';
import { APP_WIDTH } from 'styles/AppStyle';
import useManipulateServerDown from 'hooks/useManipulateSeverDown';

//
//
Expand Down Expand Up @@ -45,6 +46,11 @@ export const AppContainer = ({ children }: AppContainerProps) => {
isPaymentDetailPage ||
isProfilePage;

//
//
//
// Redirect to inspection page when service is shut down
useManipulateServerDown();
//
//
//
Expand Down
13 changes: 8 additions & 5 deletions src/hooks/useManipulateSeverDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { useQuery } from '@tanstack/react-query';
import { getIsServerShutdown } from 'api/get';
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';

//
//
//
const ADMIN_SERVER_QUERY_KEY = 'getIsServerShutdown';

export type GetIsServerShutdownResponse = boolean;

type GetIsServerShutdownResponse = boolean;
//
//
//
function useManipulateServerDown() {
const navigate = useNavigate();

Expand All @@ -16,7 +19,7 @@ function useManipulateServerDown() {
});

useEffect(() => {
if (!isShutDown) {
if (isShutDown) {
navigate('/service-unavailable');
}
}, [isShutDown, navigate]);
Expand Down

0 comments on commit b38987a

Please sign in to comment.