mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
add appStore and use router for booking
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { WizardContext } from '../context/wizardStore'
|
||||
import { AppContext } from '../context/appStore'
|
||||
import Required from './required'
|
||||
|
||||
export default function Contact() {
|
||||
const { state, onChangeEvent } = useContext(WizardContext)
|
||||
const { state, onChangeEvent } = useContext(AppContext)
|
||||
|
||||
const { name, email, street, zip, city } = state.formData
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useContext, useState, useRef, useEffect } from 'react'
|
||||
import useSWR from 'swr'
|
||||
|
||||
import { WizardContext } from '../context/wizardStore'
|
||||
import { AppContext } from '../context/appStore'
|
||||
|
||||
import { DateUtils } from 'react-day-picker'
|
||||
import DayPickerInput from 'react-day-picker/DayPickerInput'
|
||||
@@ -19,7 +19,7 @@ import 'moment/locale/de'
|
||||
const fetcher = (path) => fetch(path).then((r) => r.json())
|
||||
|
||||
export default function DateSelect() {
|
||||
const { state, onChange } = useContext(WizardContext)
|
||||
const { state, onChange } = useContext(AppContext)
|
||||
const [range, setRange] = useState({
|
||||
form: state.startDate && new Date(state.startDate),
|
||||
to: state.endDate && new Date(state.endDate),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { WizardContext } from '../context/wizardStore'
|
||||
import { AppContext } from '../context/appStore'
|
||||
import Required from './required'
|
||||
|
||||
export default function Contact() {
|
||||
const { state, onChangeEvent } = useContext(WizardContext)
|
||||
const { state, onChangeEvent } = useContext(AppContext)
|
||||
|
||||
const { formDataChanged } = state
|
||||
const { purpose, destination, org } = state.formData
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React, { useContext } from 'react'
|
||||
|
||||
import WizardStore, { WizardContext } from '../context/wizardStore'
|
||||
import { AppContext } from '../context/appStore'
|
||||
|
||||
import DateSelect from './dateSelect'
|
||||
import Reason from './reason'
|
||||
import Contact from './contact'
|
||||
//import Driver from './driver'
|
||||
|
||||
function WizardInternal() {
|
||||
const { onSubmit, state, storeData, forgetData } = useContext(WizardContext)
|
||||
export default function Wizard() {
|
||||
const { onSubmit, state, storeData, forgetData } = useContext(AppContext)
|
||||
const {
|
||||
postData,
|
||||
postDataSuccess,
|
||||
@@ -22,7 +22,7 @@ function WizardInternal() {
|
||||
<>
|
||||
<h3>Danke, die Buchung ist in Bearbeitung!</h3>
|
||||
<p>Nach Prüfung bestätigen wir die Buchung bald per E-Mail!</p>
|
||||
{typeof dataStored !== 'boolean' && (
|
||||
{!dataStoredLoaded && typeof dataStored !== 'boolean' && (
|
||||
<>
|
||||
<p>
|
||||
Sollen die eingegebenen Daten in <strong>Deinem Browser</strong>{' '}
|
||||
@@ -55,9 +55,11 @@ function WizardInternal() {
|
||||
}}
|
||||
>
|
||||
{dataStoredLoaded && (
|
||||
<p>
|
||||
<p className="my-12">
|
||||
Gespeicherte Daten wurden aus Deinem Browser geladen.{' '}
|
||||
<a onClick={forgetData}>Daten vergessen</a>
|
||||
<a className="link" onClick={forgetData} href="">
|
||||
Daten wieder vergessen
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
<DateSelect />
|
||||
@@ -72,11 +74,3 @@ function WizardInternal() {
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
export default function Wizard() {
|
||||
return (
|
||||
<WizardStore>
|
||||
<WizardInternal />
|
||||
</WizardStore>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user