Commit 2846f9ac authored by Kim, Subin's avatar Kim, Subin
Browse files

TimeTable-if문 조건 변경&timetableCtrl-partTime수정완료

parent 4ed0613a
...@@ -62,7 +62,7 @@ const TimeTable = ({ ticketInfo = { movieId: 0 }, setTicketInfo }) => { ...@@ -62,7 +62,7 @@ const TimeTable = ({ ticketInfo = { movieId: 0 }, setTicketInfo }) => {
timeList.map(el => <div className="mt-4"> timeList.map(el => <div className="mt-4">
<h5 className="mb-0">{el.theaterName} / <p className="d-inline fs-6 mb-0">{el.theaterTypeName}</p></h5> <h5 className="mb-0">{el.theaterName} / <p className="d-inline fs-6 mb-0">{el.theaterTypeName}</p></h5>
{el.timetable.map(time => { {el.timetable.map(time => {
if (ticketInfo) if (ticketInfo.movieId !== 0)
return <div className="d-inline-flex m-2"> return <div className="d-inline-flex m-2">
<div className={`card text-dark ${styles.cursor}`} onClick={() => handleClick(time)}> <div className={`card text-dark ${styles.cursor}`} onClick={() => handleClick(time)}>
<div className="card-body py-1">{moment(time.start_time).format('HH:mm')} ~ {moment(time.end_time).format('HH:mm')}</div> <div className="card-body py-1">{moment(time.start_time).format('HH:mm')} ~ {moment(time.end_time).format('HH:mm')}</div>
......
...@@ -8,7 +8,7 @@ const getAll = async (req, res) => { ...@@ -8,7 +8,7 @@ const getAll = async (req, res) => {
const selectDate = new Date(when) const selectDate = new Date(when)
let findAll = null let findAll = null
const theaterArr = [] const theaterArr = []
findAll = movieId ? await TimeTable.findAll({ where: { date: selectDate, movieId: movieId }, attributes: { exclude: ['createdAt', 'updatedAt'] }, order: [["theaterId", "ASC"], ["start_time", "ASC"]], include: [Theater] }) findAll = movieId !== "0" ? await TimeTable.findAll({ where: { date: selectDate, movieId: movieId }, attributes: { exclude: ['createdAt', 'updatedAt'] }, order: [["theaterId", "ASC"], ["start_time", "ASC"]], include: [Theater] })
: await TimeTable.findAll({ where: { date: selectDate }, attributes: { exclude: ['createdAt', 'updatedAt'] }, order: [["theaterId", "ASC"], ["start_time", "ASC"]], include: [Theater] }) : await TimeTable.findAll({ where: { date: selectDate }, attributes: { exclude: ['createdAt', 'updatedAt'] }, order: [["theaterId", "ASC"], ["start_time", "ASC"]], include: [Theater] })
findAll.forEach(async (element) => { findAll.forEach(async (element) => {
if (!theaterArr.includes(element.theaterId)) theaterArr.push(element.theaterId) if (!theaterArr.includes(element.theaterId)) theaterArr.push(element.theaterId)
...@@ -65,9 +65,13 @@ const submit = async (req, res) => { ...@@ -65,9 +65,13 @@ const submit = async (req, res) => {
await Promise.all( await Promise.all(
theater.map(async (theater) => { theater.map(async (theater) => {
let partTime = "" let partTime = ""
if ('06:00' <= theater.start && theater.start < '10:00') partTime = "morning" if ('06:00' <= theater.start && theater.start < '10:00') {
else if ('00:00' <= theater.start < '06:00') partTime = "night" partTime = "morning"
else partTime = "day" } else if ('00:00' <= theater.start && theater.start < '06:00') {
partTime = "night"
} else {
partTime = "day"
}
await TimeTable.create({ theaterId: theater.theater, movieId, title, release_date, date: curDate, start_time: getTime(theater.start), end_time: getTime(theater.start, runtime), partTime: partTime, week: (day === 0 || day === 6) ? "weekend" : "weekdays" }) await TimeTable.create({ theaterId: theater.theater, movieId, title, release_date, date: curDate, start_time: getTime(theater.start), end_time: getTime(theater.start, runtime), partTime: partTime, week: (day === 0 || day === 6) ? "weekend" : "weekdays" })
}) })
) )
......
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