diff --git a/src/apis/boardContents.ts b/src/apis/boardContents.ts new file mode 100644 index 00000000..b79b7708 --- /dev/null +++ b/src/apis/boardContents.ts @@ -0,0 +1,34 @@ +import authAPI from '@apis/authAPI'; +import { Content } from '@pages/contents/[channelLink]/[boardId]'; + +export const fetchBoardContents = async (channelLink: string, boardId: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/channel/${channelLink}/${boardId}`, + }); + + return res; +}; + +export const updateBoardContents = async ( + channelLink: string, + boardId: string, + updatedContent: Content, +) => { + const res = await authAPI({ + method: 'post', + url: `/api/channel/${channelLink}/${boardId}`, + data: { + title: updatedContent.title, + content: updatedContent.content, + }, + }); + + return res; +}; + +export const deleteBoardContents = async (channelLink: string, boardId: string) => { + const res = await authAPI({ method: 'delete', url: `/api/channel/${channelLink}/${boardId}` }); + + return res; +}; diff --git a/src/apis/boards.ts b/src/apis/boards.ts new file mode 100644 index 00000000..de1c887a --- /dev/null +++ b/src/apis/boards.ts @@ -0,0 +1,59 @@ +import authAPI from '@apis/authAPI'; +import { NEWBOARD } from '@constants/MakeBoard'; +import { Channels } from '@type/board'; +import { MainPageNoticeData } from '@type/mainPage'; + +interface NewBoard { + boardId: number; + boardTitle: string; + boardIndex: number; +} + +interface BoardsInfo { + myMatchRound: number; + myMatchId: number; + channelBoardLoadDtoList: Channels[]; +} + +export const fetchGamePatchNote = async (board: string) => { + const res = await authAPI>({ + method: 'get', + url: `/api/notice/${board}`, + }); + + return res; +}; + +export const fetchBoardLists = async (channelLink: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/channel/${channelLink}/boards`, + }); + + return res.data; +}; + +export const createNewBoard = async (channelLink: string) => { + const res = await authAPI({ + method: 'post', + url: `/api/channel/${channelLink}/new`, + data: { + title: NEWBOARD.DEFAULT_TITLE, + content: NEWBOARD.DEFAULT_CONTENT, + }, + }); + + return res.data; +}; + +export const changeBoardOrder = async (channelLink: string, customedBoards: Channels[]) => { + const res = await authAPI({ + method: 'post', + url: `/api/channel/${channelLink}/order`, + data: { + channelBoardLoadDtoList: customedBoards, + }, + }); + + return res; +}; diff --git a/src/apis/bracketContents.ts b/src/apis/bracketContents.ts new file mode 100644 index 00000000..cc5cd88d --- /dev/null +++ b/src/apis/bracketContents.ts @@ -0,0 +1,11 @@ +import authAPI from '@apis/authAPI'; +import { BracketContents } from '@type/bracket'; + +export const fetchBracketContents = async (channelLink: string, curRound: number) => { + const res = await authAPI({ + method: 'get', + url: `/api/match/${channelLink}/${curRound}`, + }); + + return res.data; +}; diff --git a/src/apis/brackets.ts b/src/apis/brackets.ts new file mode 100644 index 00000000..24b8edb4 --- /dev/null +++ b/src/apis/brackets.ts @@ -0,0 +1,27 @@ +import authAPI from '@apis/authAPI'; +import { BracketHeader } from '@type/bracket'; + +export const fetchStartBracket = async (channelLink: string) => { + const res = await authAPI({ + method: 'put', + url: `/api/channel/${channelLink}?status=1`, + }); + + return res; +}; + +export const fetchAllBracket = async (channelLink: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/match/${channelLink}`, + }); + + return res.data; +}; + +export const assignNextRound = async (channelLink: string, round: number) => { + await authAPI({ + method: 'post', + url: `/api/match/${channelLink}/${round}`, + }); +}; diff --git a/src/apis/channels.ts b/src/apis/channels.ts new file mode 100644 index 00000000..0265716d --- /dev/null +++ b/src/apis/channels.ts @@ -0,0 +1,151 @@ +import { NewGameOption } from './../components/MakeChannel/SelectRule'; +import authAPI from '@apis/authAPI'; +import { Participant } from '@components/Modal/ParticipantLists/ParticipantUser'; +import { BoardInfo } from '@type/board'; +import { ChannelCircleProps } from '@type/channelCircle'; + +export const fetchChannelLists = async () => { + const res = await authAPI({ + method: 'get', + url: '/api/channels', + }); + + return res.data; +}; + +export const fetchChannelInfo = async (channelLink: string) => { + const res = await authAPI({ method: 'get', url: '/api/channel/' + channelLink }); + + return res.data; +}; + +export const createNewChannel = async (newGameOption: NewGameOption) => { + const res = await authAPI({ + method: 'post', + url: '/api/channel', + data: { + gameCategory: newGameOption.gameCategory, + matchFormat: newGameOption.matchFormat, + title: newGameOption.title, + maxPlayer: newGameOption.maxPlayer, + tier: newGameOption.tier, + tierMax: newGameOption.tierMax, + tierMin: newGameOption.tierMin, + playCount: newGameOption.playCount, + playCountMin: newGameOption.playCountMin, + channelImageUrl: newGameOption.channelImageUrl, + }, + }); + + return res; +}; + +export const updateChannelOrder = async (customedChannels: ChannelCircleProps[]) => { + await authAPI({ method: 'post', url: '/api/channels/order', data: customedChannels }); +}; + +export const joinChannel = async (channelLink: string) => { + const res = await authAPI({ + method: 'post', + url: `/api/${channelLink}/participant/observer`, + }); + + return res; +}; + +export const updateChannelInfo = async ( + channelLink: string, + updatedLeagueTitle: string, + updatedMaxPlayer: number, +) => { + const res = await authAPI({ + method: 'post', + url: `/api/channel/${channelLink}`, + data: { + title: updatedLeagueTitle, + maxPlayer: updatedMaxPlayer, + }, + }); + + return res; +}; + +export const fetchParticipantUser = async (channelLink: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/${channelLink}/players`, + }); + + return res; +}; + +export const fetchRequestUser = async (channelLink: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/${channelLink}/player/requests`, + }); + + return res; +}; + +export const fetchOberverUser = async (channelLink: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/${channelLink}/observers`, + }); + + return res; +}; + +export const joinChannelParticipant = async ( + channelLink: string, + gameId: string, + nickname: string, +) => { + const res = await authAPI({ + method: 'post', + url: `/api/${channelLink}/participant`, + data: { + gameId, + nickname, + }, + }); + + return res; +}; + +export const demoteToObserver = async (channelLink: string, participantPK: number) => { + const res = await authAPI({ + method: 'post', + url: `/api/${channelLink}/${participantPK}/observer`, + }); + + return res; +}; + +export const promoteToAdmin = async (channelLink: string, participantPK: number) => { + const res = await authAPI({ + method: 'post', + url: `/api/${channelLink}/${participantPK}/host`, + }); + + return res; +}; + +export const confirmParticipation = async (channelLink: string, requestPK: number) => { + const res = await authAPI({ + method: 'post', + url: `/api/${channelLink}/${requestPK}/player`, + }); + + return res; +}; + +export const rejectParticipation = async (channelLink: string, requestPK: number) => { + const res = await authAPI({ + method: 'post', + url: `/api/${channelLink}/${requestPK}/observer`, + }); + + return res; +}; diff --git a/src/apis/mainContents.ts b/src/apis/mainContents.ts new file mode 100644 index 00000000..d41a3f21 --- /dev/null +++ b/src/apis/mainContents.ts @@ -0,0 +1,33 @@ +import authAPI from '@apis/authAPI'; +import { MainContent } from '@pages/contents/[channelLink]/main'; +import { useRouter } from 'next/router'; + +export const fetchMainContents = async (channelLink: string): Promise => { + const res = await authAPI({ + method: 'get', + url: `/api/channel/${channelLink}/main`, + }); + + if (res.status !== 200) { + return; + } + + return res.data; +}; + +export const updateMainContents = async ( + channelLink: string, + updatedContent: MainContent, +): Promise => { + const res = await authAPI({ + method: 'post', + url: `/api/channel/${channelLink}/main`, + data: updatedContent, + }); + + if (res.status !== 200) { + const router = useRouter(); + router.push('/'); + return; + } +}; diff --git a/src/apis/match.ts b/src/apis/match.ts new file mode 100644 index 00000000..1214a4b7 --- /dev/null +++ b/src/apis/match.ts @@ -0,0 +1,49 @@ +import authAPI from '@apis/authAPI'; +import { GetMatchPlayerScoreInfos } from '@components/RoundCheckIn'; +import { MatchCountList } from '@type/channelConfig'; + +export const fetchInitialMatchCount = async (channelLink: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/match/${channelLink}/count`, + }); + + return res.data; +}; + +export const fetchMatchInfos = async (channelLink: string, matchId: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/channel/${channelLink}/match/${matchId}/player/info`, + }); + + return res; +}; + +export const fetchRoundInfo = async (channelLink: string, curRound: number) => { + const res = await authAPI({ + method: 'get', + url: `/api/match/${channelLink}/${curRound}`, + }); + + return res; +}; + +export const updateRoundMatch = async (channelLink: string, matchSetCountList: number[]) => { + const res = await authAPI({ + method: 'post', + url: `/api/match/${channelLink}/count`, + data: { + matchSetCountList, + }, + }); + + return res; +}; + +export const navigateToCheckInPage = async (channelLink: string, matchId: number) => { + authAPI({ + method: 'post', + url: `/api/match/${channelLink}/${matchId}/call-off`, + }); +}; diff --git a/src/apis/mypage.ts b/src/apis/mypage.ts new file mode 100644 index 00000000..bafd31f8 --- /dev/null +++ b/src/apis/mypage.ts @@ -0,0 +1,39 @@ +import authAPI from '@apis/authAPI'; +import { MyPage } from '@type/mypage'; + +interface ProfileAPI { + nickName: string; + profileImageUrl: string; +} + +export const sendEmailVerification = async (email: string) => { + await authAPI({ + method: 'post', + url: '/api/member/auth/email', + data: { + email, + }, + }); +}; + +export const fetchMy = async () => { + const res = await authAPI({ + method: 'get', + url: '/api/member/mypage', + }); + + return res; +}; + +export const fetchProfile = async () => { + const res = await authAPI({ + method: 'get', + url: '/api/member/profile', + }); + + return res.data; +}; + +export const logout = async () => { + await authAPI({ method: 'post', url: '/api/member/logout' }); +}; diff --git a/src/apis/roundInfo.ts b/src/apis/roundInfo.ts new file mode 100644 index 00000000..6098e75b --- /dev/null +++ b/src/apis/roundInfo.ts @@ -0,0 +1,7 @@ +import authAPI from '@apis/authAPI'; +import { BracketHeader } from '@type/bracket'; + +export const fetchRoundInfo = async (channelLink: string): Promise => { + const res = await authAPI({ method: 'get', url: `/api/match/${channelLink}` }); + return res.data; +}; diff --git a/src/apis/utils.ts b/src/apis/utils.ts new file mode 100644 index 00000000..dd256021 --- /dev/null +++ b/src/apis/utils.ts @@ -0,0 +1,23 @@ +import authAPI from '@apis/authAPI'; + +export const uploadImage = async (formData: FormData) => { + const res = await authAPI<{ imgUrl: string }>({ + method: 'post', + url: `/api/image`, + data: formData, + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + + return res; +}; + +export const fetchUserTier = async (gameId: string, gameTag: string) => { + const res = await authAPI({ + method: 'get', + url: `/api/participant/stat/${gameId}/${gameTag}`, + }); + + return res.data.tier; +}; diff --git a/src/components/Bracket/BracketContents.tsx b/src/components/Bracket/BracketContents.tsx index 2fda3e53..9170ad53 100644 --- a/src/components/Bracket/BracketContents.tsx +++ b/src/components/Bracket/BracketContents.tsx @@ -1,29 +1,20 @@ import { useQuery } from '@tanstack/react-query'; import { useRouter } from 'next/router'; -import authAPI from '@apis/authAPI'; -import { BracketContents } from '@type/bracket'; import styled from '@emotion/styled'; import Image from 'next/image'; +import { fetchBracketContents } from '@apis/bracketContents'; interface Props { curRound: number; } -const fetchBracket = async (channelLink: string, curRound: number) => { - const res = await authAPI({ - method: 'get', - url: `/api/match/${channelLink}/${curRound}`, - }); - - return res.data; -}; - const BracketContents = (props: Props) => { const router = useRouter(); + const { data, isSuccess, isError, isLoading } = useQuery({ queryKey: ['bracketContents', props.curRound, router.query.channelLink], - queryFn: () => fetchBracket(router.query.channelLink as string, props.curRound), + queryFn: () => fetchBracketContents(router.query.channelLink as string, props.curRound), }); const moveToCheckIn = (matchId: number) => { diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 56b75b0c..9e35a761 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -5,8 +5,8 @@ import Icon from '@components/Icon'; import { useContext, useState } from 'react'; import Image from 'next/image'; import ProfileContext from '@contexts/ProfileContext'; -import authAPI from '@apis/authAPI'; import Cookies from 'js-cookie'; +import { logout } from '@apis/mypage'; const Header = () => { const router = useRouter(); @@ -32,7 +32,7 @@ const Header = () => { const handleLogout = async () => { try { - const res = await authAPI({ method: 'post', url: '/api/member/logout' }); + await logout(); Cookies.remove('accessToken'); Cookies.remove('refreshToken'); diff --git a/src/components/MakeChannel/SelectRule.tsx b/src/components/MakeChannel/SelectRule.tsx index a8af5d40..580bd62f 100644 --- a/src/components/MakeChannel/SelectRule.tsx +++ b/src/components/MakeChannel/SelectRule.tsx @@ -8,18 +8,31 @@ import useMakeGame from '@hooks/useMakeGame'; import { GameMethod, MakeChannelStep } from '@constants/MakeGame'; import CustomRule from './CustomRule'; import { useRef, useState } from 'react'; -import authAPI from '@apis/authAPI'; import Image from 'next/image'; -import { ChannelCircleProps } from '@type/channelCircle'; import useChannels from '@hooks/useChannels'; import { useRouter } from 'next/router'; import Icon from '@components/Icon'; +import { createNewChannel } from '@apis/channels'; +import { uploadImage } from '@apis/utils'; interface Props { handleCurrentModalStep: (step: keyof typeof MakeChannelStep) => void; handleModal: () => void; } +export interface NewGameOption { + gameCategory: number; + matchFormat: number; + title: string; + maxPlayer: number; + tier: boolean; + tierMax: number; + tierMin: number; + playCount: boolean; + playCountMin: number; + channelImageUrl: string; +} + const SelectRule = ({ handleCurrentModalStep, handleModal }: Props) => { const inputRef = useRef(null); @@ -52,22 +65,20 @@ const SelectRule = ({ handleCurrentModalStep, handleModal }: Props) => { } try { - const res = await authAPI({ - method: 'post', - url: '/api/channel', - data: { - gameCategory, - matchFormat, - title: basicInfo.title, - maxPlayer: basicInfo.participationNum, - tier: isUseCustomRule.tierMax || isUseCustomRule.tierMin, - tierMax: customRule.tierMax, - tierMin: customRule.tierMin, - playCount: isUseCustomRule.playCount, - playCountMin: customRule.playCountMin, - channelImageUrl: channelImgUrl, - }, - }); + const newGameOption: NewGameOption = { + gameCategory, + matchFormat, + title: basicInfo.title, + maxPlayer: basicInfo.participationNum, + tier: isUseCustomRule.tierMax || isUseCustomRule.tierMin, + tierMax: customRule.tierMax, + tierMin: customRule.tierMin, + playCount: isUseCustomRule.playCount, + playCountMin: customRule.playCountMin, + channelImageUrl: channelImgUrl, + }; + + const res = await createNewChannel(newGameOption); resetState(); router.push('/'); handleModal(); @@ -86,14 +97,7 @@ const SelectRule = ({ handleCurrentModalStep, handleModal }: Props) => { formData.append('uploadImage', e.target.files[0]); try { - const res = await authAPI<{ imgUrl: string }>({ - method: 'post', - url: `/api/image`, - data: formData, - headers: { - 'Content-Type': 'multipart/form-data', - }, - }); + const res = await uploadImage(formData); setImageUrl(res.data.imgUrl); handleImgUrl(res.data.imgUrl); diff --git a/src/components/Modal/JoinLeague/JoinLeague.tsx b/src/components/Modal/JoinLeague/JoinLeague.tsx index d16e0929..d795ac7f 100644 --- a/src/components/Modal/JoinLeague/JoinLeague.tsx +++ b/src/components/Modal/JoinLeague/JoinLeague.tsx @@ -1,6 +1,6 @@ -import authAPI from '@apis/authAPI'; +import { joinChannelParticipant } from '@apis/channels'; +import { fetchUserTier } from '@apis/utils'; import Icon from '@components/Icon'; -import { SERVER_URL } from '@config/index'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; import useProfile from '@hooks/useProfile'; @@ -30,9 +30,7 @@ const JoinLeague = ({ onClose, channelLink }: JoinLeagueProps) => { return; } - const userTier: string = ( - await authAPI.get(SERVER_URL + `/api/participant/stat/${gameIdVal}/${gameTagVal}`) - ).data.tier; + const userTier: string = await fetchUserTier(gameIdVal, gameTagVal); setTier(userTier); setGameId(gameIdVal + '#' + gameTagVal); }; @@ -53,14 +51,7 @@ const JoinLeague = ({ onClose, channelLink }: JoinLeagueProps) => { const onClickSubmit: MouseEventHandler = async () => { if (!nickname || !checked) return; - const res = await authAPI({ - method: 'post', - url: `/api/${channelLink}/participant`, - data: { - gameId, - nickname, - }, - }); + const res = await joinChannelParticipant(channelLink, gameId, nickname); if (res.status !== 200) return; diff --git a/src/components/Modal/ModifyChannel/ModifyChannel.tsx b/src/components/Modal/ModifyChannel/ModifyChannel.tsx index 98b30407..6b3acc86 100644 --- a/src/components/Modal/ModifyChannel/ModifyChannel.tsx +++ b/src/components/Modal/ModifyChannel/ModifyChannel.tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { fetchChannelInfo } from '@apis/channels'; import Icon from '@components/Icon'; import BasicInfoChannel from '@components/ModifyChannel/BasicInfoChannel'; import BracketInfoChannel from '@components/ModifyChannel/BracketInfoChannel'; @@ -13,11 +13,6 @@ interface ModifyChannelProps { type MenuList = 'basicInfo' | 'bracketInfo'; -const fetchChannelInfo = async (channelLink: string) => { - const res = await authAPI({ method: 'get', url: `/api/channel/${channelLink}` }); - return res.data; -}; - const ModifyChannel = ({ channelLink, onClose }: ModifyChannelProps) => { const [selectedMenu, setSelectedMenu] = useState('basicInfo'); @@ -46,8 +41,8 @@ const ModifyChannel = ({ channelLink, onClose }: ModifyChannelProps) => { {selectedMenu === 'basicInfo' && ( )} {selectedMenu === 'bracketInfo' && } diff --git a/src/components/Modal/ParticipantLists/ObserverUser.tsx b/src/components/Modal/ParticipantLists/ObserverUser.tsx index 538a28ac..e00116ad 100644 --- a/src/components/Modal/ParticipantLists/ObserverUser.tsx +++ b/src/components/Modal/ParticipantLists/ObserverUser.tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { fetchOberverUser, promoteToAdmin } from '@apis/channels'; import { Participant } from '@components/Modal/ParticipantLists/ParticipantUser'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; @@ -11,10 +11,8 @@ const ObserverUser = () => { const { currentChannel, channelPermission } = useChannels(); const fetchData = async () => { - const res = await authAPI({ - method: 'get', - url: `/api/${currentChannel}/observers`, - }); + if (!currentChannel) return; + const res = await fetchOberverUser(currentChannel); setObservers(res.data); }; @@ -23,11 +21,9 @@ const ObserverUser = () => { }; const onClickPromotionUser = async (observer: Participant) => { + if (!currentChannel) return; if (!confirm(`${observer.nickname}님을 관리자 권한을 부여하겠습니까?`)) return; - const res = await authAPI({ - method: 'post', - url: `/api/${currentChannel}/${observer.pk}/host`, - }); + const res = await promoteToAdmin(currentChannel, observer.pk); if (res.status !== 200) return; const updatedObservers = observers?.filter((user) => user.pk !== observer.pk); setObservers(updatedObservers); diff --git a/src/components/Modal/ParticipantLists/ParticipantUser.tsx b/src/components/Modal/ParticipantLists/ParticipantUser.tsx index f63d6b50..82a8d10f 100644 --- a/src/components/Modal/ParticipantLists/ParticipantUser.tsx +++ b/src/components/Modal/ParticipantLists/ParticipantUser.tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { demoteToObserver, fetchParticipantUser } from '@apis/channels'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; import useChannels from '@hooks/useChannels'; @@ -19,10 +19,8 @@ const ParticipantUser = () => { const { currentChannel, channelPermission } = useChannels(); const fetchData = async () => { - const res = await authAPI({ - method: 'get', - url: `/api/${currentChannel}/players`, - }); + if (!currentChannel) return; + const res = await fetchParticipantUser(currentChannel); setParticipants(res.data); }; @@ -31,11 +29,9 @@ const ParticipantUser = () => { }; const onClickKickUser = async (participant: Participant) => { + if (!currentChannel) return; if (!confirm(`${participant.nickname}님을 강퇴하시겠습니까?`)) return; - const res = await authAPI({ - method: 'post', - url: `/api/${currentChannel}/${participant.pk}/observer`, - }); + const res = await demoteToObserver(currentChannel, participant.pk); if (res.status !== 200) return; const updatedParticipants = participants?.filter((user) => user.pk !== participant.pk); setParticipants(updatedParticipants); diff --git a/src/components/Modal/ParticipantLists/RequestUser.tsx b/src/components/Modal/ParticipantLists/RequestUser.tsx index 9080192d..b534b583 100644 --- a/src/components/Modal/ParticipantLists/RequestUser.tsx +++ b/src/components/Modal/ParticipantLists/RequestUser.tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { confirmParticipation, fetchRequestUser, rejectParticipation } from '@apis/channels'; import { Participant } from '@components/Modal/ParticipantLists/ParticipantUser'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; @@ -6,23 +6,14 @@ import useChannels from '@hooks/useChannels'; import Image from 'next/image'; import { useEffect, useState } from 'react'; -const postData = async (url: string) => { - const res = await authAPI({ - method: 'post', - url: url, - }); - return res; -}; - const RequestUser = () => { const [requestUsers, setRequestUsers] = useState(); const { currentChannel, channelPermission } = useChannels(); const fetchData = async () => { - const res = await authAPI({ - method: 'get', - url: `/api/${currentChannel}/player/requests`, - }); + if (currentChannel === undefined) return; + const res = await fetchRequestUser(currentChannel); + setRequestUsers(res.data); }; @@ -31,13 +22,14 @@ const RequestUser = () => { }; const onClick = async (requestUser: Participant, mode: boolean) => { + if (!currentChannel) return; let res; if (mode) { if (!confirm(`${requestUser.nickname}님 대회 참가를 수락하시겠습니까?`)) return; - res = await postData(`/api/${currentChannel}/${requestUser.pk}/player`); + res = await confirmParticipation(currentChannel, requestUser.pk); } else { if (!confirm(`${requestUser.nickname}님 대회 참가를 거절하시겠습니까?`)) return; - res = await postData(`/api/${currentChannel}/${requestUser.pk}/observer`); + res = await rejectParticipation(currentChannel, requestUser.pk); } if (res.status !== 200) return; const updatedRequestUsers = requestUsers?.filter((user) => user.pk !== requestUser.pk); diff --git a/src/components/ModifyChannel/AssignBracket.tsx b/src/components/ModifyChannel/AssignBracket.tsx index affd745c..6b84e6f5 100644 --- a/src/components/ModifyChannel/AssignBracket.tsx +++ b/src/components/ModifyChannel/AssignBracket.tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { assignNextRound, fetchAllBracket } from '@apis/brackets'; import styled from '@emotion/styled'; import { useQuery } from '@tanstack/react-query'; import { BracketHeader } from '@type/bracket'; @@ -7,15 +7,6 @@ import { useRouter } from 'next/router'; type bracketStatus = 'DONE' | 'READY' | 'BAN'; -const fetchAllBracket = async (channelLink: string) => { - const res = await authAPI({ - method: 'get', - url: `/api/match/${channelLink}`, - }); - - return res.data; -}; - const AssignBracket = () => { const router = useRouter(); @@ -24,21 +15,16 @@ const AssignBracket = () => { queryFn: () => fetchAllBracket(router.query.channelLink as string), }); - const fetchSetBracket = async (round: number) => { - if (window.confirm(`Round ${round}를 배정하시겠습니까?`)) { - try { - const res = await authAPI({ - method: 'post', - url: `/api/match/${router.query.channelLink as string}/${round}`, - }); - - if (isSuccess) { - data.liveRound = round; - } - } catch (error) { - if (error instanceof AxiosError) { - window.alert(error.response?.data.message); - } + const setBracket = async (round: number) => { + if (!window.confirm(`Round ${round}를 배정하시겠습니까?`)) return; + try { + await assignNextRound(router.query.channelLink as string, round); + if (isSuccess) { + data.liveRound = round; + } + } catch (error) { + if (error instanceof AxiosError) { + window.alert(error.response?.data.message); } } }; @@ -51,7 +37,7 @@ const AssignBracket = () => { Round {round} {round === data.liveRound && 배정 완료} {round === data.liveRound + 1 && ( - fetchSetBracket(round)}> + setBracket(round)}> 배정 하기 )} diff --git a/src/components/ModifyChannel/BasicInfoChannel.tsx b/src/components/ModifyChannel/BasicInfoChannel.tsx index 8cb6f01d..6934a68d 100644 --- a/src/components/ModifyChannel/BasicInfoChannel.tsx +++ b/src/components/ModifyChannel/BasicInfoChannel.tsx @@ -1,7 +1,6 @@ import styled from '@emotion/styled'; -import { css } from '@emotion/react'; import { useRef } from 'react'; -import authAPI from '@apis/authAPI'; +import { updateChannelInfo } from '@apis/channels'; interface BasicInfoChannelProps { channelLink: string; @@ -23,14 +22,7 @@ const BasicInfoChannel = ({ channelLink, leagueTitle, maxPlayer }: BasicInfoChan return; } if (!confirm('리그를 수정하시겠습니까?')) return; - const res = await authAPI({ - method: 'post', - url: `/api/channel/${channelLink}`, - data: { - title: updatedLeagueTitle, - maxPlayer: updatedMaxPlayer, - }, - }); + const res = await updateChannelInfo(channelLink, updatedLeagueTitle, updatedMaxPlayer); if (res.status !== 200) return; alert('정보가 수정되었습니다'); }; diff --git a/src/components/ModifyChannel/BracketInfoChannel.tsx b/src/components/ModifyChannel/BracketInfoChannel.tsx index 122ef595..c17df49c 100644 --- a/src/components/ModifyChannel/BracketInfoChannel.tsx +++ b/src/components/ModifyChannel/BracketInfoChannel.tsx @@ -1,18 +1,9 @@ -import authAPI from '@apis/authAPI'; +import { fetchInitialMatchCount, updateRoundMatch } from '@apis/match'; import styled from '@emotion/styled'; import { useQuery } from '@tanstack/react-query'; -import { MatchCountList } from '@type/channelConfig'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; -const fetchInitialMatchCount = async (channelLink: string) => { - const res = await authAPI({ - method: 'get', - url: `/api/match/${channelLink}/count`, - }); - return res.data; -}; - const BracketInfoChannel = () => { const router = useRouter(); @@ -38,14 +29,7 @@ const BracketInfoChannel = () => { } try { - const res = await authAPI({ - method: 'post', - url: `/api/match/${router.query.channelLink as string}/count`, - data: { - matchSetCountList: [...roundInfo].reverse(), - }, - }); - + await updateRoundMatch(router.query.channelLink as string, [...roundInfo].reverse()); alert('수정이 완료되었습니다!'); } catch (error) { console.log(error); diff --git a/src/components/ModifyChannel/StartMatch.tsx b/src/components/ModifyChannel/StartMatch.tsx index 3da11f7b..5f6e7dff 100644 --- a/src/components/ModifyChannel/StartMatch.tsx +++ b/src/components/ModifyChannel/StartMatch.tsx @@ -1,5 +1,4 @@ -import authAPI from '@apis/authAPI'; -import Button from '@components/Button'; +import { fetchStartBracket } from '@apis/brackets'; import styled from '@emotion/styled'; import { AxiosError } from 'axios'; import { useRouter } from 'next/router'; @@ -7,19 +6,10 @@ import { useRouter } from 'next/router'; const StartMatch = () => { const router = useRouter(); - const fetchStartBracket = async () => { - const res = await authAPI({ - method: 'put', - url: `/api/channel/${router.query.channelLink as string}?status=1`, - }); - - return res; - }; - const handleStartMatch = async () => { if (window.confirm('대회를 시작하시겠습니까?\n시작한 이후에는 중지할 수 없습니다')) { try { - const res = await fetchStartBracket(); + await fetchStartBracket(router.query.channelLink as string); window.alert('대회가 시작되었습니다!\nRound 1 배정을 해주세요!'); } catch (error) { if (error instanceof AxiosError) { diff --git a/src/components/RoundAlarm/RoundAlarmBody.tsx b/src/components/RoundAlarm/RoundAlarmBody.tsx index 4ee46236..c3c98cd9 100644 --- a/src/components/RoundAlarm/RoundAlarmBody.tsx +++ b/src/components/RoundAlarm/RoundAlarmBody.tsx @@ -1,10 +1,10 @@ -import authAPI from '@apis/authAPI'; import Icon from '@components/Icon'; import styled from '@emotion/styled'; import { BracketContents } from '@type/bracket'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; import { CallAdmin } from '@type/admin'; +import { fetchRoundInfo, navigateToCheckInPage } from '@apis/match'; interface Props { curRound: number; @@ -19,10 +19,7 @@ const RoundAlarmBody = ({ curRound, alramInfo }: Props) => { useEffect(() => { const getRoundInfo = async () => { try { - const res = await authAPI({ - method: 'get', - url: `/api/match/${router.query.channelLink as string}/${curRound}`, - }); + const res = await fetchRoundInfo(router.query.channelLink as string, curRound); setRoundInfo(res.data); } catch (error) {} @@ -32,10 +29,7 @@ const RoundAlarmBody = ({ curRound, alramInfo }: Props) => { }, [router.query.channelLink as string]); const moveToCheckIn = (matchId: number) => { - authAPI({ - method: 'post', - url: `/api/match/${router.query.channelLink as string}/${matchId}/call-off`, - }); + navigateToCheckInPage(router.query.channelLink as string, matchId); router.push(`/contents/${router.query.channelLink as string}/checkIn/${matchId}`); }; diff --git a/src/components/RoundCheckIn/PlayerLists.tsx b/src/components/RoundCheckIn/PlayerLists.tsx index 6cd07582..ba492976 100644 --- a/src/components/RoundCheckIn/PlayerLists.tsx +++ b/src/components/RoundCheckIn/PlayerLists.tsx @@ -1,9 +1,7 @@ -import authAPI from '@apis/authAPI'; import Icon from '@components/Icon'; import { MatchPlayerScoreInfos, UserStatus } from '@components/RoundCheckIn'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; -import { useRouter } from 'next/router'; interface PlayerListsProps { ParticipantDisqualifying: (participantId: number, matchPlayerId: number) => void; diff --git a/src/components/RoundCheckIn/index.tsx b/src/components/RoundCheckIn/index.tsx index 02f3ad8f..2c09b9f2 100644 --- a/src/components/RoundCheckIn/index.tsx +++ b/src/components/RoundCheckIn/index.tsx @@ -9,6 +9,7 @@ import authAPI from '@apis/authAPI'; import { useRouter } from 'next/router'; import { css } from '@emotion/react'; import Cookies from 'js-cookie'; +import { fetchMatchInfos } from '@apis/match'; export interface MatchPlayerScoreInfos { matchPlayerId: number; @@ -60,10 +61,7 @@ const RoundCheckIn = ({ channelLink, matchId }: RoundCheckInProps) => { const router = useRouter(); const fetchData = async () => { - const res = await authAPI({ - method: 'get', - url: `/api/channel/${channelLink}/match/${matchId}/player/info`, - }); + const res = await fetchMatchInfos(channelLink, matchId); if (res.status !== 200 || res.data.requestMatchPlayerId === 0) { router.back(); diff --git a/src/components/Sidebar/BoardBar/BoardBar.tsx b/src/components/Sidebar/BoardBar/BoardBar.tsx index 51ce75bd..62733f4c 100644 --- a/src/components/Sidebar/BoardBar/BoardBar.tsx +++ b/src/components/Sidebar/BoardBar/BoardBar.tsx @@ -4,22 +4,15 @@ import styled from '@emotion/styled'; import BoardFooter from '@components/Sidebar/BoardBar/BoardFooter'; import BoardHeader from '@components/Sidebar/BoardBar/BoardHeader'; import BoardBody from '@components/Sidebar/BoardBar/BoardBody'; -import { BoardInfo } from '@type/board'; -import authAPI from '@apis/authAPI'; import { useEffect } from 'react'; import useChannels from '@hooks/useChannels'; import MainHeader from '@components/MainHeader/MainHeader'; - -const fetchData = async (channelLink: string) => { - const res = await authAPI({ method: 'get', url: '/api/channel/' + channelLink }); - - return res.data; -}; +import { fetchChannelInfo } from '@apis/channels'; const BoardBar = ({ channelLink }: { channelLink: string }) => { const { data } = useQuery({ queryKey: ['getBoard', channelLink], - queryFn: () => fetchData(channelLink), + queryFn: () => fetchChannelInfo(channelLink), gcTime: Infinity, enabled: channelLink !== 'main', }); diff --git a/src/components/Sidebar/BoardBar/BoardBody.tsx b/src/components/Sidebar/BoardBar/BoardBody.tsx index e326459b..54379575 100644 --- a/src/components/Sidebar/BoardBar/BoardBody.tsx +++ b/src/components/Sidebar/BoardBar/BoardBody.tsx @@ -3,53 +3,18 @@ import { MouseEventHandler, useEffect, useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { useRouter } from 'next/router'; import styled from '@emotion/styled'; -import authAPI from '@apis/authAPI'; import { Channels } from '@type/board'; import Icon from '@components/Icon'; import useLastVisitedBoardLists from '@hooks/useLastVisitedBoardLists'; -import { NEWBOARD } from '@constants/MakeBoard'; import useChannels from '@hooks/useChannels'; import { css } from '@emotion/react'; +import { changeBoardOrder, createNewBoard, fetchBoardLists } from '@apis/boards'; interface Props { channelLink: string; } -interface NewBoard { - boardId: number; - boardTitle: string; - boardIndex: number; -} - -interface BoardsInfo { - myMatchRound: number; - myMatchId: number; - channelBoardLoadDtoList: Channels[]; -} - -const fetchData = async (channelLink: string) => { - const res = await authAPI({ - method: 'get', - url: `/api/channel/${channelLink}/boards`, - }); - - return res.data; -}; - -const postData = async (channelLink: string) => { - const res = await authAPI({ - method: 'post', - url: `/api/channel/${channelLink}/new`, - data: { - title: NEWBOARD.DEFAULT_TITLE, - content: NEWBOARD.DEFAULT_CONTENT, - }, - }); - - return res.data; -}; - const BoardBody = ({ channelLink }: Props) => { const [selected, setSelected] = useState(''); const [boards, setBoards] = useState([]); @@ -57,7 +22,7 @@ const BoardBody = ({ channelLink }: Props) => { const { data, isSuccess } = useQuery({ queryKey: ['getBoardLists', channelLink], - queryFn: () => fetchData(channelLink), + queryFn: () => fetchBoardLists(channelLink), }); const { lastVisitedBoardIdLists, handleBoard } = useLastVisitedBoardLists(); @@ -82,7 +47,7 @@ const BoardBody = ({ channelLink }: Props) => { const onClickNewBoard: MouseEventHandler = async () => { if (boards === undefined) return; - const res = await postData(channelLink); + const res = await createNewBoard(channelLink); const newBoard: Channels = { boardId: res.boardId, boardTitle: res.boardTitle, @@ -94,14 +59,7 @@ const BoardBody = ({ channelLink }: Props) => { }; const postCustomBoard = async (customedBoards: Channels[]) => { - const res = await authAPI({ - method: 'post', - url: `/api/channel/${channelLink}/order`, - data: { - channelBoardLoadDtoList: customedBoards, - }, - }); - + const res = await changeBoardOrder(channelLink, customedBoards); if (res.status === 200) setBoards(customedBoards); }; diff --git a/src/components/Sidebar/ChannelBar/SelectChannelType.tsx b/src/components/Sidebar/ChannelBar/SelectChannelType.tsx index 0adf873d..6ce1ca96 100644 --- a/src/components/Sidebar/ChannelBar/SelectChannelType.tsx +++ b/src/components/Sidebar/ChannelBar/SelectChannelType.tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { joinChannel } from '@apis/channels'; import Button from '@components/Button'; import SelectGame from '@components/MakeChannel/SelectGame'; import SelectRule from '@components/MakeChannel/SelectRule'; @@ -29,12 +29,10 @@ const SelectChannelType = (props: Props) => { const fetchEnterNewChannel = async (event: React.FormEvent) => { event.preventDefault(); + if (!channelInput) return; try { - const res = await authAPI({ - method: 'post', - url: `/api/${channelInput}/participant/observer`, - }); + const res = await joinChannel(channelInput); const newChannel: ChannelCircleProps = { channelLink: res.data.channelLink, diff --git a/src/components/providers/ChannelsProvider.tsx b/src/components/providers/ChannelsProvider.tsx index f6877c53..be245388 100644 --- a/src/components/providers/ChannelsProvider.tsx +++ b/src/components/providers/ChannelsProvider.tsx @@ -4,21 +4,12 @@ import Cookies from 'js-cookie'; import { ChannelCircleProps } from '@type/channelCircle'; import ChannelsContext from '@contexts/ChannelsContext'; -import authAPI from '@apis/authAPI'; +import { fetchChannelLists, updateChannelOrder } from '@apis/channels'; interface Props { children: React.ReactNode; } -const fetchChannels = async () => { - const res = await authAPI({ - method: 'get', - url: '/api/channels', - }); - - return res.data; -}; - const ChannelsProvider = ({ children }: Props) => { const isHaveAccessToken = Cookies.get('accessToken'); @@ -28,7 +19,7 @@ const ChannelsProvider = ({ children }: Props) => { const { data } = useQuery({ queryKey: ['getChannels'], - queryFn: fetchChannels, + queryFn: fetchChannelLists, enabled: isHaveAccessToken ? true : false, }); @@ -50,16 +41,7 @@ const ChannelsProvider = ({ children }: Props) => { setChannels(updateChannels); - updateChannelsOrder(updateChannels); - }; - - const updateChannelsOrder = async (channels: ChannelCircleProps[]) => { - try { - const res = await authAPI({ method: 'post', url: '/api/channels/order', data: channels }); - console.log(res.data); - } catch (error) { - console.log(error); - } + updateChannelOrder(updateChannels); }; useEffect(() => { diff --git a/src/components/providers/ProfileProvider.tsx b/src/components/providers/ProfileProvider.tsx index 4ffec413..15e7ab2e 100644 --- a/src/components/providers/ProfileProvider.tsx +++ b/src/components/providers/ProfileProvider.tsx @@ -3,8 +3,8 @@ import { useQuery } from '@tanstack/react-query'; import ProfileContext from '@contexts/ProfileContext'; import { Profile } from '@type/profile'; -import authAPI from '@apis/authAPI'; import Cookies from 'js-cookie'; +import { fetchProfile } from '@apis/mypage'; interface ProfileAPI { nickName: string; @@ -15,14 +15,6 @@ interface ProfileProviderProps { children: React.ReactNode; } -const fetchProfile = async () => { - const res = await authAPI({ - method: 'get', - url: '/api/member/profile', - }); - return res.data; -}; - const ProfileProvider = ({ children }: ProfileProviderProps) => { // 유저가 로그인 되어있는지 확인 diff --git a/src/pages/contents/[channelLink]/[boardId].tsx b/src/pages/contents/[channelLink]/[boardId].tsx index 1cab4c68..7c018ea7 100644 --- a/src/pages/contents/[channelLink]/[boardId].tsx +++ b/src/pages/contents/[channelLink]/[boardId].tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { deleteBoardContents, fetchBoardContents, updateBoardContents } from '@apis/boardContents'; import ContentModify from '@components/Content/ContentModify'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; @@ -18,19 +18,6 @@ interface ContentButtonProps { backgroundColor?: string; } -const updateData = async (channelLink: string, boardId: string, updatedContent: Content) => { - const res = await authAPI({ - method: 'post', - url: `/api/channel/${channelLink}/${boardId}`, - data: { - title: updatedContent.title, - content: updatedContent.content, - }, - }); - - return res; -}; - const boardContents = () => { const [contents, setContents] = useState({ title: '', content: '' }); const [isModify, setIsModify] = useState(false); @@ -41,11 +28,7 @@ const boardContents = () => { const { handleBoard } = useLastVisitedBoardLists(); const fetchBoardContent = async () => { - const res = await authAPI({ - method: 'get', - url: `/api/channel/${channelLink}/${boardId}`, - }); - + const res = await fetchBoardContents(channelLink as string, boardId as string); if (res.status !== 200) return router.push('/'); setContents(res.data); @@ -58,7 +41,7 @@ const boardContents = () => { }; if (!channelLink) return; - const res = await updateData(channelLink as string, boardId as string, updatedContent); + const res = await updateBoardContents(channelLink as string, boardId as string, updatedContent); if (res.status !== 200) { alert('요청실패'); return; @@ -71,7 +54,7 @@ const boardContents = () => { const deleteBoard = async () => { if (!confirm('공지를 삭제하시겠습니까?')) return; - const res = await authAPI({ method: 'delete', url: `/api/channel/${channelLink}/${boardId}` }); + const res = await deleteBoardContents(channelLink as string, boardId as string); if (res.status !== 200) { alert('서버 에러가 발생했습니다.'); diff --git a/src/pages/contents/[channelLink]/admin.tsx b/src/pages/contents/[channelLink]/admin.tsx index 15372513..6c09d942 100644 --- a/src/pages/contents/[channelLink]/admin.tsx +++ b/src/pages/contents/[channelLink]/admin.tsx @@ -4,7 +4,6 @@ import { useRouter } from 'next/router'; import { GetServerSideProps } from 'next'; import Modal from '@components/Modal'; -import Button from '@components/Button'; import ModifyBracket from '@components/Modal/ModifyChannel/ModifyBracket'; import ModifyChannel from '@components/Modal/ModifyChannel/ModifyChannel'; @@ -16,20 +15,14 @@ import { useEffect, useState } from 'react'; import { connectToStomp } from '@config/stomp'; import { Client, StompSubscription } from '@stomp/stompjs'; import { useQuery } from '@tanstack/react-query'; -import authAPI from '@apis/authAPI'; -import { BracketHeader } from '@type/bracket'; import RoundAlarmHeader from '@components/RoundAlarm/RoundAlarmHeader'; import RoundAlarmBody from '@components/RoundAlarm/RoundAlarmBody'; import { CallAdmin } from '@type/admin'; +import { fetchRoundInfo } from '@apis/roundInfo'; interface Props { role: string; } -const fetchRoundInfo = async (channelLink: string): Promise => { - const res = await authAPI({ method: 'get', url: `/api/match/${channelLink}` }); - return res.data; -}; - const Admin = ({ role }: Props) => { const router = useRouter(); const [client, setClient] = useState(); @@ -78,47 +71,45 @@ const Admin = ({ role }: Props) => { return (
{' '} -
- -
대회 설정
- - - openModal(Modal, { - onClose: () => closeModal(Modal), - children: closeModal(Modal)} />, - }) - } - > - 대회 관리하기 - - - openModal(Modal, { - onClose: () => closeModal(Modal), - children: ( - closeModal(Modal)} - /> - ), - }) - } - > - 채널 정보 수정하기 - - -
대회 알림
- - - {data?.roundList.map((ele) => { - return ; - })} - - - {curRound && } -
-
+ +
대회 설정
+ + + openModal(Modal, { + onClose: () => closeModal(Modal), + children: closeModal(Modal)} />, + }) + } + > + 대회 관리하기 + + + openModal(Modal, { + onClose: () => closeModal(Modal), + children: ( + closeModal(Modal)} + /> + ), + }) + } + > + 채널 정보 수정하기 + + +
대회 알림
+ + + {data?.roundList.map((ele) => { + return ; + })} + + + {curRound && } +
); }; diff --git a/src/pages/contents/[channelLink]/main.tsx b/src/pages/contents/[channelLink]/main.tsx index 58769fe8..6bf55111 100644 --- a/src/pages/contents/[channelLink]/main.tsx +++ b/src/pages/contents/[channelLink]/main.tsx @@ -1,4 +1,4 @@ -import authAPI from '@apis/authAPI'; +import { fetchMainContents, updateMainContents } from '@apis/mainContents'; import HomeCard from '@components/Card/HomeCard'; import MainContentModify from '@components/Content/MainContentModify'; import styled from '@emotion/styled'; @@ -15,19 +15,6 @@ export interface MainContent { readonly channelPrizeInfo: string; } -const fetchData = async (channelLink: string): Promise => { - const res = await authAPI({ - method: 'get', - url: `/api/channel/${channelLink}/main`, - }); - - if (res.status !== 200) { - return; - } - - return res.data; -}; - const Main = () => { const [mainContents, setMainContents] = useState(); const [isModify, setIsModify] = useState(false); @@ -38,7 +25,7 @@ const Main = () => { const { data, isSuccess, refetch } = useQuery({ queryKey: ['getMainContents', channelLink], - queryFn: () => fetchData(channelLink as string), + queryFn: () => fetchMainContents(channelLink as string), }); useEffect(() => { @@ -52,12 +39,7 @@ const Main = () => { const handleContentUpdate = async (updatedContent: MainContent) => { if (!channelLink) return; - const res = await authAPI({ - method: 'post', - url: `/api/channel/${channelLink}/main`, - data: updatedContent, - }); - if (res.status !== 200) return router.push('/'); + await updateMainContents(channelLink as string, updatedContent); setMainContents(updatedContent); setIsModify(false); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 5869e5b2..a2264a3d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,16 +1,12 @@ -import authAPI from '@apis/authAPI'; +import { fetchGamePatchNote } from '@apis/boards'; import styled from '@emotion/styled'; import { useQuery } from '@tanstack/react-query'; -import { MainPageNoticeData } from '@type/mainPage'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; const fetchNotice = async (board: string) => { if (!board) return; - const res = await authAPI>({ - method: 'get', - url: `/api/notice/${board}`, - }); + const res = await fetchGamePatchNote(board); return res.data; }; diff --git a/src/pages/mypage.tsx b/src/pages/mypage.tsx index 3973df99..94eab1f1 100644 --- a/src/pages/mypage.tsx +++ b/src/pages/mypage.tsx @@ -9,7 +9,7 @@ import checkEmailAddressValidation from 'src/utils/checkEmailAddressValidation'; import { SERVER_URL } from '@config/index'; import { MyPage } from '@type/mypage'; import Icon from '@components/Icon'; -import authAPI from '@apis/authAPI'; +import { fetchMy, sendEmailVerification } from '@apis/mypage'; interface Props { data: MyPage; @@ -32,13 +32,7 @@ const Mypage = (props: Props) => { } try { - const res = await authAPI({ - method: 'post', - url: '/api/member/auth/email', - data: { - email, - }, - }); + await sendEmailVerification(email); setSendEmail(true); alert( @@ -51,10 +45,7 @@ const Mypage = (props: Props) => { const refreshMyInfo = async () => { try { - const res = await authAPI({ - method: 'get', - url: '/api/member/mypage', - }); + const res = await fetchMy(); setInfo(res.data); } catch (error) { console.log(error);