Skip to content

Commit

Permalink
refactor: prevRoute를 literal type으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
MinGu-Jeong committed Jan 3, 2024
1 parent c326527 commit 93334f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/page/Auth/FindPassword/CompleteChangePassword/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ReactComponent as Check } from 'assets/svg/auth/check.svg';
import { useNavigate } from 'react-router-dom';
import { useRouteCheck, Route } from 'page/Auth/FindPassword/hooks/useRouteCheck';
import { useRouteCheck } from 'page/Auth/FindPassword/hooks/useRouteCheck';
import styles from './CompleteChangePassword.module.scss';

export default function CompleteChangePassword() {
const navigate = useNavigate();
useRouteCheck(Route.NEXT_STEP, '/new-password');
useRouteCheck('new-password', '/new-password');

return (
<div className={styles.template}>
Expand Down
4 changes: 2 additions & 2 deletions src/page/Auth/FindPassword/NewPassword/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactComponent as KoinLogo } from 'assets/svg/auth/koin-logo.svg';
import { ReactComponent as ShowIcon } from 'assets/svg/auth/show.svg';
import { ReactComponent as BlindIcon } from 'assets/svg/auth/blind.svg';
import { useRouteCheck, Route } from 'page/Auth/FindPassword/hooks/useRouteCheck';
import { useRouteCheck } from 'page/Auth/FindPassword/hooks/useRouteCheck';
import useBooleanState from 'utils/hooks/useBooleanState';
import { useState } from 'react';
import { useNewPassword } from 'query/auth';
Expand All @@ -14,7 +14,7 @@ export default function NewPassword() {
const { value: isBlind, changeValue: changeIsBlind } = useBooleanState(true);
const { email } = useEmailAuthStore();
const submit = useNewPassword();
useRouteCheck(Route.NEXT_STEP, '/find-password');
useRouteCheck('find-password', '/find-password');
const handleSubmit = (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
submit({ email, password });
Expand Down
4 changes: 1 addition & 3 deletions src/page/Auth/FindPassword/hooks/useRouteCheck.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useEffect } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';

export enum Route {
NEXT_STEP = 'nextStep',
}
type Route = 'new-password' | 'find-password';

export const useRouteCheck = (prevRoute: Route, entryRoute: string) => {
const location = useLocation();
Expand Down

0 comments on commit 93334f0

Please sign in to comment.