diff --git a/src/apis/adminApproval/AdminApprovalApi.ts b/src/apis/adminApproval/AdminApprovalApi.ts new file mode 100644 index 00000000..88fd31ab --- /dev/null +++ b/src/apis/adminApproval/AdminApprovalApi.ts @@ -0,0 +1,18 @@ +import { axiosAPI } from '@/apis/axios' + +const AdminApprovalAPI = { + GET_APPROVAL_REQUEST_LIST: async () => { + const response = await axiosAPI.get(`/admin/approvals`) + return { + data: response.data, + } + }, + GET_APPROVAL_INFO: async () => { + const response = await axiosAPI.get(`/admin/approvals/1`) + return { + data: response.data, + } + }, +} + +export default AdminApprovalAPI diff --git a/src/apis/adminReport/AdminReportApi.ts b/src/apis/adminReport/AdminReportApi.ts new file mode 100644 index 00000000..6df5495b --- /dev/null +++ b/src/apis/adminReport/AdminReportApi.ts @@ -0,0 +1,12 @@ +import { axiosAPI } from '@/apis/axios' + +const AdminReportAPI = { + GET_REPORT_LIST: async () => { + const response = await axiosAPI.get(`/admin/reports`) + return { + data: response.data, + } + }, +} + +export default AdminReportAPI diff --git a/src/apis/axios.ts b/src/apis/axios.ts index fe99eba1..285d9728 100644 --- a/src/apis/axios.ts +++ b/src/apis/axios.ts @@ -14,7 +14,7 @@ axiosAPI.interceptors.request.use( function (config) { // 요청 바로 직전 // axios 설정값에 대해 작성합니다. - + config.headers['Authorization'] = `Bearer ${localStorage.getItem('token')}` // const { authTokens } = useAuthStore() // config.headers['Authorization'] = `Bearer ${authTokens}` diff --git a/src/components/common/ListRow/AdminApprovalList.tsx b/src/components/common/ListRow/AdminApprovalList.tsx index f0059201..ba759e18 100644 --- a/src/components/common/ListRow/AdminApprovalList.tsx +++ b/src/components/common/ListRow/AdminApprovalList.tsx @@ -1,43 +1,44 @@ import styled from '@emotion/styled' +import { useQuery } from '@tanstack/react-query' +import AdminApprovalAPI from '@/apis/adminApproval/AdminApprovalApi' import AdminApprovalListRow from '@/components/common/ListRow/AdminApprovalListRow' import { palette } from '@/styles/palette' interface AdminApprovalListProps { - onApproveSelect: (nickname: string) => void + onApproveSelectUserName: (nickname: string) => void } +interface ApprovalListData { + approvalRequestUser: string + approvalRequestUserStatus: string +} + +const AdminApprovalList = ({ onApproveSelectUserName }: AdminApprovalListProps) => { + // API 요청 코드 + const { data, isSuccess } = useQuery( + ['ApprovalRequestList'], + AdminApprovalAPI.GET_APPROVAL_REQUEST_LIST, + ) -const AdminApprovalList = ({ onApproveSelect }: AdminApprovalListProps) => { const handlePersonApproval = (nickname: string) => { - onApproveSelect(nickname) + onApproveSelectUserName(nickname) } - const AdminApprovalListData = [ - { nickname: '유명한', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '박상민', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '박은지', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '주다현', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '남궁호수', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '우창욱', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '대기 중', isDarkMode: false }, - ] + const ApprovalDatas = data?.data.approvals return ( - {AdminApprovalListData.map((data, index) => ( - handlePersonApproval(data.nickname)} - /> - ))} + {isSuccess && + ApprovalDatas.map((approvalListData: ApprovalListData, index: number) => ( + handlePersonApproval(approvalListData.approvalRequestUser)} + /> + ))} ) diff --git a/src/components/common/ListRow/AdminReportList.tsx b/src/components/common/ListRow/AdminReportList.tsx index fcf02145..d2c62ee7 100644 --- a/src/components/common/ListRow/AdminReportList.tsx +++ b/src/components/common/ListRow/AdminReportList.tsx @@ -1,42 +1,38 @@ import styled from '@emotion/styled' +import { useQuery } from '@tanstack/react-query' +import AdminReportAPI from '@/apis/adminReport/AdminReportApi' import AdminReportListRow from '@/components/common/ListRow/AdminReportListRow' import { palette } from '@/styles/palette' interface AdminReportListProps { onReportSelect: (nickname: string) => void } +interface ReportListData { + reportedUserName: string + reportCount: number +} const AdminReportList = ({ onReportSelect }: AdminReportListProps) => { + const { data, isSuccess } = useQuery(['ReportedUserList'], AdminReportAPI.GET_REPORT_LIST) const handlePersonReported = (nickname: string) => { onReportSelect(nickname) } - const AdminReportListData = [ - { nickname: '유명한', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '박상민', height: 71, infoMessage: '누적 2회', isDarkMode: false }, - { nickname: '박은지', height: 71, infoMessage: '누적 2회', isDarkMode: false }, - { nickname: '주다현', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '남궁호수', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '우창욱', height: 71, infoMessage: '누적 2회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - { nickname: '홍길동', height: 71, infoMessage: '누적 1회', isDarkMode: false }, - ] + const ReportDatas = data?.data.reports return ( - {AdminReportListData.map((data, index) => ( - handlePersonReported(data.nickname)} - /> - ))} + {isSuccess && + ReportDatas.map((reportListData: ReportListData, index: number) => ( + handlePersonReported(reportListData.reportedUserName)} + /> + ))} ) diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index f95a399d..cfd9ecbb 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -1,6 +1,14 @@ import { http, HttpResponse } from 'msw' + +import { Approval, ApprovalInfo, ReportInfo, Reports } from './handlersInterface' const nickname = '주다다' + export const handlers = [ + // example + http.get('/pets', () => { + return HttpResponse.json(['Tom', 'Jerry', 'Spike']) + }), + http.get('/v1/histories', () => { return HttpResponse.json([ { @@ -355,4 +363,111 @@ export const handlers = [ statusText: 'Out Of Apples', }) }), + + // example + http.get('/pets', () => { + return HttpResponse.json(['Tom', 'Jerry', 'Spike']) + }), + // 승인 목록 API 핸들러 + http.get('/admin/approvals', () => { + const approvals: Approval[] = [ + { approvalRequestUser: '박상민', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '박은지', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '주다현', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '남궁호수', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '우창욱', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + { approvalRequestUser: '홍길동', approvalRequestUserStatus: '대기 중' }, + ] + return HttpResponse.json({ approvals }) + }), + + // 승인 상세 정보 API 핸들러 + http.get('/admin/approvals/:userId', (req) => { + const { userId } = req.params + const approvalInfo: ApprovalInfo = { + approvalRequestUserName: `userId:${userId}에 해당하는 userName`, + approvalRequestUserEmail: `userId:${userId}에 해당하는 userName의 Email`, + approvalRequestUserBusinessCardImage: `https://www.imageExample.jpg`, + } + + return HttpResponse.json({ approvalInfo }) + }), + + // 승인/거절 처리 API 핸들러 + // req.body 오류 해결이 필요한 부분 + // http.post('/admin/approvals/:userId/action', (req) => { + // const { userId } = req.params + // const { action } = req.body + // const approvalResult: ApprovalResult = { + // result: action === 'accept' ? 'accepted' : 'rejected', + // } + // return HttpResponse.json({ approvalResult }) + // }), + + // 신고 목록 API 핸들러 + http.get('/admin/reports', () => { + const reports: Reports[] = [ + { reportedUserName: '유명한', reportCount: 1 }, + { reportedUserName: '박상민', reportCount: 2 }, + { reportedUserName: '박은지', reportCount: 1 }, + { reportedUserName: '주다현', reportCount: 1 }, + { reportedUserName: '남궁호수', reportCount: 1 }, + { reportedUserName: '우창욱', reportCount: 1 }, + { reportedUserName: '홍길동', reportCount: 0 }, + { reportedUserName: '홍길동', reportCount: 2 }, + { reportedUserName: '홍길동', reportCount: 3 }, + { reportedUserName: '홍길동', reportCount: 1 }, + { reportedUserName: '홍길동', reportCount: 2 }, + { reportedUserName: '홍길동', reportCount: 3 }, + { reportedUserName: '홍길동', reportCount: 1 }, + { reportedUserName: '홍길동', reportCount: 0 }, + ] + return HttpResponse.json({ reports }) + }), + + // 신고 상세 정보 API 핸들러 + http.get('/admin/reports/:userId', (req) => { + const { userId } = req.params + const reportInfo: ReportInfo = { + reportedUserName: `userName, userId:${userId}`, + reporterUserName: 'reporterUserName', + reportDate: new Date().toISOString(), + reason: 'saying swear words', + reportCount: 3, + email: `userId:${userId}@example.com`, + } + return HttpResponse.json({ + reportInfo, + }) + }), + + // // 신고 처리 API 핸들러 + // req.body 오류 해결이 필요한 부분 + // http.post('/admin/reports/:userId/action', (req) => { + // const { userId } = req.params + // const { action } = req.body + // const reportResult: ReportResult = { + // result: action === 'addCount' ? 'countAdded' : 'ignored', + // } + // return HttpResponse.json({ reportResult }) + // }), ] diff --git a/src/mocks/handlersInterface.ts b/src/mocks/handlersInterface.ts new file mode 100644 index 00000000..89da3154 --- /dev/null +++ b/src/mocks/handlersInterface.ts @@ -0,0 +1,29 @@ +export interface Approval { + approvalRequestUser: string + approvalRequestUserStatus: string +} +export interface ApprovalInfo { + approvalRequestUserName: string + approvalRequestUserEmail: string + approvalRequestUserBusinessCardImage: string +} +// req.body 오류 해결이 필요한 부분 +// export interface ApprovalResult { +// result: string +// } +export interface Reports { + reportedUserName: string + reportCount: number +} +export interface ReportInfo { + reportedUserName: string + reporterUserName: string + reportDate: string + reason: string + reportCount: number + email: string +} +// req.body 오류 해결이 필요한 부분 +// export interface ReportResult { +// result: string +// } diff --git a/src/pages/admin/components/AdminApprovalInfo.tsx b/src/pages/admin/components/AdminApprovalInfo.tsx index 1a4faa2e..1a52f08a 100644 --- a/src/pages/admin/components/AdminApprovalInfo.tsx +++ b/src/pages/admin/components/AdminApprovalInfo.tsx @@ -1,5 +1,7 @@ import styled from '@emotion/styled' +import { useQuery } from '@tanstack/react-query' +import AdminApprovalAPI from '@/apis/adminApproval/AdminApprovalApi' import businessCardExample from '@/assets/images/businessCardExample.jpg' import NormalButton from '@/components/common/Buttons/NormalButton' import Spacing from '@/components/common/Spacing' @@ -14,6 +16,11 @@ interface AdminApprovalInfoProps { } const AdminApprovalInfo = ({ selectedApprovalNickname }: AdminApprovalInfoProps) => { + const { data, isSuccess } = useQuery( + ['ApprovalRequestUserInfo'], + AdminApprovalAPI.GET_APPROVAL_INFO, + ) + console.log(isSuccess && data) const { openModal } = useModal() const handleAcceptCertificationBtn = () => { openModal({ diff --git a/src/pages/admin/components/AdminTabs.tsx b/src/pages/admin/components/AdminTabs.tsx index 1179a63c..28955d62 100644 --- a/src/pages/admin/components/AdminTabs.tsx +++ b/src/pages/admin/components/AdminTabs.tsx @@ -30,13 +30,13 @@ const AdminTabs = () => { setSelectedReportNickname(reportNickname) setActiveTab('reportInfo') } - const handleApprovalSelectNickname = (approvalNickname: string) => { + const handleApprovalSelectUserName = (approvalNickname: string) => { setSelectedApprovalNickname(approvalNickname) setActiveTab('approvalInfo') } const ApprovalList = ({ onPersonApprovalSelected }: ApprovalListProps) => ( - + ) const ReportList = ({ onPersonReportedSelected }: ReportListProps) => ( @@ -70,7 +70,7 @@ const AdminTabs = () => { {activeTab === 'approval' && ( - + )} {activeTab === 'report' && ( diff --git a/src/pages/register/RegisterCompany.tsx b/src/pages/register/RegisterCompany.tsx index add880d8..16355278 100644 --- a/src/pages/register/RegisterCompany.tsx +++ b/src/pages/register/RegisterCompany.tsx @@ -1,5 +1,341 @@ +import styled from '@emotion/styled' +import { useMutation } from '@tanstack/react-query' +import { RefObject, useRef, useState } from 'react' +import { MdWbSunny } from 'react-icons/md' +import { useNavigate } from 'react-router-dom' + +import { axiosAPI } from '@/apis/axios' +import AlertText from '@/components/common/AlertText' +import BackChevron from '@/components/common/BackChevron' +import NormalButton from '@/components/common/Buttons/NormalButton' +import { FlexBox } from '@/components/common/Flexbox' +import RegisterInput from '@/components/common/RegisterInput' +import SelectorButtonContainer from '@/components/common/SelectorButtonContainer' +import Spacing from '@/components/common/Spacing' +import useToast from '@/hooks/useToast' +import useInterestStore from '@/store/InterestStore' +import useThemeStore from '@/store/ThemeStore' +import { palette } from '@/styles/palette' +import { typo } from '@/styles/typo' + const RegisterCompany = () => { - return
{'RegisterCompany'}
+ const JobList = [ + '경영', + '영업', + '물류/무역', + 'IT', + '디자인', + '전문직', + '미디어', + '생산/제조', + '연구/개발', + '기획/마케팅', + '광고', + '의약/바이오', + '유통', + '법률/집행기관', + ] + const navigate = useNavigate() + const companyName = useRef(null) + const emailRef = useRef(null) + const codeRef = useRef(null) + const [isCodeSame, setIsCodeSame] = useState(false) + const [codeChecked, setCodeChecked] = useState(null) + const { interestList } = useInterestStore() //여기서 회사 직무 list 저장한거 불러오기 + const { showToast } = useToast() + const isDarkMode = useThemeStore((state) => state.isDarkMode) + const formData = new FormData() + const imgRef = useRef(null) as RefObject + const [uploadedURL, setUploadedURL] = useState('') + + const handleClickEmailVerify = async (email: string) => { + console.log(email) + return await axiosAPI.post(`/v1/certification/users/me/company-mail`, { + companyEmail: emailRef.current && emailRef.current.value, + }) + } + const emailVerifyMutation = useMutation((email: string) => handleClickEmailVerify(email), { + onSuccess: (response) => { + console.log(response) + }, + onError: (err) => { + console.log(err) + }, + }) + + const getAlertMessage = (isCodeSame: boolean | null, codeChecked: boolean | null) => { + if (isCodeSame === null && codeChecked === null) { + return { message: '닉네임 중복검사를 해주세요!', color: palette.RED } + } else if (isCodeSame === false && codeChecked) { + return { message: '사용 가능한 닉네임입니다.', color: palette.PRIMARY } + } else if (isCodeSame === true && codeChecked) { + return { message: '이미 사용 중인 닉네임입니다.', color: palette.RED } + } else { + return null // 혹은 기본 메시지 객체를 반환 + } + } + + const alertInfo = getAlertMessage(isCodeSame, codeChecked) + + //이메일 인증 버튼 누르면 실행되는 함수 + const handleEmailCertification = async () => { + emailRef.current && emailVerifyMutation.mutate(emailRef.current.value) + } + + //인증 코드 입력하고 확인 버튼 누르면 실행되는 함수 + const checkEmailCode = async () => { + setCodeChecked(true) + const response = await axiosAPI.post('/v1/certification/users/me/company-mail/verification', { + verificationCode: codeRef.current && codeRef.current.value, + }) + if (response.status == 200) setIsCodeSame(true) + //이 부분 코드 다시 짜야함 + else console.log('인증 코드 불일치') + } + + const submitUserCompanyData = () => { + console.log(formData) + //다 체크 됐나 확인하고 + if (!codeChecked) { + showToast({ + message: '이메일 인증을 해주세요 ', + type: 'warning', + isDarkMode, + }) + return + } else if (!isCodeSame) { + showToast({ + message: '인증코드가 일치하지 않습니다. ', + type: 'warning', + isDarkMode, + }) + return + } + companyName.current && formData.append('companyName', companyName.current.value) + emailRef.current && formData.append('companyEmail', emailRef.current.value) + formData.append('department', JSON.stringify(interestList)) + + // const body = { + // companyName: companyName.current && companyName.current.value, + // companyEmail: emailRef.current && emailRef.current.value, + // department: interestList, + // businessCard: '', + // } + registerCompanyData(formData) + // registerCompanyMutation.mutate(formData) + } + + const registerCompanyData = async (body: object) => { + console.log(body) + await axiosAPI.post('/v1/certification/users/me/company-info', body, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }) + } + // const registerCompanyMutation = useMutation((body: object) => registerCompanyData(body), { + // onSuccess: (response) => { + // console.log(response) + // navigate('/') + // }, + // onError: () => { + // showToast({ + // message: '회사 정보 등록에 실패했습니다.', + // type: 'error', + // isDarkMode: false, + // }) + // }, + // }) + const handleImageChange = () => { + if (imgRef.current && imgRef.current?.files) { + if (!imgRef.current.files[0]) return + console.log(imgRef.current?.files[0]) + formData.append('businessCard', imgRef.current?.files[0]) + console.log(formData) + const url = URL.createObjectURL(imgRef.current?.files[0]) + setUploadedURL(url) + } + } + const handleClickUpload = () => { + if (!imgRef.current) return + imgRef.current.click() + } + + return ( + + + + + + { + navigate('/register/user') + }} + /> + + {'회사 인증'} + + + + + {/* */} + + + + + + + + + + + handleEmailCertification()} + > + {'이메일 인증'} + + + + + {alertInfo ? ( + + {alertInfo.message} + + ) : ( + + )} + + + checkEmailCode()}> + {'확인'} + + + {alertInfo && ( + + {alertInfo.message} + + )} + + {'직무정보'} + + + + + + + {'명함을 업로드 해주세요!'} + + {uploadedURL ? ( + {'사용자가 + ) : ( + '+' + )} + + + + + + + + {'등록 완료'} + + + + + ) } +const StyleRegisterWrapper = styled.div` + background-color: ${palette.GRAY100}; + height: 100%; + overflow: scroll; +` +const StyleDataWrapper = styled.div`` +const StyleImageCard = styled.button` + width: 250px; + height: 150px; + background: ${palette.WHITE}; + border: 1px dashed ${palette.GRAY600}; + border-radius: 10px; + display: flex; + flex-direction: column; + justify-content: space-around; + align-items: center; + /* @media (max-width: 786px) { + width: 90vw; + height: 50vh; + } */ +` +const StyleRegisterHeader = styled.div`` +const StyleHeaderText = styled.span` + font-size: ${typo.Body_24()}; +` +const StyleDivider = styled.hr` + height: 1px; + background-color: ${palette.GRAY200}; + border: 0; +` +const StyleInterestText = styled.div` + padding: 10px; + margin-left: 25px; + font-size: ${typo.Body_18()}; +` +const StyleSubmitButtonWrapper = styled.div` + display: flex; + width: 100%; + justify-content: center; + position: relative; +` +const StyleText = styled.div` + font-size: ${typo.Body_12()}; + margin: 10px; +` +const StyleIcon = styled.button` + cursor: pointer; +` +const StyleVerificationEmailButton = styled.button` + width: 42px; + height: 25px; + background-color: ${palette.TERTIARY}; + position: absolute; + right: 30px; + color: ${palette.WHITE}; + border-radius: 10px; + font-size: 12px; + font-family: 'Pretendard-Regular'; + letter-spacing: -1px; + box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.15); +` export default RegisterCompany diff --git a/src/pages/register/RegisterUser.tsx b/src/pages/register/RegisterUser.tsx index 238f0c02..4b75d38a 100644 --- a/src/pages/register/RegisterUser.tsx +++ b/src/pages/register/RegisterUser.tsx @@ -1,6 +1,6 @@ import styled from '@emotion/styled' import { useMutation } from '@tanstack/react-query' -import { useRef, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { MdWbSunny } from 'react-icons/md' import { useNavigate } from 'react-router-dom' import { useLocation } from 'react-router-dom' @@ -45,6 +45,31 @@ const RegisterUser = () => { const { provider } = useAuthStore() const { showToast } = useToast() const isDarkMode = useThemeStore((state) => state.isDarkMode) + const setToken = useAuthStore((state) => state.setAuthTokens) + + const routeAuthInfo = async () => { + await axiosAPI + .get(`/v1/users/login/${provider}?authCode=${authCode}`) + .then((res) => { + console.log(res.data.accessToken) + localStorage.setItem('jwt', res.data.accessToken) + localStorage.setItem('nickname', res.data.nickname) + + setToken({ + accessToken: res.data.accessToken, + refreshToken: res.data.refreshToken, + }) + }) + .catch((err) => { + if (err.response.status === 404) { + navigate('/register/user', { state: { authCode } }) + console.log('실패패패') + } + }) + } + useEffect(() => { + routeAuthInfo() + }, []) const getNicknameValid = async (nickname: string) => { return await axiosAPI.get(`/v1/users/duplicate?nickname=${nickname}`) @@ -125,6 +150,8 @@ const RegisterUser = () => { const registerMutation = useMutation((body: object) => registerPost(body), { onSuccess: (response) => { console.log(response) + console.log(response.data.accessToken) + localStorage.setItem('jwt', response.data.accessToken) showToast({ message: '닉네임, 관심사 정보 등록을 완료했습니다!', type: 'success',