From e1dee71731be8fbc2f04839bc346236c14acfc4d Mon Sep 17 00:00:00 2001 From: Mats Eriksson Date: Sun, 9 Jul 2023 16:41:50 +0300 Subject: [PATCH] front: adds SendEmailForm and SendEmailButton components --- .../src/common/components/SendEmailButton.tsx | 13 +++++ .../src/common/components/SendEmailForm.tsx | 52 +++++++++++++++++++ .../apartment/ApartmentDetailsPage.tsx | 22 +++++++- .../styles/components/_ApartmentDetails.sass | 10 ++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 frontend/src/common/components/SendEmailButton.tsx create mode 100644 frontend/src/common/components/SendEmailForm.tsx diff --git a/frontend/src/common/components/SendEmailButton.tsx b/frontend/src/common/components/SendEmailButton.tsx new file mode 100644 index 000000000..d0f3cccdf --- /dev/null +++ b/frontend/src/common/components/SendEmailButton.tsx @@ -0,0 +1,13 @@ +import {Button, IconEnvelope} from "hds-react"; + +const SendEmailButton = ({...rest}) => ( + +); + +export default SendEmailButton; diff --git a/frontend/src/common/components/SendEmailForm.tsx b/frontend/src/common/components/SendEmailForm.tsx new file mode 100644 index 000000000..d8d3340b7 --- /dev/null +++ b/frontend/src/common/components/SendEmailForm.tsx @@ -0,0 +1,52 @@ +import {useForm} from "react-hook-form"; +import {Select, TextInput} from "./form"; +import SendEmailButton from "./SendEmailButton"; + +type SendEmailFormProps = { + recipient?: string; + email: string; + options: Array<{value: string; label: string}>; +}; + +const SendEmailForm = ({recipient, email = "", options}: SendEmailFormProps) => { + const sendEmailForm = useForm({ + defaultValues: { + email: email, + template: 0, + }, + mode: "all", + }); + const {handleSubmit} = sendEmailForm; + const sendEmail = (data) => { + // TODO: Validation & implement sending email + // eslint-disable-next-line no-console + console.log("Sending email", data); + }; + return ( +
+ +
+