Skip to content

Commit 92c2cc4

Browse files
Contact with google form
1 parent dd61b13 commit 92c2cc4

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

src/pages/[...lang]/contact.astro

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export function getStaticPaths() {
1616
const { lang } = Astro.params;
1717
const contact = await getListPage("contact", lang as keyof ContentEntryMap);
1818
19-
const { contact_form_action }: { contact_form_action: string } = config.params;
2019
const { title, description, meta_title, image } = contact[0].data;
2120
2221
const {
@@ -39,18 +38,24 @@ const {
3938
<div class="container">
4039
<div class="row">
4140
<div class="mx-auto md:col-10 lg:col-6">
42-
<form action={contact_form_action} method="POST">
41+
<form
42+
action="https://docs.google.com/forms/d/e/1FAIpQLSdKLON3GrQN1OrGxmj0S3HCKeiVg-MjmeqDHLufys7CzkDm1g/formResponse"
43+
method="POST"
44+
target="_blank"
45+
onsubmit="return window.submitGoogleForm(this);"
46+
>
4347
<div class="mb-6">
4448
<label for="name" class="form-label">
4549
{full_name}
4650
<span class="text-red-500">*</span>
4751
</label>
4852
<input
4953
id="name"
50-
name="name"
54+
name="entry.713430944"
5155
class="form-input"
5256
placeholder="Krishna Chaitanya Ethamukkala"
5357
type="text"
58+
required
5459
/>
5560
</div>
5661
<div class="mb-6">
@@ -60,10 +65,11 @@ const {
6065
</label>
6166
<input
6267
id="email"
63-
name="email"
68+
name="entry.1244225098"
6469
class="form-input"
6570
placeholder="[email protected]"
6671
type="email"
72+
required
6773
/>
6874
</div>
6975
<div class="mb-6">
@@ -73,13 +79,38 @@ const {
7379
</label>
7480
<textarea
7581
id="message"
76-
name="message"
82+
name="entry.618640668"
7783
class="form-input"
7884
placeholder={contact_message_placeholder}
79-
rows="8"></textarea>
85+
rows="8"
86+
required
87+
></textarea>
88+
</div>
89+
<div id="form-status" class="mb-6 hidden">
90+
<p class="text-success">Thank you for your message! We'll get back to you soon.</p>
8091
</div>
8192
<button type="submit" class="btn btn-primary">{submit}</button>
8293
</form>
94+
95+
<script is:inline>
96+
window.submitGoogleForm = function(form) {
97+
const formData = new FormData(form);
98+
fetch(form.action, {
99+
method: 'POST',
100+
body: formData,
101+
mode: 'no-cors'
102+
})
103+
.then(() => {
104+
form.reset();
105+
document.getElementById('form-status').classList.remove('hidden');
106+
setTimeout(() => {
107+
document.getElementById('form-status').classList.add('hidden');
108+
}, 5000);
109+
})
110+
.catch(error => console.error('Error:', error));
111+
return false;
112+
};
113+
</script>
83114
</div>
84115
</div>
85116
</div>

0 commit comments

Comments
 (0)