From a6ff5eee45215effb3344cb5d631a27a7c0369aa Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Fri, 22 Sep 2023 19:34:01 +0200
Subject: refactor(components): rewrite form components

---
 src/pages/contact.tsx | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

(limited to 'src/pages/contact.tsx')

diff --git a/src/pages/contact.tsx b/src/pages/contact.tsx
index e3c8a2c..92c58cc 100644
--- a/src/pages/contact.tsx
+++ b/src/pages/contact.tsx
@@ -79,7 +79,7 @@ const ContactPage: NextPageWithLayout = () => {
   const [statusMessage, setStatusMessage] = useState<string>('');
 
   const submitMail: ContactFormProps['sendMail'] = async (data, reset) => {
-    const { email, message, name, subject } = data;
+    const { email, message, name, object } = data;
     const messageHTML = message.replace(/\r?\n/g, '<br />');
     const body = `Message received from ${name} <${email}> on ${website.url}.<br /><br />${messageHTML}`;
     const replyTo = `${name} <${email}>`;
@@ -87,7 +87,7 @@ const ContactPage: NextPageWithLayout = () => {
       body,
       clientMutationId: 'contact',
       replyTo,
-      subject,
+      subject: object,
     };
     const { message: mutationMessage, sent } = await sendMail(mailData);
 
@@ -139,11 +139,13 @@ const ContactPage: NextPageWithLayout = () => {
         <ContactForm
           sendMail={submitMail}
           Notice={
-            <Notice
-              kind={status}
-              message={statusMessage}
-              className={styles.notice}
-            />
+            statusMessage ? (
+              <Notice
+                kind={status}
+                message={statusMessage}
+                className={styles.notice}
+              />
+            ) : undefined
           }
         />
       </PageLayout>
-- 
cgit v1.2.3

