Skip to content

Commit

Permalink
Reservation Polish (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueHorn07 authored Jan 28, 2024
1 parent 58ef6c0 commit cd7d931
Show file tree
Hide file tree
Showing 21 changed files with 1,228 additions and 404 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Buile Step
FROM node:18.18-alpine AS builder
FROM node:20.9-alpine AS builder

WORKDIR /usr/src/app

Expand All @@ -21,7 +21,7 @@ RUN npm run build
RUN npm prune --production

# Run Step
FROM node:18.18-alpine AS runner
FROM node:20.9-alpine AS runner

WORKDIR /usr/src/app

Expand Down
2 changes: 1 addition & 1 deletion assets/owner.options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const OwnerOptions = [
{ key: "chonghak", text: "총학생회", value: "chonghak" },
{ key: "dongyeon", text: "동아리연합회", value: "dongyeon" },
{ key: "dormUnion", text: "생활관자치회", value: "dormUnion" },
{ key: "chonghak", text: "총학생회", value: "chonghak" },
{ key: "saengna", text: "생각나눔", value: "saengna" },
{ key: "others", text: "그 외", value: "others" },
];
6 changes: 3 additions & 3 deletions components/equipment/equipment.reservation.confirm.modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const EquipmentReservationConfirmModal = (props) => {
{}, {withCredentials: true})
setOpen(false)
window.location.reload()
} catch (e) {
alert('예약 승인/거절에 실패했습니다.')
console.log(e)
} catch (err) {
const errMsg = err.response.data.message;
alert(`예약 승인/거절에 실패했습니다.\n${errMsg}`);
}
}

Expand Down
125 changes: 60 additions & 65 deletions components/equipment/equipment.reservation.table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,67 @@ import moment from 'moment'
import EquipmentReservationConfirmModal
from './equipment.reservation.confirm.modal'

const EquipmentReservationTable = (props) => {
const reservations = props.reservations
const start_idx = props.startIdx

const EquipmentReservationTable = ({ reservations, startIdx }) => {
return (
<>
<Table
celled selectable
textAlign={'center'}>
<Table.Header>
<Table.Row>
<Table.HeaderCell width={1}>idx.</Table.HeaderCell>
<Table.HeaderCell width={3}>장비 목록</Table.HeaderCell>
<Table.HeaderCell width={2}>사용자</Table.HeaderCell>
<Table.HeaderCell>예약 제목</Table.HeaderCell>
<Table.HeaderCell width={4}>예약 기간</Table.HeaderCell>
<Table.HeaderCell width={2}>상태</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{
reservations.map((reservation, idx) =>
<EquipmentReservationConfirmModal
key={reservation.uuid}
reservation={reservation}
trigger={
<Table.Row key={reservation.uuid}>
<Table.Cell>{start_idx + idx + 1}</Table.Cell>
<Table.Cell>
{
reservation.equipments.map(equipment => {
return (
<Label
size={"tiny"}
key={equipment.uuid}
style={{margin: "2px"}}
>
{equipment.name}
</Label>
)
})
}
</Table.Cell>
<Table.Cell>{reservation.booker.name}</Table.Cell>
<Table.Cell>{reservation.title}</Table.Cell>
<Table.Cell>
<b>
{moment(reservation.date, 'YYYYMMDD').
format('YYYY년 MM월 DD일')}
<br/>
{moment(reservation.start_time, 'HHmm').
format('HH:mm')}
&nbsp;~&nbsp;
{moment(reservation.end_time, 'HHmm').
format('HH:mm')}
</b>
</Table.Cell>
<Table.Cell>{reservation.status}</Table.Cell>
</Table.Row>
}
/>,
)
}
</Table.Body>
</Table>
</>
<Table
celled selectable
textAlign={'center'}>
<Table.Header>
<Table.Row>
<Table.HeaderCell width={1}>idx.</Table.HeaderCell>
<Table.HeaderCell width={3}>장비 목록</Table.HeaderCell>
<Table.HeaderCell width={2}>사용자</Table.HeaderCell>
<Table.HeaderCell>예약 제목</Table.HeaderCell>
<Table.HeaderCell width={4}>예약 기간</Table.HeaderCell>
<Table.HeaderCell width={2}>상태</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{
reservations.map((reservation, idx) =>
<EquipmentReservationConfirmModal
key={reservation.uuid}
reservation={reservation}
trigger={
<Table.Row key={reservation.uuid}>
<Table.Cell>{startIdx + idx + 1}</Table.Cell>
<Table.Cell>
{
reservation.equipments.map(equipment => {
return (
<Label
size={"tiny"}
key={equipment.uuid}
style={{margin: "2px"}}
>
{equipment.name}
</Label>
)
})
}
</Table.Cell>
<Table.Cell>{reservation.booker.name}</Table.Cell>
<Table.Cell>{reservation.title}</Table.Cell>
<Table.Cell>
<b>
{moment(reservation.date, 'YYYYMMDD').
format('YYYY년 MM월 DD일')}
<br/>
{moment(reservation.start_time, 'HHmm').
format('HH:mm')}
&nbsp;~&nbsp;
{moment(reservation.end_time, 'HHmm').
format('HH:mm')}
</b>
</Table.Cell>
<Table.Cell>{reservation.status}</Table.Cell>
</Table.Row>
}
/>,
)
}
</Table.Body>
</Table>
)
}

Expand Down
82 changes: 82 additions & 0 deletions components/equipment/equipment.reservation.wait.table.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react'
import { Label, Table } from 'semantic-ui-react'
import moment from 'moment'
import EquipmentReservationConfirmModal
from './equipment.reservation.confirm.modal'

const EquipmentReservationWaitTable = ({ reservations, startIdx }) => {
return (
<Table
celled selectable
textAlign={'center'}>
<Table.Header>
<Table.Row>
<Table.HeaderCell width={1}>idx.</Table.HeaderCell>
<Table.HeaderCell width={3}>장비 목록</Table.HeaderCell>
<Table.HeaderCell width={2}>사용자</Table.HeaderCell>
<Table.HeaderCell>예약 제목</Table.HeaderCell>
<Table.HeaderCell width={4}>예약 기간</Table.HeaderCell>
<Table.HeaderCell width={2}>상태</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
{
reservations.map((reservation, idx) => {

const start_datetime = moment(
`${reservation.date} ${reservation.start_time}`, 'YYYYMMDD HHmm')
const end_datetime = moment(
`${reservation.date} ${reservation.end_time}`, 'YYYYMMDD HHmm')

const isOutdated = moment() > end_datetime;
const isNow = start_datetime <= moment() && moment() <= end_datetime;

return (
<EquipmentReservationConfirmModal
key={reservation.uuid}
reservation={reservation}
trigger={
<Table.Row key={reservation.uuid} negative={isOutdated} positive={isNow}>
<Table.Cell>{startIdx + idx + 1}</Table.Cell>
<Table.Cell>
{
reservation.equipments.map(equipment => {
return (
<Label
size={"tiny"}
key={equipment.uuid}
style={{margin: "2px"}}
>
{equipment.name}
</Label>
)
})
}
</Table.Cell>
<Table.Cell>{reservation.booker.name}</Table.Cell>
<Table.Cell>{reservation.title}</Table.Cell>
<Table.Cell>
<b>
{moment(reservation.date, 'YYYYMMDD').
format('YYYY년 MM월 DD일')}
<br/>
{moment(reservation.start_time, 'HHmm').
format('HH:mm')}
&nbsp;~&nbsp;
{moment(reservation.end_time, 'HHmm').
format('HH:mm')}
</b>
</Table.Cell>
<Table.Cell>{reservation.status}</Table.Cell>
</Table.Row>
}
/>
)
})
}
</Table.Body>
</Table>
)
}

export default EquipmentReservationWaitTable
6 changes: 3 additions & 3 deletions components/place/place.reservation.confirm.modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const PlaceReservationConfirmModal = ({trigger, reservation}) => {
{}, {withCredentials: true})
setOpen(false)
window.location.reload()
} catch (e) {
alert('예약 승인/거절에 실패했습니다.')
console.log(e)
} catch (err) {
const errMsg = err.response.data.message;
alert(`예약 승인/거절에 실패했습니다.\n${errMsg}`);
}
}

Expand Down
10 changes: 7 additions & 3 deletions components/place/place.reservation.wait.table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ const PlaceReservationWaitTable = ({reservations}) => {
<Table.Body>
{
reservations.map((reservation, idx) => {
const reservation_end_datetime = moment(
const start_datetime = moment(
`${reservation.date} ${reservation.start_time}`, 'YYYYMMDD HHmm')
const end_datetime = moment(
`${reservation.date} ${reservation.end_time}`, 'YYYYMMDD HHmm')
const isOutdated = moment() > reservation_end_datetime

const isOutdated = moment() > end_datetime;
const isNow = start_datetime <= moment() && moment() <= end_datetime;

return (
<Table.Row key={reservation.uuid} error={isOutdated}>
<Table.Row key={reservation.uuid} negative={isOutdated} positive={isNow}>
<Table.Cell>{idx + 1}</Table.Cell>
<Table.Cell>{reservation.place.name}</Table.Cell>
<Table.Cell>{reservation.booker.name}</Table.Cell>
Expand Down
52 changes: 52 additions & 0 deletions components/reservation/opening_hours.list.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { KoreanWeekday } from '@/utils/opening_hours'

const OpeningHoursList = ({ openingHours }) => {
let isBriefCase;
if (openingHours['Everyday']) {
isBriefCase = false;
} else {
let cnt = 0;
for(const day of Object.keys(openingHours)) {
if(openingHours[day] === '00:00-24:00') {
cnt += 1;
}
}
isBriefCase = (cnt > 5);
}

return (
<div style={{ width: '100%' }}>
{
Object.keys(openingHours).map(day => {
if(isBriefCase && openingHours[day] === '00:00-24:00') {
return;
}

return (
<div key={day} style={{ display: 'flex', margin: 0 }}>
<div style={{ flex: 2, margin: 0 }}>
{KoreanWeekday[day]}:
</div>
<div style={{ flex: 4, margin: 0 }}>
{openingHours[day]}
</div>
</div>
)
},
)
}
{
isBriefCase ? (
<div key={'others'} style={{ display: 'flex', margin: 0 }}>
<div style={{ flex: 2, margin: 0 }}>그외:</div>
<div style={{ flex: 4, margin: 0 }}>
00:00-24:00
</div>
</div>
) : null
}
</div>
)
}

export default OpeningHoursList
Loading

0 comments on commit cd7d931

Please sign in to comment.