mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
move contexts all out in own toplevel dir
- rename wizard to book
This commit is contained in:
50
components/book/index.tsx
Normal file
50
components/book/index.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import React, { useContext } from 'react'
|
||||
import Contact from './contact'
|
||||
import BookStore, { BookContext } from '../../context/book'
|
||||
import DateSelect from './dateSelect'
|
||||
import Reason from './reason'
|
||||
|
||||
function BookForm() {
|
||||
const { onSubmit, state, forgetData } = useContext(BookContext)
|
||||
const { postData, postDataError, dataStoredLoaded } = state
|
||||
|
||||
return (
|
||||
<>
|
||||
<form
|
||||
className="form"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault()
|
||||
onSubmit()
|
||||
}}
|
||||
>
|
||||
<DateSelect />
|
||||
<Reason />
|
||||
{dataStoredLoaded && (
|
||||
<p className="mb-6 info-message">
|
||||
Buchungsdaten wurden aus Deinem Browser geladen und vorausgefüllt.{' '}
|
||||
<a className="link" onClick={forgetData}>
|
||||
Daten wieder vergessen
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
<Contact />
|
||||
<div className="flex items-end">
|
||||
<button type="submit" disabled={postData} className="btn btn-blue">
|
||||
{postData ? 'Speichern...' : 'Absenden'}
|
||||
</button>
|
||||
{postDataError && (
|
||||
<div className="error-message flex-grow">{postDataError}</div>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default function Book() {
|
||||
return (
|
||||
<BookStore>
|
||||
<BookForm />
|
||||
</BookStore>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user