From 6b0f5588d9ee3da70cd454bf3d0a95b0f7483358 Mon Sep 17 00:00:00 2001 From: devGEP Date: Fri, 6 Oct 2023 03:55:49 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refact:=20=EB=B0=B1=EC=97=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=20=EC=88=98=EC=A0=95(Post,?= =?UTF-8?q?=20Dto,=20Lookbook,=20Enum=20=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api-instance.ts | 2 + src/assets/data/rainfallType.ts | 32 ++++++------- src/assets/data/token.ts | 1 + src/assets/data/weatherSky.ts | 16 +++---- src/components/AddFashion/AddFashion.tsx | 15 ++++-- .../AddFashion/AddFashion/AddImage.tsx | 2 + .../LookbookDetailLayout/LookbookListBox.tsx | 4 +- .../LookbookLayout/AddLookbookButton.tsx | 7 ++- .../Lookbook/LookbookLayout/LookbookBox.tsx | 4 +- src/components/MainLayout/FashionListBox.tsx | 20 ++++---- .../FashionListBox/FashionDetailModal.tsx | 11 +++-- .../FashionListBox/LookbookPopover.tsx | 4 +- .../MainLayout/FashionListBox/SearchBox.tsx | 48 +++++++++---------- src/components/MainLayout/InfoBox.tsx | 2 + .../MainLayout/InfoBox/WeatherBox.tsx | 8 ++-- src/components/MyLayout/MyPostBox.tsx | 4 +- src/utils/Recoil.tsx | 42 ++++------------ src/utils/types.ts | 16 +++---- 18 files changed, 123 insertions(+), 115 deletions(-) create mode 100644 src/assets/data/token.ts diff --git a/src/api/api-instance.ts b/src/api/api-instance.ts index f309dc6..874fb54 100644 --- a/src/api/api-instance.ts +++ b/src/api/api-instance.ts @@ -1,9 +1,11 @@ import axios from 'axios'; +import {token} from 'src/assets/data/token'; const apiV1Instance = axios.create({ baseURL: 'http://localhost:8080/api/v1', headers: { 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` }, }); diff --git a/src/assets/data/rainfallType.ts b/src/assets/data/rainfallType.ts index a5e95e5..0800292 100644 --- a/src/assets/data/rainfallType.ts +++ b/src/assets/data/rainfallType.ts @@ -1,27 +1,27 @@ -export default function rainfallType(type: number | undefined): string { - let rainType = 'Clear'; +export default function rainfallType(type: string | undefined): string { + let rainType = 'NONE'; switch(type) { - case 0: - rainType = 'Clear' + case 'CLEAR': + rainType = 'CLEAR' break; - case 1: - rainType = 'Rain'; + case 'RAIN': + rainType = 'RAIN'; break; - case 2: - rainType = 'Rain/Snow'; + case 'RAIN_SNOW': + rainType = 'RAIN_SNOW'; break; - case 3: - rainType = 'Snow'; + case 'SNOW': + rainType = 'SNOW'; break; - case 5: - rainType = 'Raindrop'; + case 'RAINDROP': + rainType = 'RAINDROP'; break; - case 6: - rainType = 'Raindrop/Snow'; + case 'RAINDROP_FLURRY': + rainType = 'RAINDROP_FLURRY'; break; - case 7: - rainType = 'Snow'; + case 'FLURRY': + rainType = 'FLURRY'; break; } diff --git a/src/assets/data/token.ts b/src/assets/data/token.ts new file mode 100644 index 0000000..e069c75 --- /dev/null +++ b/src/assets/data/token.ts @@ -0,0 +1 @@ +export const token = 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdHJpbmdAZ21haWwuY29tIiwiYXV0aCI6IlVTRVIiLCJpYXQiOjE2OTY1MzExOTYsImV4cCI6MTY5NjUzNDc5Nn0.mDxSTbcuvDkkXldaILl26tkxPSBsH4XBA9Kuqvu1vztzlWFMj3GzejkDFuv6e700IlIKb-Ex3f6bxYLbZ9dVdQ'; \ No newline at end of file diff --git a/src/assets/data/weatherSky.ts b/src/assets/data/weatherSky.ts index 94ca4da..f0ff8d6 100644 --- a/src/assets/data/weatherSky.ts +++ b/src/assets/data/weatherSky.ts @@ -1,15 +1,15 @@ -export default function weatherSky(sky: number | undefined) { - let skyName = 'Clear'; +export default function weatherSky(sky: string | undefined) { + let skyName = 'NONE'; switch(sky) { - case 1: - skyName = 'Clear'; + case 'SUNNY': + skyName = 'SUNNY'; break; - case 3: - skyName = 'Cloudy'; + case 'CLOUDY': + skyName = 'CLOUDY'; break; - case 4: - skyName = 'Overcast'; + case 'OVERCAST': + skyName = 'OVERCAST'; break; } diff --git a/src/components/AddFashion/AddFashion.tsx b/src/components/AddFashion/AddFashion.tsx index 737af71..1cf7c22 100644 --- a/src/components/AddFashion/AddFashion.tsx +++ b/src/components/AddFashion/AddFashion.tsx @@ -2,6 +2,9 @@ import { Box, Button, Divider, Grid, Typography } from '@mui/material'; import axios from 'axios'; import React, { useState } from 'react'; import { useRecoilValue } from 'recoil'; +import rainfallType from 'src/assets/data/rainfallType'; +import {token} from 'src/assets/data/token'; +import weatherSky from 'src/assets/data/weatherSky'; import { WeatherType } from 'src/utils/types'; import { weatherDataState } from '../../utils/Recoil'; @@ -11,6 +14,7 @@ import AddReview from './AddFashion/AddReview'; import AddTitle from './AddFashion/AddTitle'; import AddWeatherInfo from './AddFashion/AddWeatherInfo'; + export default function AddFashion() { const [postTitle, setPostTitle] = useState(''); const [postImage, setPostImage] = React.useState(''); @@ -45,14 +49,17 @@ export default function AddFashion() { try { await axios .post('/api/v1/posts', { - userId: '550e8400-e29b-41d4-a716-446655440000', - name: postTitle, + title: postTitle, image: postImage, review: postReview, temperature: weatherData.temperature, - skyStatus: weatherData.sky, - rainfallType: weatherData.rainfallType, + skyStatus: weatherSky(weatherData.sky), + rainfallType: rainfallType(weatherData.rainfallType), windSpeed: weatherData.windSpeed, + }, { + headers: { + Authorization: `Bearer ${token}` + }, }) .then((response) => { console.log(response); diff --git a/src/components/AddFashion/AddFashion/AddImage.tsx b/src/components/AddFashion/AddFashion/AddImage.tsx index e529733..a0dd5cc 100644 --- a/src/components/AddFashion/AddFashion/AddImage.tsx +++ b/src/components/AddFashion/AddFashion/AddImage.tsx @@ -6,6 +6,7 @@ import axios from 'axios'; import { useState } from 'react'; import Resizer from 'react-image-file-resizer'; import { toast, ToastContainer } from 'react-toastify'; +import {token} from 'src/assets/data/token'; type ImageProps = { getImageData: (data: string) => void; @@ -69,6 +70,7 @@ export default function AddImage({ getImageData }: ImageProps) { .post('/api/v1/images', formData, { headers: { 'Content-Type': 'multipart/form-data', + Authorization: `Bearer ${token}` }, }) .then((response) => { diff --git a/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx b/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx index ab34adc..d704a75 100644 --- a/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx +++ b/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx @@ -124,7 +124,7 @@ export default function LookbookListBox() { }} > - {item.name} + {item.title} @@ -169,7 +169,7 @@ export default function LookbookListBox() { {lookbook.length > 0 && ( {lookbook[currentImageIndex].name} )} diff --git a/src/components/Lookbook/LookbookLayout/AddLookbookButton.tsx b/src/components/Lookbook/LookbookLayout/AddLookbookButton.tsx index d20a962..65eb0b1 100644 --- a/src/components/Lookbook/LookbookLayout/AddLookbookButton.tsx +++ b/src/components/Lookbook/LookbookLayout/AddLookbookButton.tsx @@ -12,6 +12,7 @@ import { } from '@mui/material'; import axios from 'axios'; import { useState } from 'react'; +import { token } from 'src/assets/data/token'; // import SearchIcon from '@mui/icons-material/Search'; import AddImage from '../../../components/AddFashion/AddFashion/AddImage'; @@ -54,10 +55,14 @@ export default function AddLookbookButton() { try { await axios - .post('/api/v1/books', { + .post('/api/v1/lookbooks', { userId: '550e8400-e29b-41d4-a716-446655440000', title: title, image: postImage, + }, { + headers: { + Authorization: `Bearer ${token}` + }, }) .then((response) => { console.log(response); diff --git a/src/components/Lookbook/LookbookLayout/LookbookBox.tsx b/src/components/Lookbook/LookbookLayout/LookbookBox.tsx index 7e65dd6..a5e9d94 100644 --- a/src/components/Lookbook/LookbookLayout/LookbookBox.tsx +++ b/src/components/Lookbook/LookbookLayout/LookbookBox.tsx @@ -3,6 +3,7 @@ import axios from 'axios'; import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useRecoilValue, useSetRecoilState } from 'recoil'; +import { token } from 'src/assets/data/token'; import { lookbookNameState, userIdState } from '../../../utils/Recoil'; import { LookBookBoxType } from '../../../utils/types'; @@ -17,9 +18,10 @@ export default function LookbookBox() { const lookbookListAPI = async () => { try { await axios - .get(`/api/v1/books/${userId}`, { + .get(`/api/v1/lookbooks/${userId}`, { headers: { Accept: 'application/json', + Authorization: `Bearer ${token}` }, }) .then((response) => { diff --git a/src/components/MainLayout/FashionListBox.tsx b/src/components/MainLayout/FashionListBox.tsx index 061e54e..b4e01a3 100644 --- a/src/components/MainLayout/FashionListBox.tsx +++ b/src/components/MainLayout/FashionListBox.tsx @@ -12,12 +12,13 @@ import { import axios from 'axios'; import React, { useEffect, useState } from 'react'; import { useRecoilState, useRecoilValue } from 'recoil'; +import {token} from 'src/assets/data/token'; import { currentPageState, fullPageState, - rainfallCodeState, - skyCodeState, + rainfallTypeState, + skyStatusState, windChillState, } from '../../utils/Recoil'; import { WeatherPostType } from '../../utils/types'; @@ -51,8 +52,8 @@ export default function FashionListBox() { const handleOpenDetail = () => setOpenDetail(true); const handleCloseDetail = () => setOpenDetail(false); - const skyCode = useRecoilValue(skyCodeState); - const rainfallCode = useRecoilValue(rainfallCodeState); + const skyStatus = useRecoilValue(skyStatusState); + const rainfallType = useRecoilValue(rainfallTypeState); const windChill = useRecoilValue(windChillState); const [pageCount, setPageCount] = useRecoilState(fullPageState); // 전체 페이지 @@ -73,16 +74,17 @@ export default function FashionListBox() { }; const fashionAPI = async () => { - console.log('[Recoil] skyCode: ', skyCode); - console.log('[Recoil] rainfallCode: ', rainfallCode); + console.log('[Recoil] skyCode: ', skyStatus); + console.log('[Recoil] rainfallCode: ', rainfallType); console.log('[Recoil] windChill: ', windChill); try { await axios .get( - `/api/v1/posts/weather?skyCode=${skyCode}&rainfallCode=${rainfallCode}&windChill=${windChill}`, + `/api/v1/posts/weather?skyStatus=${skyStatus}&rainfallType=${rainfallType}&windChill=${windChill}`, { headers: { Accept: 'application/json', + Authorization: `Bearer ${token}` }, } ) @@ -175,7 +177,7 @@ export default function FashionListBox() { }} > - {fashion[index].name} + {fashion[index].title} @@ -191,7 +193,7 @@ export default function FashionListBox() { useEffect(() => { fashionAPI(); - }, [skyCode, rainfallCode, windChill]); + }, [skyStatus, rainfallType, windChill]); return ( diff --git a/src/components/MainLayout/FashionListBox/FashionDetailModal.tsx b/src/components/MainLayout/FashionListBox/FashionDetailModal.tsx index 1360ae2..6b1db56 100644 --- a/src/components/MainLayout/FashionListBox/FashionDetailModal.tsx +++ b/src/components/MainLayout/FashionListBox/FashionDetailModal.tsx @@ -19,6 +19,7 @@ import { import axios from 'axios'; import { useEffect, useState } from 'react'; import { toast } from 'react-toastify'; +import { token } from 'src/assets/data/token'; import rainfallType from '../../../assets/data/rainfallType'; import weatherSky from '../../../assets/data/weatherSky'; @@ -61,6 +62,7 @@ export default function FashioinDetailModal({ singleId }: FashionDetailProps) { .get(`/api/v1/posts/${singleId}`, { headers: { Accept: 'application/json', + Authorization: `Bearer ${token}` }, }) .then((response) => { @@ -76,9 +78,10 @@ export default function FashioinDetailModal({ singleId }: FashionDetailProps) { const lookbookPostAPI = async (lookbookId: string) => { try { await axios - .post(`/api/v1/books/posts`, { - lookBookId: lookbookId, - postId: singleId, + .post(`/api/v1/lookbooks/posts/${lookbookId}?postId=${singleId}`, {}, { + headers: { + Authorization: `Bearer ${token}` + }, }) .then((response) => { console.log(response); @@ -130,7 +133,7 @@ export default function FashioinDetailModal({ singleId }: FashionDetailProps) { fontSize="20pt" sx={{ mt: 0.5, ml: 6 }} > - {singleData.name} + {singleData.title} { try { await axios - .get(`/api/v1/books/${userId}`, { + .get(`/api/v1/lookbooks/${userId}`, { headers: { Accept: 'application/json', + Authorization: `Bearer ${token}` }, }) .then((response) => { diff --git a/src/components/MainLayout/FashionListBox/SearchBox.tsx b/src/components/MainLayout/FashionListBox/SearchBox.tsx index 2682bee..4a562b0 100644 --- a/src/components/MainLayout/FashionListBox/SearchBox.tsx +++ b/src/components/MainLayout/FashionListBox/SearchBox.tsx @@ -27,8 +27,8 @@ import { useRecoilState, useRecoilValue } from 'recoil'; import { useFindAllWeathers } from 'src/api/hook/WeatherHook'; import { - rainfallCodeState, - skyCodeState, + rainfallTypeState, + skyStatusState, weatherDataState, windChillState, } from '../../../utils/Recoil'; @@ -86,7 +86,7 @@ const PrettoSlider = styled(Slider)({ }); export default function SearchBox() { - const [isLoading, setIsLoading] = useState(true); + const [isLoading, setIsLoading] = useState(false); const weatherData = useRecoilValue(weatherDataState); @@ -103,8 +103,8 @@ export default function SearchBox() { const [openSlider, setOpenSlider] = useState(false); const [placementSlider, setPlacementSlider] = useState(); - const [skyCode, setSkyCode] = useRecoilState(skyCodeState); - const [rainfallCode, setRainfallCode] = useRecoilState(rainfallCodeState); + const [skyStatus, setSkyStatus] = useRecoilState(skyStatusState); + const [rainfallType, setRainfallType] = useRecoilState(rainfallTypeState); const [windChill, setWindChill] = useRecoilState(windChillState); const [snowState, setSnowState] = useState(false); @@ -142,20 +142,20 @@ export default function SearchBox() { const { data: windChillData } = useFindAllWeathers(); - function searchSky(skyCode: number, rainfallCode: number) { + function searchSky(skyStatus: string, rainfallType: string) { let index = 0; - // console.log('[searchSky] skyCode: ', skyCode); + // console.log('[searchSky] skyStatus: ', skyStatus); // console.log('[searchSky] rainfallCode: ', rainfallCode); - if (skyCode === 1 && rainfallCode === 0) { + if (skyStatus === 'SUNNY' && rainfallType === 'NONE') { index = 0; - } else if ((skyCode === 3 || skyCode === 4) && rainfallCode === 0) { + } else if ((skyStatus === 'CLOUDY' || skyStatus === 'OVERCAST') && rainfallType === 'NONE') { index = 1; - } else if (skyCode === 0 && (rainfallCode === 1 || rainfallCode === 5)) { + } else if (skyStatus === 'NONE' && (rainfallType === 'CLEAR' || rainfallType === 'RAINDROP')) { index = 2; - } else if (skyCode === 0 && (rainfallCode === 2 || rainfallCode === 6)) { + } else if (skyStatus === 'NONE' && (rainfallType === 'RAIN' || rainfallType === 'RAINDROP_FLURRY')) { index = 3; - } else if (skyCode === 0 && (rainfallCode === 3 || rainfallCode === 7)) { + } else if (skyStatus === 'NONE' && (rainfallType === 'SNOW' || rainfallType === 'FLURRY')) { index = 4; } @@ -169,31 +169,31 @@ export default function SearchBox() { // setWindChill(windChillData?.data?.windChill); // } - searchSky(skyCode, rainfallCode); - }, [skyCode, rainfallCode, windChillData]); + searchSky(skyStatus, rainfallType); + }, [skyStatus, rainfallType, windChillData]); function getSkyData(data: string) { console.log('data: ', data); if (data === 'Sunny') { - setSkyCode(1); - setRainfallCode(0); + setSkyStatus('SUNNY'); + setRainfallType('NONE'); setSnowState(false); } else if (data === 'Cloudy') { - setSkyCode(3); - setRainfallCode(0); + setSkyStatus('CLOUDY'); + setRainfallType('NONE'); setSnowState(false); } else if (data === 'Rain') { - setSkyCode(0); - setRainfallCode(1); + setSkyStatus('NONE'); + setRainfallType('CLEAR'); setSnowState(false); } else if (data === 'Rain & Snow') { - setSkyCode(0); - setRainfallCode(2); + setSkyStatus('NONE'); + setRainfallType('RAIN'); setSnowState(true); } else if (data === 'Snow') { - setSkyCode(0); - setRainfallCode(7); + setSkyStatus('NONE'); + setRainfallType('FLURRY'); setSnowState(false); } } diff --git a/src/components/MainLayout/InfoBox.tsx b/src/components/MainLayout/InfoBox.tsx index 7c52ea9..499c1b2 100644 --- a/src/components/MainLayout/InfoBox.tsx +++ b/src/components/MainLayout/InfoBox.tsx @@ -3,6 +3,7 @@ import axios from 'axios'; import { useEffect } from 'react'; import { useSetRecoilState } from 'recoil'; import { useFindAllWeathers } from 'src/api/hook/WeatherHook'; +import {token} from 'src/assets/data/token'; import useGeoLocation from '../../assets/hooks/useGeoLocation'; import { locationDataState, weatherDataState } from '../../utils/Recoil'; @@ -27,6 +28,7 @@ export default function InfoBox() { .get(`/api/v1/address?latitude=${latitude}&longitude=${longitude}`, { headers: { Accept: 'application/json', + Authorization: `Bearer ${token}` }, }) .then((response) => { diff --git a/src/components/MainLayout/InfoBox/WeatherBox.tsx b/src/components/MainLayout/InfoBox/WeatherBox.tsx index 310df43..573d60d 100644 --- a/src/components/MainLayout/InfoBox/WeatherBox.tsx +++ b/src/components/MainLayout/InfoBox/WeatherBox.tsx @@ -17,13 +17,13 @@ type WeatherProps = { const WeatherSkyLottie = ({ weatherData }: WeatherProps) => { // weatherData에 따라 다른 애니메이션 데이터를 선택 const getAnimationData = () => { - if (weatherData?.sky === 1) { + if (weatherData?.sky === 'SUNNY') { return require('../../../assets/lotties/weather/sunny.json'); - } else if (weatherData?.sky === 3) { + } else if (weatherData?.sky === 'CLOUDY') { return require('../../../assets/lotties/weather/cloudy.json'); - } else if (weatherData?.sky === 4) { + } else if (weatherData?.sky === 'OVERCAST') { return require('../../../assets/lotties/weather/rainy.json'); - } else if (weatherData?.sky === 5) { + } else if (weatherData?.sky === 'SNOWY') { return require('../../../assets/lotties/weather/snow.json'); } // 기본값으로 사용할 애니메이션 데이터 diff --git a/src/components/MyLayout/MyPostBox.tsx b/src/components/MyLayout/MyPostBox.tsx index ce14176..f5f8040 100644 --- a/src/components/MyLayout/MyPostBox.tsx +++ b/src/components/MyLayout/MyPostBox.tsx @@ -2,6 +2,7 @@ import { Box, Card, CardMedia, Grid, Typography } from '@mui/material'; import axios from 'axios'; import { useEffect, useState } from 'react'; import { useRecoilValue } from 'recoil'; +import { token } from 'src/assets/data/token'; import { userIdState } from '../../utils/Recoil'; import { UserPostListType } from '../../utils/types'; @@ -34,6 +35,7 @@ export default function MyPostBox() { .get(`/api/v1/posts/user/${userId}`, { headers: { Accept: 'application/json', + Authorization: `Bearer ${token}` }, }) .then((response) => { @@ -94,7 +96,7 @@ export default function MyPostBox() { }} > - {postList.name} + {postList.title} diff --git a/src/utils/Recoil.tsx b/src/utils/Recoil.tsx index fb2566d..c3c59e9 100644 --- a/src/utils/Recoil.tsx +++ b/src/utils/Recoil.tsx @@ -5,9 +5,9 @@ import { LocationType, WeatherType } from './types'; const { persistAtom } = recoilPersist(); -export const userIdState = atom({ +export const userIdState = atom({ key: 'userIdState', - default: '550e8400-e29b-41d4-a716-446655440000', + default: 2, effects_UNSTABLE: [persistAtom], }); @@ -21,35 +21,13 @@ export const longitudeState = atom({ default: 0, }); -// FashionList, SearchBox -// export const skyCodeState = selector({ -// key: 'skyCodeState', -// get: async ({ get }) => { -// const latitude = get(latitudeState); -// const longitude = get(longitudeState); - -// if(latitude && longitude) { -// try{ -// const response = await axios.get(`/api/v1/weather?latitude=${latitude}&longitude=${longitude}`, { -// headers: { -// Accept: 'application/json' -// }, -// withCredentials: true -// }); -// return response.data.data?.sky; -// } catch(error) { -// throw error; -// } -// } -// } -// }) -export const skyCodeState = atom({ - key: 'skyCodeState', - default: 1, +export const skyStatusState = atom({ + key: 'skyStatusState', + default: 'NONE', }); -export const rainfallCodeState = atom({ - key: 'rainfallCodeState', - default: 0, +export const rainfallTypeState = atom({ + key: 'rainfallTypeState', + default: 'NONE', }); export const windChillState = atom({ key: 'windChillState', @@ -74,11 +52,11 @@ export const menuState = atom({ // InfoBox에서 Weather Data const initialWeatherInfo: WeatherType = { - sky: 1, + sky: 'SUNNY', temperature: 0, hourRainfall: 0, humidity: 0, - rainfallType: 0, + rainfallType: 'NONE', windSpeed: 0, windChill: 0, }; diff --git a/src/utils/types.ts b/src/utils/types.ts index 2aec6b2..b39c718 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,11 +1,11 @@ export type SinglePostType = { id: string; userId: string; - name: string; + title: string; image: string; review: string; - skyStatus: number; - rainfallType: number; + skyStatus: string; + rainfallType: string; windChill: number; createdAt: string; updatedAt: string; @@ -13,11 +13,11 @@ export type SinglePostType = { } export type WeatherType = { - sky: number; + sky: string; temperature: number; hourRainfall: number; humidity: number; - rainfallType: number; + rainfallType: string; windSpeed: number; windChill: number; } @@ -31,13 +31,13 @@ export type LocationType = { export type WeatherPostType = { id: string; - name: string; + title: string; imageUrl: string; }; export type LookBookListType = { id: string; - name: string; + title: string; image: string; userId: string; }; @@ -53,7 +53,7 @@ export type LookBookBoxType = { export type UserPostListType = { id: string; userId: string; - name: string; + title: string; image: string; review: string; skyStatus: number; From 91389deae7973fd9cb4bb1297ddc9d2a902f65e6 Mon Sep 17 00:00:00 2001 From: devGEP Date: Sat, 7 Oct 2023 20:24:25 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20API=20=EC=A3=BC=EC=86=8C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=82=B4=20=EC=A1=B0=ED=9A=8C=20API)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/data/token.ts | 2 +- .../LookbookDetailLayout/LookbookListBox.tsx | 2 +- src/components/MyLayout/MyPostBox.tsx | 34 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/assets/data/token.ts b/src/assets/data/token.ts index e069c75..c7359ca 100644 --- a/src/assets/data/token.ts +++ b/src/assets/data/token.ts @@ -1 +1 @@ -export const token = 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdHJpbmdAZ21haWwuY29tIiwiYXV0aCI6IlVTRVIiLCJpYXQiOjE2OTY1MzExOTYsImV4cCI6MTY5NjUzNDc5Nn0.mDxSTbcuvDkkXldaILl26tkxPSBsH4XBA9Kuqvu1vztzlWFMj3GzejkDFuv6e700IlIKb-Ex3f6bxYLbZ9dVdQ'; \ No newline at end of file +export const token = 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdHJpbmdAZ21haWwuY29tIiwiYXV0aCI6IlVTRVIiLCJpYXQiOjE2OTY2MTcwODMsImV4cCI6MTY5NjYyMDY4M30.DcBvR_9haP6RzqETEHD4gFnlqa3094k370KMtjKmP0PFeiJ-MxzihImLS0P_HqUn4F3C1iiyIt983J6jnDEXGw'; \ No newline at end of file diff --git a/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx b/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx index d704a75..7ccab12 100644 --- a/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx +++ b/src/components/Lookbook/LookbookDetailLayout/LookbookListBox.tsx @@ -40,7 +40,7 @@ export default function LookbookListBox() { try { await axios - .get(`/api/v1/books/posts/${id}`, { + .get(`/api/v1/lookbooks/${id}`, { headers: { Accept: 'application/json', }, diff --git a/src/components/MyLayout/MyPostBox.tsx b/src/components/MyLayout/MyPostBox.tsx index f5f8040..0c76835 100644 --- a/src/components/MyLayout/MyPostBox.tsx +++ b/src/components/MyLayout/MyPostBox.tsx @@ -7,32 +7,32 @@ import { token } from 'src/assets/data/token'; import { userIdState } from '../../utils/Recoil'; import { UserPostListType } from '../../utils/types'; -const style = { - position: 'absolute', - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - height: 600, - width: 400, - bgcolor: '#FFF', - borderRadius: '25px', - boxShadow: 24, - p: 2, -}; +// const style = { +// position: 'absolute', +// top: '50%', +// left: '50%', +// transform: 'translate(-50%, -50%)', +// height: 600, +// width: 400, +// bgcolor: '#FFF', +// borderRadius: '25px', +// boxShadow: 24, +// p: 2, +// }; export default function MyPostBox() { const userId = useRecoilValue(userIdState); const [postList, setPostList] = useState([]); - const [singleId, setSingleId] = useState(''); - const [openDetail, setOpenDetail] = useState(false); + // const [singleId, setSingleId] = useState(''); + // const [openDetail, setOpenDetail] = useState(false); - const handleOpenDetail = () => setOpenDetail(true); - const handleCloseDetail = () => setOpenDetail(false); + // const handleOpenDetail = () => setOpenDetail(true); + // const handleCloseDetail = () => setOpenDetail(false); const userPostListAPI = async () => { try { await axios - .get(`/api/v1/posts/user/${userId}`, { + .get(`/api/v1/posts/users/${userId}`, { headers: { Accept: 'application/json', Authorization: `Bearer ${token}`