Skip to content

Commit

Permalink
refactor: useLogin -> useToken 으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
guridaek committed Aug 3, 2023
1 parent 624318a commit b42a979
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { styled } from 'styled-components';
import { Outlet } from 'react-router-dom';
import { useLogin } from './hooks/useLogin';
import { useToken } from './hooks/useToken';

const App = () => {
const { validateToken } = useLogin();
const { validateToken } = useToken();

validateToken();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface LoginToken {
expirationDate: Date;
}

export const useLogin = () => {
export const useToken = () => {
const getToken = (): LoginToken | null => {
try {
const item = localStorage.getItem(ACCESS_TOKEN_LOCAL_STORAGE_KEY);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { usePageRouter } from '@/hooks/usePageRouter';
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import LogoImage from '@/assets/logo-image.svg';
import { useLogin } from '@/hooks/useLogin';
import { useToken } from '@/hooks/useToken';

const Header = () => {
const { goToMainPage, goToLoginPage } = usePageRouter();
const { getToken, removeToken } = useLogin();
const { getToken, removeToken } = useToken();
const [isLogin, setIsLogin] = useState(false);

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/GithubCallbackPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ACCESS_TOKEN_LOCAL_STORAGE_KEY, BATON_BASE_URL } from '@/constants';
import { useLogin } from '@/hooks/useLogin';
import { useToken } from '@/hooks/useToken';
import { usePageRouter } from '@/hooks/usePageRouter';
import React, { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
Expand All @@ -8,7 +8,7 @@ function GithubCallbackPage() {
const location = useLocation();

const { goToMainPage, goToLoginPage } = usePageRouter();
const { saveToken } = useLogin();
const { saveToken } = useToken();
const getToken = async (code: string) => {
if (localStorage.getItem(ACCESS_TOKEN_LOCAL_STORAGE_KEY) === null) {
try {
Expand Down

0 comments on commit b42a979

Please sign in to comment.