move storing data to booking page

This commit is contained in:
Thomas Ruoff
2020-08-20 00:30:47 +02:00
parent e1d1de469b
commit 3a5f5b3204
2 changed files with 5 additions and 34 deletions

View File

@@ -8,42 +8,12 @@ import Contact from './contact'
//import Driver from './driver' //import Driver from './driver'
export default function Wizard() { export default function Wizard() {
const { onSubmit, state, storeData, forgetData } = useContext(AppContext) const { onSubmit, state, forgetData } = useContext(AppContext)
const { const { postData, postDataSuccess, postDataError, dataStoredLoaded } = state
postData,
postDataSuccess,
postDataError,
dataStored,
dataStoredLoaded,
} = state
if (postDataSuccess) { if (postDataSuccess) {
return ( // /booking/[id] takes over
<> return null
<h3>Danke, die Buchung ist in Bearbeitung!</h3>
<p>Nach Prüfung bestätigen wir die Buchung bald per E-Mail!</p>
{!dataStoredLoaded && typeof dataStored !== 'boolean' && (
<>
<p>
Sollen die eingegebenen Daten in <strong>Deinem Browser</strong>{' '}
für die nächste Buchung gespeichert werden?
</p>
<button onClick={() => storeData(true)} className="btn btn-blue">
Ja, bitte speichern
</button>
<button
onClick={() => storeData(false)}
className="btn btn-grey ml-2"
>
Nein danke
</button>
</>
)}
{dataStored === true && (
<p>Ok, die Daten wurden für die nächste Buchung gespeichert.</p>
)}
</>
)
} }
return ( return (

View File

@@ -3,6 +3,7 @@ import { AppContext } from '../../context/appStore'
import Footer from '../../components/footer' import Footer from '../../components/footer'
export default function Booking() { export default function Booking() {
const { state, storeData } = useContext(AppContext)
const { dataStored, dataStoredLoaded } = state const { dataStored, dataStoredLoaded } = state
return ( return (