mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
remove *Document intefaces from FE code
This commit is contained in:
@@ -3,8 +3,8 @@ import Footer from '../../../../components/footer'
|
||||
import Header from '../../../../components/header'
|
||||
import Input from '../../../../components/input'
|
||||
import Select from '../../../../components/select'
|
||||
import { AdditionalCost, BillDocument } from '../../../../db/bill'
|
||||
import { BookingDocument } from '../../../../db/booking'
|
||||
import { AdditionalCost, Bill } from '../../../../db/bill'
|
||||
import { Booking } from '../../../../db/booking'
|
||||
import { BILL_STATUS, MILAGE_TARIFS } from '../../../../db/enums'
|
||||
import { getMilageMax } from '../../../../db/index'
|
||||
import { dateFormatFrontend } from '../../../../helpers/date'
|
||||
@@ -80,7 +80,7 @@ function getBillStatusLabel(status: BILL_STATUS) {
|
||||
}
|
||||
|
||||
async function saveBill(
|
||||
booking: BookingDocument,
|
||||
booking: Booking,
|
||||
bill: {
|
||||
milageStart: number
|
||||
milageEnd: number
|
||||
@@ -89,9 +89,9 @@ async function saveBill(
|
||||
additionalCosts: AdditionalCost[]
|
||||
status: BILL_STATUS
|
||||
}
|
||||
): Promise<BillDocument> {
|
||||
): Promise<Bill> {
|
||||
const response = await fetch(`/api/admin/booking/${booking.uuid}/bill`, {
|
||||
method: booking.bill?._id ? 'PATCH' : 'POST',
|
||||
method: !!booking.bill ? 'PATCH' : 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
@@ -108,7 +108,7 @@ export default function BookingBillPage({
|
||||
booking: bookingProp,
|
||||
milageMax,
|
||||
}: {
|
||||
booking: BookingDocument
|
||||
booking: Booking
|
||||
milageMax: number
|
||||
}) {
|
||||
const [booking, setBooking] = useState(bookingProp)
|
||||
@@ -300,7 +300,7 @@ export default function BookingBillPage({
|
||||
className="btn btn-blue mt-3"
|
||||
disabled={storingInProgress}
|
||||
>
|
||||
Rechnung {booking.bill?._id ? 'Updaten' : 'Erstellen'}
|
||||
Rechnung {!!booking.bill ? 'Updaten' : 'Erstellen'}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
@@ -8,7 +8,7 @@ import withSession, {
|
||||
redirectToLogin,
|
||||
} from '../../../../lib/session'
|
||||
import { getServerSideBooking } from '../../../../lib/getServerSideProps'
|
||||
import { BookingDocument } from '../../../../db/booking'
|
||||
import { Booking } from '../../../../db/booking'
|
||||
import { getBookingStatus } from '../../../../helpers/booking'
|
||||
import { dateFormatFrontend } from '../../../../helpers/date'
|
||||
import { BOOKING_STATUS } from '../../../../db/enums'
|
||||
@@ -52,7 +52,7 @@ async function patchBooking(uuid: string, bookingData: any) {
|
||||
export default function ShowBookingAdmin({
|
||||
booking: bookingProp,
|
||||
}: {
|
||||
booking: BookingDocument
|
||||
booking: Booking
|
||||
}) {
|
||||
const [booking, setBooking] = useState(bookingProp)
|
||||
const [storingBooking, setStoringBooking] = useState(false)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { BillDocument } from '../../../../../db/bill'
|
||||
import { Bill } from '../../../../../db/bill'
|
||||
import { createBill, patchBill } from '../../../../../db/index'
|
||||
import withSession, { isAdminSession } from '../../../../../lib/session'
|
||||
|
||||
export default withSession(async function billHandler(req, res) {
|
||||
if (!isAdminSession(req, res)) {
|
||||
if (!isAdminSession(req)) {
|
||||
res.status(403).send({ message: 'Not Authorized' })
|
||||
return
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export default withSession(async function billHandler(req, res) {
|
||||
} = req
|
||||
const bookingUUID = Array.isArray(uuids) ? uuids[0] : uuids
|
||||
|
||||
let bill: BillDocument
|
||||
let bill: Bill
|
||||
|
||||
switch (method) {
|
||||
case 'POST':
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { BOOKING_STATUS } from '../../../../../db/enums'
|
||||
|
||||
export default withSession(async function bookingHandler(req, res) {
|
||||
if (!isAdminSession(req, res)) {
|
||||
if (!isAdminSession(req)) {
|
||||
res.status(403).send({ message: 'Not Authorized' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Error } from 'mongoose'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { BookingDocument } from '../../../db/booking'
|
||||
import { Booking } from '../../../db/booking'
|
||||
import { createBooking } from '../../../db/index'
|
||||
import { sendReceivedBookingAdminMail, sendReceivedBookingBookerMail } from '../../../helpers/mail'
|
||||
import {
|
||||
sendReceivedBookingAdminMail,
|
||||
sendReceivedBookingBookerMail,
|
||||
} from '../../../helpers/mail'
|
||||
|
||||
export default async function userHandler(
|
||||
req: NextApiRequest,
|
||||
@@ -10,7 +13,7 @@ export default async function userHandler(
|
||||
) {
|
||||
const { method } = req
|
||||
|
||||
let booking: BookingDocument
|
||||
let booking: Booking
|
||||
|
||||
switch (method) {
|
||||
case 'POST':
|
||||
|
||||
@@ -2,14 +2,14 @@ import React, { useEffect, useState } from 'react'
|
||||
import Footer from '../../../components/footer'
|
||||
import Header from '../../../components/header'
|
||||
import { getServerSideBooking } from '../../../lib/getServerSideProps'
|
||||
import { BookingDocument } from '../../../db/booking'
|
||||
import { Booking } from '../../../db/booking'
|
||||
import { BOOKING_STATUS } from '../../../db/enums'
|
||||
import { dateFormatFrontend } from '../../../helpers/date'
|
||||
import { getBookingStatus } from '../../../helpers/booking'
|
||||
|
||||
export const getServerSideProps = getServerSideBooking
|
||||
|
||||
async function cancelBooking(booking: BookingDocument) {
|
||||
async function cancelBooking(booking: Booking) {
|
||||
const response = await fetch(`/api/booking/${booking.uuid}`, {
|
||||
method: 'PATCH',
|
||||
mode: 'cors',
|
||||
@@ -27,7 +27,7 @@ async function cancelBooking(booking: BookingDocument) {
|
||||
export default function ShowBooking({
|
||||
booking: bookingProp,
|
||||
}: {
|
||||
booking: BookingDocument
|
||||
booking: Booking
|
||||
}) {
|
||||
const [booking, setBooking] = useState(bookingProp)
|
||||
const [storingBooking, setStoringBooking] = useState(false)
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import Footer from '../../../components/footer'
|
||||
import Header from '../../../components/header'
|
||||
import { BookingDocument } from '../../../db/booking'
|
||||
import { Booking } from '../../../db/booking'
|
||||
import { loadBookingData, storeBookingData } from '../../../helpers/storage'
|
||||
import { getServerSideBooking } from '../../../lib/getServerSideProps'
|
||||
|
||||
@@ -11,7 +11,7 @@ export const getServerSideProps = getServerSideBooking
|
||||
export default function ShowBookingStored({
|
||||
booking: booking,
|
||||
}: {
|
||||
booking: BookingDocument
|
||||
booking: Booking
|
||||
}) {
|
||||
const [storedBookingData, setStoredBookingData] = useState(null)
|
||||
const [bookingDataStored, setBookingDataStored] = useState(false)
|
||||
|
||||
Reference in New Issue
Block a user