mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
clean up type mess in SSR functions
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { GetServerSideProps } from 'next'
|
||||
import Footer from '../../../../components/footer'
|
||||
import Header from '../../../../components/header'
|
||||
import Input from '../../../../components/input'
|
||||
@@ -17,27 +16,26 @@ import withSession, {
|
||||
} from '../../../../lib/session'
|
||||
import { getServerSideBooking } from '../../../../lib/getServerSideProps'
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = withSession(
|
||||
async (context) => {
|
||||
const { req, res } = context
|
||||
export const getServerSideProps = withSession(async (context) => {
|
||||
const { req, res } = context
|
||||
|
||||
const adminUser = isAdminSession(req, res)
|
||||
const adminUser = isAdminSession(req)
|
||||
|
||||
if (!adminUser) {
|
||||
redirectToLogin(req, res)
|
||||
return { props: {} }
|
||||
}
|
||||
|
||||
const milageMax = await getMilageMax()
|
||||
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, milageMax, user: adminUser },
|
||||
}
|
||||
if (!adminUser) {
|
||||
redirectToLogin(req, res)
|
||||
return { props: {} }
|
||||
}
|
||||
)
|
||||
|
||||
const milageMax = await getMilageMax()
|
||||
const serverSideBookingProps = await getServerSideBooking(context)
|
||||
return {
|
||||
props: {
|
||||
...serverSideBookingProps.props.booking,
|
||||
milageMax,
|
||||
user: adminUser,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
const milageTarifOptions = Object.values(MILAGE_TARIFS).map((tarif) => {
|
||||
return (
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getServerSideProps: GetServerSideProps = withSession(
|
||||
async (context) => {
|
||||
const { req, res } = context
|
||||
|
||||
const adminUser = isAdminSession(req, res)
|
||||
const adminUser = isAdminSession(req)
|
||||
|
||||
if (!adminUser) {
|
||||
redirectToLogin(req, res)
|
||||
|
||||
Reference in New Issue
Block a user