rip out all old auth data

This commit is contained in:
Thomas Ruoff
2021-10-02 01:03:02 +02:00
committed by Thomas Ruoff
parent b257bc8258
commit 0e84945ab4
8 changed files with 22 additions and 89 deletions

View File

@@ -9,32 +9,18 @@ import { getMilageMax } from '../../../../db/index'
import { daysFormatFrontend } from '../../../../helpers/date'
import { getBillTotal, createBill, patchBill } from '../../../../helpers/bill'
import { getBookingStatus } from '../../../../helpers/booking'
import withSession, {
isAdminSession,
redirectToLogin,
} from '../../../../lib/session'
import { getServerSideBooking } from '../../../../lib/getServerSideProps'
export const getServerSideProps = withSession(async (context) => {
const { req, res } = context
const adminUser = isAdminSession(req)
if (!adminUser) {
redirectToLogin(req, res)
return { props: {} }
}
export const getServerSideProps = async (context) => {
const milageMax = await getMilageMax()
const serverSideBookingProps = await getServerSideBooking(context)
return {
props: {
...serverSideBookingProps.props,
milageMax,
user: adminUser,
},
}
})
};
}
const milageTarifOptions = Object.values(MILAGE_TARIFS).map((tarif) => {
return (
@@ -217,9 +203,8 @@ export default function BookingBillPage({
>
-
</button>
<label className="flabel inline">{`Kostenpunkt ${
index + 1
}`}</label>
<label className="flabel inline">{`Kostenpunkt ${index + 1
}`}</label>
</div>
<div className="ml-10 mb-3" key={`input{index}`}>
<Input

View File

@@ -1,40 +1,16 @@
import React, { useEffect, useState } from 'react'
import { GetServerSideProps } from 'next'
import { useRouter } from 'next/router'
import Link from 'next/link'
import Footer from '../../../../components/footer'
import Header from '../../../../components/header'
import Calendar from '../../../../components/calendar'
import withSession, {
isAdminSession,
redirectToLogin,
} from '../../../../lib/session'
import { getServerSideBooking } from '../../../../lib/getServerSideProps'
import { Booking } from '../../../../db/booking'
import { getBookingStatus, patchBooking } from '../../../../helpers/booking'
import { daysFormatFrontend } from '../../../../helpers/date'
import { BOOKING_STATUS } from '../../../../db/enums'
export const getServerSideProps: GetServerSideProps = withSession(
async (context) => {
const { req, res } = context
const adminUser = isAdminSession(req)
if (!adminUser) {
redirectToLogin(req, res)
return { props: {} }
}
const result = await getServerSideBooking(context)
return {
...result,
// TODO: have a closer look at this type issue. Seems like a bug
// @ts-ignore
props: { ...result.props, user: adminUser },
}
}
)
export const getServerSideProps = getServerSideBooking;
export default function ShowBookingAdmin({
booking: bookingProp,