diff --git a/components/bookingTable.tsx b/components/bookingTable.tsx new file mode 100644 index 0000000..3f9e025 --- /dev/null +++ b/components/bookingTable.tsx @@ -0,0 +1,75 @@ +import React from 'react' +import Link from 'next/link' + +import { daysFormatFrontend } from '../helpers/date' +import { BookingDocument } from '../db/booking' + +export default function BookingTable({ + booking, +}: { + booking: BookingDocument +}) { + const data = [ + { name: 'Status', value: booking.status }, + { name: 'Buchungszeitraum', value: daysFormatFrontend(booking.days) }, + { name: 'Organisation', value: booking.org }, + { + name: 'Addresse', + value: ( + <> +
{booking.street}
+
+ {booking.zip} {booking.city} +
+ + ), + }, + { + name: 'Email', + value: ( + + {booking.email} + + ), + }, + { name: 'Zweck', value: booking.purpose }, + { name: 'Ziel', value: booking.destination }, + ] + return ( +
+
+

+ + Booking {booking.uuid} + +

+

+ Last updated{' '} + {new Date(booking.updatedAt as string).toLocaleString( + new Intl.Locale('de') + )} +

+
+
+
+ {data.map(({ name, value }, index) => ( +
+
{name}
+
+ {value || 'n/a'} +
+
+ ))} +
+
+
+ ) +} diff --git a/pages/admin/index.tsx b/pages/admin/index.tsx index 34ace7f..b8c7332 100644 --- a/pages/admin/index.tsx +++ b/pages/admin/index.tsx @@ -1,7 +1,6 @@ import React from 'react' -import Link from 'next/link' +import BookingTable from '../../components/bookingTable' import Layout from '../../components/layout' -import { daysFormatFrontend } from '../../helpers/date' import { getServerSideRecentBookings } from '../../lib/getServerSideProps' @@ -21,51 +20,7 @@ function AdminRecentBookings({ bookings }) { return ( {bookings.map((booking: any) => ( -
-
-

- - Booking {booking.uuid} - -

-

- Last updated {new Date(booking.updatedAt).toLocaleString()} -

-
-
-
-
-
- Buchungszeitraum -
-
- {daysFormatFrontend(booking.days)} -
-
-
-
Bucher
-
- {booking.name} -
-
-
-
Email
-
- {booking.email} -
-
-
-
Status
-
- {booking.status} -
-
-
-
-
+ ))}
)