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

reservation

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