feat(SW-240): add simple form

This commit is contained in:
Fredrik Thorsson
2024-08-15 11:38:38 +02:00
parent 00a5465485
commit 608fe13004
4 changed files with 87 additions and 83 deletions

View File

@@ -1,9 +1,13 @@
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { FormProvider, useForm } from "react-hook-form"
import { useIntl } from "react-intl"
import { dt } from "@/lib/dt"
import Button from "@/components/TempDesignSystem/Button"
import Body from "@/components/TempDesignSystem/Text/Body"
import FormContent from "./FormContent"
import { bookingWidgetSchema } from "./schema"
@@ -14,6 +18,7 @@ import { BookingWidgetSchema } from "@/types/components/bookingWidget"
const formId = "booking-widget"
export default function Form() {
const intl = useIntl()
const methods = useForm<BookingWidgetSchema>({
defaultValues: {
search: {
@@ -48,14 +53,31 @@ export default function Form() {
}
return (
<form
onSubmit={methods.handleSubmit(onSubmit)}
className={styles.form}
id={formId}
>
<FormProvider {...methods}>
<FormContent />
</FormProvider>
</form>
<section className={styles.section}>
<form
onSubmit={methods.handleSubmit(onSubmit)}
className={styles.form}
id={formId}
>
<FormProvider {...methods}>
<FormContent />
</FormProvider>
</form>
<Button
type="submit"
size="small"
theme="base"
intent="primary"
className={styles.button}
>
<Body
color="white"
textTransform="bold"
className={styles.bodyFontSize}
>
{intl.formatMessage({ id: "Find hotels" })}
</Body>
</Button>
</section>
)
}