From 71093a4c88ed41bd51a3387f1e91c7ee05f2203c Mon Sep 17 00:00:00 2001
From: Andrew Lee <alee14498@protonmail.com>
Date: Sun, 4 Feb 2024 12:30:02 -0500
Subject: Almost finished implementing guestbook; More consistency in cards

---
 src/components/GuestbookForm.jsx | 56 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 src/components/GuestbookForm.jsx

(limited to 'src/components/GuestbookForm.jsx')

diff --git a/src/components/GuestbookForm.jsx b/src/components/GuestbookForm.jsx
new file mode 100644
index 0000000..aae5e10
--- /dev/null
+++ b/src/components/GuestbookForm.jsx
@@ -0,0 +1,56 @@
+import { h, Component } from 'preact';
+import { createMessage } from '../services/GuestbookService';
+
+class GuestbookForm extends Component {
+    state = {
+        name: '',
+        email: '',
+        website: '',
+        message: ''
+    };
+
+    handleChange = (e) => {
+        this.setState({ [e.target.name]: e.target.value });
+    }
+
+    handleSubmit = async (e) => {
+        e.preventDefault();
+        await createMessage(this.state);
+        this.setState({
+            name: '',
+            email: '',
+            website: '',
+            message: ''
+        });
+    }
+
+    render() {
+        return (
+            <form class="card" onSubmit={this.handleSubmit}>
+                <h2>Submit Message</h2>
+                <label>
+                    Name<br />
+                    <input type="text" name="name" placeholder="Name" required value={this.state.name} onChange={this.handleChange} />
+                </label>
+                <br />
+                <label>
+                    Email Address<br />
+                    <input type="email" name="email" placeholder="Email Address (optional)" value={this.state.email} onChange={this.handleChange} />
+                </label>
+                <br />
+                <label>
+                    Your Website<br />
+                    <input type="url" name="website" placeholder="https://example.com (optional)" value={this.state.website} onChange={this.handleChange} />
+                </label>
+                <br />
+                <label>
+                    Message<br />
+                    <textarea name="message" placeholder="Message (Up to 1000 characters)" required value={this.state.message} onChange={this.handleChange}></textarea>
+                </label>
+                <button type="submit">Send</button>
+            </form>
+        );
+    }
+}
+
+export default GuestbookForm;
-- 
cgit v1.2.3

