mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
update mongoose to 5.8.3 (lots of types changes)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import Input from '../../../../components/input'
|
||||
import Select from '../../../../components/select'
|
||||
import { Booking } from '../../../../db/booking'
|
||||
import { IBooking } from '../../../../db/booking'
|
||||
import { BILL_STATUS, MILAGE_TARIFS } from '../../../../db/enums'
|
||||
import { getMilageMax } from '../../../../db/index'
|
||||
import { daysFormatFrontend } from '../../../../helpers/date'
|
||||
@@ -67,7 +67,7 @@ function BookingBillPage({
|
||||
booking: bookingProp,
|
||||
milageMax,
|
||||
}: {
|
||||
booking: Booking
|
||||
booking: IBooking
|
||||
milageMax: number
|
||||
}) {
|
||||
const [booking, setBooking] = useState(bookingProp)
|
||||
@@ -262,4 +262,4 @@ function BookingBillPage({
|
||||
|
||||
BookingBillPage.authenticationRequired = true
|
||||
|
||||
export default BookingBillPage
|
||||
export default BookingBillPage
|
||||
@@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
|
||||
import Link from 'next/link'
|
||||
import Calendar from '../../../../components/calendar'
|
||||
import { getServerSideBooking } from '../../../../lib/getServerSideProps'
|
||||
import { BookingDocument } from '../../../../db/booking'
|
||||
import { IBooking } from '../../../../db/booking'
|
||||
import { patchBooking } from '../../../../helpers/booking'
|
||||
import { log } from '../../../../helpers/log'
|
||||
import { BOOKING_STATUS } from '../../../../db/enums'
|
||||
@@ -11,7 +11,7 @@ import BookingTable from '../../../../components/bookingTable'
|
||||
|
||||
export const getServerSideProps = getServerSideBooking
|
||||
|
||||
function ShowBookingAdmin({ booking: bookingProp }: { booking: BookingDocument }) {
|
||||
function ShowBookingAdmin({ booking: bookingProp }: { booking: IBooking }) {
|
||||
const router = useRouter()
|
||||
const [booking, setBooking] = useState(bookingProp)
|
||||
const [storingBooking, setStoringBooking] = useState(false)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { Bill } from '../../../../db/bill'
|
||||
import { IBill } from '../../../../db/bill'
|
||||
import { createBill, patchBill } from '../../../../db/index'
|
||||
import { log } from '../../../../helpers/log'
|
||||
|
||||
@@ -13,7 +13,7 @@ export default async function billHandler(
|
||||
} = req
|
||||
const bookingUUID = Array.isArray(uuids) ? uuids[0] : uuids
|
||||
|
||||
let bill: Bill
|
||||
let bill: IBill
|
||||
|
||||
switch (method) {
|
||||
case 'POST':
|
||||
@@ -40,4 +40,4 @@ export default async function billHandler(
|
||||
res.setHeader('Allow', ['POST', 'PATCH'])
|
||||
res.status(405).end(`Method ${method} Not Allowed`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { Booking } from '../../../../db/booking'
|
||||
import { IBooking } from '../../../../db/booking'
|
||||
import { BOOKING_STATUS } from '../../../../db/enums'
|
||||
import { patchBooking } from '../../../../db/index'
|
||||
import {
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
import { log } from '../../../../helpers/log'
|
||||
|
||||
function changedStatus(
|
||||
previous: Booking,
|
||||
current: Partial<Booking>,
|
||||
previous: IBooking,
|
||||
current: Partial<IBooking>,
|
||||
status: BOOKING_STATUS
|
||||
): boolean {
|
||||
return (
|
||||
@@ -19,15 +19,15 @@ function changedStatus(
|
||||
current.status === status
|
||||
)
|
||||
}
|
||||
function wasRejected(previous: Booking, current: Partial<Booking>): boolean {
|
||||
function wasRejected(previous: IBooking, current: Partial<IBooking>): boolean {
|
||||
return changedStatus(previous, current, BOOKING_STATUS.REJECTED)
|
||||
}
|
||||
|
||||
function wasConfirmed(previous: Booking, current: Partial<Booking>): boolean {
|
||||
function wasConfirmed(previous: IBooking, current: Partial<IBooking>): boolean {
|
||||
return changedStatus(previous, current, BOOKING_STATUS.CONFIRMED)
|
||||
}
|
||||
|
||||
function wasCanceled(previous: Booking, current: Partial<Booking>): boolean {
|
||||
function wasCanceled(previous: IBooking, current: Partial<IBooking>): boolean {
|
||||
return (
|
||||
[BOOKING_STATUS.REQUESTED, BOOKING_STATUS.CONFIRMED].includes(
|
||||
previous.status
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Error } from 'mongoose'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { Booking } from '../../../db/booking'
|
||||
import { IBooking } from '../../../db/booking'
|
||||
import { createBooking } from '../../../db/index'
|
||||
import { log } from '../../../helpers/log'
|
||||
import {
|
||||
@@ -14,7 +14,7 @@ export default async function userHandler(
|
||||
): Promise<void> {
|
||||
const { method } = req
|
||||
|
||||
let booking: Booking
|
||||
let booking: IBooking
|
||||
|
||||
switch (method) {
|
||||
case 'POST':
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { getServerSideBooking } from '../../../lib/getServerSideProps'
|
||||
import { Booking } from '../../../db/booking'
|
||||
import { IBooking } from '../../../db/booking'
|
||||
import { BOOKING_STATUS } from '../../../db/enums'
|
||||
import { daysFormatFrontend } from '../../../helpers/date'
|
||||
import { log } from '../../../helpers/log'
|
||||
@@ -11,7 +11,7 @@ export const getServerSideProps = getServerSideBooking
|
||||
export default function ShowBooking({
|
||||
booking: bookingProp,
|
||||
}: {
|
||||
booking: Booking
|
||||
booking: IBooking
|
||||
}) {
|
||||
const [booking, setBooking] = useState(bookingProp)
|
||||
const [storingBooking, setStoringBooking] = useState(false)
|
||||
@@ -65,4 +65,4 @@ export default function ShowBooking({
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import Link from 'next/link'
|
||||
import { Booking } from '../../../db/booking'
|
||||
import { IBooking } from '../../../db/booking'
|
||||
import { loadBookingData, storeBookingData } from '../../../helpers/storage'
|
||||
import { getServerSideBooking } from '../../../lib/getServerSideProps'
|
||||
|
||||
export const getServerSideProps = getServerSideBooking
|
||||
|
||||
export default function ShowBookingStored({ booking }: { booking: Booking }) {
|
||||
export default function ShowBookingStored({ booking }: { booking: IBooking }) {
|
||||
const [storedBookingData, setStoredBookingData] = useState(null)
|
||||
const [bookingDataStored, setBookingDataStored] = useState(false)
|
||||
|
||||
@@ -53,4 +53,4 @@ export default function ShowBookingStored({ booking }: { booking: Booking }) {
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user