Commit ab2a8d78 authored by Kim, Subin's avatar Kim, Subin
Browse files

SearchResult Pagination 필요없음 -> 관련 기능 삭제

parent 4b0f9909
...@@ -18,6 +18,7 @@ const MovieEdit = () => { ...@@ -18,6 +18,7 @@ const MovieEdit = () => {
async function paginate(pageNum) { async function paginate(pageNum) {
try { try {
setError("")
const { TMDBmovies, totalPage } = (search.keyword !== '') ? await movieApi.search(search, pageNum) : await movieApi.getAllfromTM(pageNum) const { TMDBmovies, totalPage } = (search.keyword !== '') ? await movieApi.search(search, pageNum) : await movieApi.getAllfromTM(pageNum)
setActivePage(pageNum) setActivePage(pageNum)
setTotalPages(totalPage) setTotalPages(totalPage)
......
...@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react' ...@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'
import { useLocation } from 'react-router-dom' import { useLocation } from 'react-router-dom'
import queryString from 'query-string' import queryString from 'query-string'
import MovieCard from "./MovieCard/index.js" import MovieCard from "./MovieCard/index.js"
import Pagination from "./Pagination.js";
import movieApi from '../apis/movie.api.js' import movieApi from '../apis/movie.api.js'
import catchErrors from '../utils/catchErrors.js' import catchErrors from '../utils/catchErrors.js'
...@@ -18,8 +19,8 @@ const SearchResult = () => { ...@@ -18,8 +19,8 @@ const SearchResult = () => {
async function findforKeyword() { async function findforKeyword() {
try { try {
setError("") setError("")
const { count, results } = await movieApi.search({ type: "home", keyword: title }) const res = await movieApi.search({ type: "home", keyword: title })
setResult([...results]) setResult(res)
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
} }
......
...@@ -97,8 +97,6 @@ const getMovieById = async (req, res) => { ...@@ -97,8 +97,6 @@ const getMovieById = async (req, res) => {
} }
const getMovieList = async (req, res) => { const getMovieList = async (req, res) => {
const { category } = req.params
// console.log(category)
try { try {
const { category } = req.params const { category } = req.params
const movieList = await Movie.findAll() const movieList = await Movie.findAll()
...@@ -178,15 +176,15 @@ const findonlyTitle = async (req, res) => { ...@@ -178,15 +176,15 @@ const findonlyTitle = async (req, res) => {
try { try {
const { keyword } = req.query const { keyword } = req.query
const movieIds = [] const movieIds = []
const { count, rows } = await Movie.findAndCountAll({ const findAll = await Movie.findAll({
where: { where: {
title: { title: {
[Op.substring]: keyword [Op.substring]: keyword
} }
} }
}); });
if (rows) { if (findAll) {
rows.forEach(movie => movieIds.push(movie.movieId)) findAll.forEach(movie => movieIds.push(movie.movieId))
const elements = await Promise.all( const elements = await Promise.all(
movieIds.map(async (movieId) => { movieIds.map(async (movieId) => {
const movie = await axios.get(`https://api.themoviedb.org/3/movie/${movieId}?api_key=${process.env.TMDB_APP_KEY}&language=ko-KR`) const movie = await axios.get(`https://api.themoviedb.org/3/movie/${movieId}?api_key=${process.env.TMDB_APP_KEY}&language=ko-KR`)
...@@ -200,8 +198,8 @@ const findonlyTitle = async (req, res) => { ...@@ -200,8 +198,8 @@ const findonlyTitle = async (req, res) => {
return { ...movie.data, ticket_sales: cols.ticket_sales, vote_average: cols.vote_average, totalReservationRate: totalReservationRate[0] } return { ...movie.data, ticket_sales: cols.ticket_sales, vote_average: cols.vote_average, totalReservationRate: totalReservationRate[0] }
}) })
) )
return res.json({ count: movieIds.length, results: elements }) return res.json(elements)
} else return res.json({ count: count, results: rows }) } else return res.json(findAll)
} catch (error) { } catch (error) {
return res.status(500).send(error.message || "영화 검색 중 에러 발생"); return res.status(500).send(error.message || "영화 검색 중 에러 발생");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment