Commit 432e3eb3 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

reservation

parent bc3ee7b9
...@@ -53,14 +53,15 @@ const TheaterInfo = () => { ...@@ -53,14 +53,15 @@ const TheaterInfo = () => {
try { try {
const response = await cinemaApi.getCinemaInfo() const response = await cinemaApi.getCinemaInfo()
const response2 = await theaterApi.getAll() const response2 = await theaterApi.getAll()
setCinemaInfo({ ...response.data, theaterNum: response2.data.length }) setCinemaInfo({ ...response, theaterNum: response2.length })
setCurrentInfo({ setCurrentInfo({
name: "대중교통 안내", name: "대중교통 안내",
title: "transportation", title: "transportation",
information: response.data.transportation information: response.transportation
}) })
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
console.log(error)
} }
} }
......
...@@ -8,7 +8,12 @@ const TicketingTheater = ({ ticketInfo, cinemaInfo, setTicketInfo }) => { ...@@ -8,7 +8,12 @@ const TicketingTheater = ({ ticketInfo, cinemaInfo, setTicketInfo }) => {
return ( return (
<div className="d-grid gap-2"> <div className="d-grid gap-2">
{cinemaInfo
?
<button name={cinemaInfo.cinemaName} className={`${ticketInfo.cinema === cinemaInfo.cinemaName ? styles.on : styles.btn}`} onClick={handleClick}>{cinemaInfo.cinemaName}</button> <button name={cinemaInfo.cinemaName} className={`${ticketInfo.cinema === cinemaInfo.cinemaName ? styles.on : styles.btn}`} onClick={handleClick}>{cinemaInfo.cinemaName}</button>
:
<></>
}
</div> </div>
) )
} }
......
import axios from 'axios'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import axios from 'axios'
import moment from 'moment';
import { useAuth } from '../context/auth_context' import { useAuth } from '../context/auth_context'
import catchErrors from '../utils/catchErrors' import catchErrors from '../utils/catchErrors'
import reservationApi from '../apis/reservation.api' import reservationApi from '../apis/reservation.api'
...@@ -26,18 +27,18 @@ const PaymentCompletePage = () => { ...@@ -26,18 +27,18 @@ const PaymentCompletePage = () => {
try { try {
const response = await axios.get(`/api/auth/guestinfo/${user.id}`); const response = await axios.get(`/api/auth/guestinfo/${user.id}`);
const response2 = await reservationApi.findOneReservation() const response2 = await reservationApi.findOneReservation()
console.log("예매내역=====",response2) console.log("예매내역=====", response2)
// if (response.data||response2) { if (response.data || response2) {
// const responseEmail = await axios.post('/api/email/send', { const responseEmail = await axios.post('/api/email/send', {
// reservationData: response2, reservationData: response2.map(el => { return { "row": el.row, "col": el.col } }),
// userData: { ...response.data }, userData: { ...response.data },
// cinema: "Butter Studio 조치원", cinema: "Butter Studio 조치원",
// title: "더 수어사이드 스쿼드", title: response2[0].title,
// theater: "1", theater: response2[0].theater.theaterName,
// time: "2021/07/21 10:00" time: response2[0].timetable.date.split('T')[0] + ' ' + moment(response2[0].timetable.start_time).format('HH:mm')
// }) })
// console.log(responseEmail.data) console.log(responseEmail.data)
// } }
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
} }
......
...@@ -129,7 +129,6 @@ const Payment = ({ location }) => { ...@@ -129,7 +129,6 @@ const Payment = ({ location }) => {
return ( return (
<div className="container" style={{ color: "white" }}> <div className="container" style={{ color: "white" }}>
{console.log(ticketInfo)}
<div className="row justify-content-center my-5"> <div className="row justify-content-center my-5">
<div className="col-sm-4 "> <div className="col-sm-4 ">
<h3 className="py-2 text-white text-center" style={{ border: "3px solid #000000", borderBottom: "3px solid #FEDC00" }}>결제하기</h3> <h3 className="py-2 text-white text-center" style={{ border: "3px solid #000000", borderBottom: "3px solid #FEDC00" }}>결제하기</h3>
......
...@@ -10,6 +10,7 @@ import catchErrors from "../utils/catchErrors.js" ...@@ -10,6 +10,7 @@ import catchErrors from "../utils/catchErrors.js"
const TicketingPage = ({ location }) => { const TicketingPage = ({ location }) => {
const [ticketInfo, setTicketInfo] = useState({ const [ticketInfo, setTicketInfo] = useState({
movieId: 0,
...location.state, ...location.state,
cinema: "", cinema: "",
selectedTheater: 1, selectedTheater: 1,
...@@ -24,11 +25,9 @@ const TicketingPage = ({ location }) => { ...@@ -24,11 +25,9 @@ const TicketingPage = ({ location }) => {
}, []) }, [])
useEffect(() => { useEffect(() => {
getCinemaInfo() if (ticketInfo.movieId > 0) {
}, [])
useEffect(() => {
getMovieInfo() getMovieInfo()
}
}, [ticketInfo]) }, [ticketInfo])
async function getMovieInfo() { async function getMovieInfo() {
...@@ -54,7 +53,7 @@ const TicketingPage = ({ location }) => { ...@@ -54,7 +53,7 @@ const TicketingPage = ({ location }) => {
console.log(response.data) console.log(response.data)
setCinemaInfo(response.data) setCinemaInfo(response.data)
} catch (error) { } catch (error) {
console.log(error) catchErrors(error, setError)
} }
} }
return ( return (
......
...@@ -10,7 +10,7 @@ dotenv.config({ ...@@ -10,7 +10,7 @@ dotenv.config({
}); });
sequelize sequelize
.sync({ force: false }) .sync({ force: true })
.then(async () => { .then(async () => {
await Promise.all( await Promise.all(
Object.keys(ROLE_NAME).map((name) => { Object.keys(ROLE_NAME).map((name) => {
......
...@@ -11,6 +11,9 @@ const ReservationModel = (sequelize) => { ...@@ -11,6 +11,9 @@ const ReservationModel = (sequelize) => {
primaryKey: true, primaryKey: true,
autoIncrement: true, autoIncrement: true,
}, },
// reservationNum: {
// type: DataTypes.INTEGER,
// },
movieId: { movieId: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
}, },
...@@ -20,16 +23,16 @@ const ReservationModel = (sequelize) => { ...@@ -20,16 +23,16 @@ const ReservationModel = (sequelize) => {
col: { col: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
}, },
userType:{ userType: {
type: DataTypes.STRING, type: DataTypes.STRING,
}, },
user:{ user: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
}, },
payment:{ payment: {
type: DataTypes.STRING, type: DataTypes.STRING,
}, },
totalFee:{ totalFee: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
} }
}, },
......
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