diff --git a/src/api/index.ts b/src/api/index.ts index 45866bd..7c676f5 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,6 +1,20 @@ import axios from 'axios'; -const api = axios.create({ baseURL: 'https://wayu.hackathon.sparcs.net/' }); +const api = axios.create({ + baseURL: 'https://wayu.hackathon.sparcs.net/', + paramsSerializer: (params) => { + const searchParams = new URLSearchParams(); + for (const key of Object.keys(params)) { + const param = params[key]; + if (Array.isArray(param)) { + searchParams.append(key, param.join(',')); + } else { + searchParams.append(key, param); + } + } + return searchParams.toString(); + }, +}); api.interceptors.request.use((config) => { const token = localStorage.getItem('accessToken'); diff --git a/src/pages/Videos.tsx b/src/pages/Videos.tsx index d9ea300..cbd7ebf 100644 --- a/src/pages/Videos.tsx +++ b/src/pages/Videos.tsx @@ -1,13 +1,12 @@ -import React from 'react'; +import { Swiper, SwiperSlide } from 'swiper/react'; +import 'swiper/css'; import Header from './component/Header'; -import { FaLocationArrow } from "react-icons/fa"; -import { Link } from 'react-router-dom'; -import Category from './component/Category'; -import Grade from './component/Grade'; -import Feel from './component/Feel'; -import Reviews from './component/Reviews'; import Menu from './component/Menu'; import Video from './component/Video'; +import { useNavigate, useParams } from 'react-router-dom'; +import { useQuery } from '@tanstack/react-query'; +import api from '../api'; +import { useEffect, useState } from 'react'; // type VideosProps = { // type: string; // profileImg: string; @@ -16,19 +15,46 @@ import Video from './component/Video'; // videoImg?: string; // followChk?: boolean; // videoUrl: string; -// Categorys: string[]; +// Categorys: string[]; // } export default function Videos() { - return ( -
-
-
- ); -} + const { id } = useParams(); + const { data, error } = useQuery({ + queryKey: [ + '/reviews', + { regions: ['서구', '중구', '유성구', '대덕구', '동구'] }, + ], + }); + + const navigate = useNavigate(); + + useEffect(() => { + if (id) return; + if (!data) return; + navigate(`/review/${data.data.list[0].id}`); + }, [data, id, navigate]); + const [activeIndex, setActiveIndex] = useState(0); + + return ( +
+
+ setActiveIndex(swiper.activeIndex)} + > + {data?.data.list.map((review, index) => ( + +
+
+
+ ))} +
+ +
+ ); +} diff --git a/src/pages/component/Header.tsx b/src/pages/component/Header.tsx index 217dd1d..9ff434c 100644 --- a/src/pages/component/Header.tsx +++ b/src/pages/component/Header.tsx @@ -11,6 +11,7 @@ type HeaderProps = { className?: string; border?: boolean; white?: boolean; + fixed?: boolean; }; const Header: React.FC = ({ @@ -22,6 +23,7 @@ const Header: React.FC = ({ setting, border, white, + fixed = false, }) => { const navigate = useNavigate(); @@ -31,7 +33,9 @@ const Header: React.FC = ({ return (
diff --git a/src/pages/component/Menu.tsx b/src/pages/component/Menu.tsx index bbbe791..07c9fa4 100644 --- a/src/pages/component/Menu.tsx +++ b/src/pages/component/Menu.tsx @@ -36,7 +36,7 @@ const Menu: React.FC = ({ home, map, video, mypage }) => {

지도

= ({ src, grade, name }) => { - const [isPlaying, setIsPlaying] = useState(true); +const Video = ({ user, place, tags, stars, likes, active }: VideoProps) => { + const videoEl = React.useRef(null); const handleVideoClick = () => { - setIsPlaying((prevState) => !prevState); - console.log(isPlaying); + if (videoEl.current) { + if (videoEl.current.paused) { + videoEl.current.play(); + } else { + videoEl.current.pause(); + } + } }; + useEffect(() => { + if (videoEl.current) { + if (active) { + videoEl.current.play(); + } else { + videoEl.current.pause(); + } + } + }, [active]); + return (
= ({ src, grade, name }) => { >
-
+
-
+
-

1235

+

{likes}

= ({ src, grade, name }) => {
- +
-

__A___D___

+

{user.nickname}

-

- 유성구 둔산동 백년식당 -

+

{place.name}

@@ -90,14 +109,13 @@ const Video: React.FC = ({ src, grade, name }) => { 유성구 둔산동에 위치한 백년식당입니다.
다양한 반찬을 즐길 수 있습니다.

- - #가족 - - - #맛집 - + {tags.map((tag) => ( + + {`#${tag}`} + + ))}
- + {/* */}
); }; diff --git a/src/routes/Router.tsx b/src/routes/Router.tsx index bf5d630..a6a241b 100644 --- a/src/routes/Router.tsx +++ b/src/routes/Router.tsx @@ -29,7 +29,8 @@ const Router = () => { } /> } /> } /> - } /> + } /> + } /> } /> } /> } /> diff --git a/tailwind.config.js b/tailwind.config.js index adf7702..ced24bc 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -13,7 +13,7 @@ export default { }, backgroundImage: { 'gradient-video': - 'linear-gradient(to top,rgba(0,0,0,.4) 0,rgba(0,0,0,0) 160px),linear-gradient(to bottom,rgba(0,0,0,.4) 0,rgba(0,0,0,0) 96px)', + 'linear-gradient(to top,rgba(0,0,0,.8) 120px,rgba(0,0,0,0) 260px),linear-gradient(to bottom,rgba(0,0,0,.4) 0,rgba(0,0,0,0) 96px)', }, height: { custom: 'calc(100vh - 60px)',