forked from GANESH-ICMC/ganesh-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontato.js
269 lines (254 loc) · 10.3 KB
/
contato.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import React from 'react';
import { Component } from 'react';
import Head from '../shared/components/head';
import Navbar from '../shared/components/navbar/navbar';
import Footer from '../shared/components/footer';
import {Trans, withTranslation} from 'react-i18next';
import { loadScriptFromURL } from '../shared/load_script';
class Contact extends Component {
componentDidMount() {
loadScriptFromURL("https://www.google.com/recaptcha/api.js");
document.getElementById("contact-form").addEventListener('submit', this.formSubmit);
window.sendEmail = this.sendEmail;
}
sendEmail() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "api/contact/email");
xhr.onload = function(event) {
if (xhr.status === 200) {
document.getElementById("contact-form").reset();
document.getElementById("contact-form-msg-success").style.display = 'inline-block';
} else {
document.getElementById("contact-form-msg-error").style.display = 'inline-block';
}
grecaptcha.reset();
document.getElementById("form-contact-button").disabled = false;
};
var formData = new FormData(document.getElementById("contact-form"));
xhr.send(formData);
}
formSubmit(e) {
e.preventDefault();
document.getElementById("contact-form-msg-success").style.display = 'none';
document.getElementById("contact-form-msg-error").style.display = 'none';
document.getElementById("form-contact-button").disabled = true;
grecaptcha.execute();
}
render() {
const { t } = this.props;
return (
<React.Fragment>
<Head
title="Ganesh - Contact"
description='Extracurricular group focused on information security.'
/>
<Navbar />
<main>
<div className="flex justify-center items-center bg-fixed bg-cover bg-center container-top shadow-md">
<h1 className="text-4xl text-center text-white"><Trans i18nKey="contact:title">Contact</Trans></h1>
</div>
<div className="container mx-auto px-4 py-8">
<div className="flex bg-white my-4 rounded-lg shadow-md">
<div className="p-2 xl:p-4">
<div className="fb-page">
<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2FganeshICMC&tabs=messages%2Ctimeline%2Cevents&width=200&height=400&small_header=true&adapt_container_width=true&hide_cover=false&show_facepile=true&appId" width="200" height="400" scrolling="no" frameBorder="0" allowtransparency="true" allow="encrypted-media"></iframe>
</div>
<p className="hidden lg:block text-sm contact-a">
<a href="https://github.com/GANESH-ICMC" target="_blank">Github</a>
<a href="mailto:[email protected]">E-mail</a>
</p>
</div>
<div className="py-2 pr-2 xl:py-4 xl:pr-4 contact-form">
<h2 className="news-title sm:text-lg"> <Trans i18nKey="contact:visitsocial">
Visit our social pages or e-mail us.
</Trans></h2>
<form action="/api/contact/email" method="post" className="form" id="contact-form">
<div className="text-input">
<label htmlFor="form-contact-mail"><Trans i18nKey="contact:email">Your e-mail:</Trans></label>
<span>
<input type="email" name="sender" id="form-contact-mail" required="required" />
</span>
</div>
<div className="text-input">
<label htmlFor="form-contact-subject"><Trans i18nKey="contact:subject">Subject:</Trans></label>
<span>
<input type="text" name="topic" id="form-contact-subject" required="required" />
</span>
</div>
<div className="textarea-input">
<label htmlFor="form-contact-body"><Trans i18nKey="contact:message">Message:</Trans></label>
<span>
<textarea name="text" id="form-contact-body" required="required"></textarea>
</span>
</div>
<div className="g-recaptcha"
data-sitekey="6Lf1S6AaAAAAAPol7TZH0VCmlPFnFQCRBRYXlmRv"
data-callback="sendEmail"
data-size="invisible">
</div>
<div className="submit-input">
<button type="submit" id="form-contact-button">Send »</button>
</div>
<div className="reply-input">
<div id="contact-form-msg-success" className='bg-gray-300 rounded-lg shadow-md font-bold flex flex-col items-center justify-center p-8 md:p-4' style={{display: "none"}}>
<span>
<p>Email sent. Thank you very much for your interest!</p>
</span>
</div>
<div id="contact-form-msg-error" className='bg-gray-300 rounded-lg shadow-md font-bold text-red-700 flex flex-col items-center justify-center p-8 md:p-4' style={{display: "none"}}>
<span>
<p>Something went wrong. Please try again.</p>
</span>
</div>
</div>
</form>
</div>
</div>
</div>
<style type="text/css">{`
.fb-page iframe {
border:none;
overflow:hidden;
}
.contact-form {
width: 100%;
}
.form {
display: block;
margin-top: 15px;
}
.form .text-input, .form .textarea-input, .form .submit-input {
margin-bottom: 25px;
}
.form .text-input span, .form .textarea-input span {
display: block;
margin-top: 5px;
}
.form .text-input span input, .form .textarea-input span textarea {
display: block;
border-style: solid;
border-width: 0px 0px 2px 0px;
border-color: rgba(0, 0, 0, 0.25);
outline-width: 0px;
margin: 0px 0px;
max-width: 500px;
padding: 5px;
box-sizing: border-box;
width: 100%;
transition: border-color 0.25s;
}
.form .textarea-input span textarea {
border-width: 2px;
min-width: 100%;
max-width: 100%;
width: 100%;
min-height: 100px;
height: 150px;
}
.form .text-input span input:hover, .form .textarea-input span textarea:hover {
border-color: rgba(0, 0, 0, 1);
}
.form .text-input span input:focus, .form .textarea-input span textarea:focus {
border-color: rgba(66, 220, 163, 1);
}
.form .text-input p, .form .textarea-input p {
display: block;
margin-top: 5px;
font-size: 0.8em;
text-align: justify;
}
.form .submit-input {
text-align: center;
}
.form .submit-input button {
display: inline-block;
margin: 2px;
padding: 10px;
border-style: solid;
border-width: 2px;
border-color: rgb(66, 220, 163);
cursor: pointer;
color: rgb(66, 220, 163);
background-color: rgb(255, 255, 255);
transition: background-color,color 0.25s,0.25s;
}
.form .submit-input button:hover {
color: rgb(0, 0, 0);
background-color: rgb(66, 220, 163);
}
.form .reply-input {
text-align: center;
}
.fb-page, .fb-page * {
position: static !important;
}`}
</style>
<style jsx>{`
.contact-a {
display: block;
margin-top: 15px;
text-align: center;
}
.contact-a a {
display: inline-block;
background-color: transparent;
color: #42dca3;
border-color: #42dca3;
border-style: solid;
border-width: 1px;
padding: 15px;
margin: 5px;
}
.contact-a a:hover {
background-color: #42dca3;
color: black;
}
.container-top {
background-image: url(/static/images/bgfull.jpg);
height: 250px;
}
.news-image {
background-image: url(/static/images/400.jpg);
height: 75px;
width: 75px;
}
.news-title {
font-size: 0.75rem;
}
.news-date {
display: none;
}
@media (min-width: 480px) {
.news-title {
font-size: 1rem;
}
}
@media (min-width: 580px) {
.news-date {
display: block;
}
}
@media (min-width: 640px) {
.news-image {
height: 150px;
width: 150px;
}
.news-title {
font-size: 1.125rem;
}
}
@media (min-width: 1024px) {
.news-image {
height: 200px;
width: 200px;
}
}
`}</style>
</main>
<Footer />
</React.Fragment>
)
}
}
//export default Contact;
export default withTranslation()(Contact);