54 行
1.8 KiB
JavaScript
54 行
1.8 KiB
JavaScript
import React, { useEffect, useState } from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import { Button } from '@material-ui/core';
|
|
import { LoadingButton } from '@material-ui/lab';
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
const Contact = () => {
|
|
const [email, setEmail] = useState('');
|
|
const [text, setText] = useState('');
|
|
|
|
const handleSubmit = () => {
|
|
e.preventDefault();
|
|
const formdata = new FormData();
|
|
formdata.append('email', email);
|
|
formdata.append('text', text);
|
|
|
|
axios.post('/contacts/register/', formdata)
|
|
.then(response => {
|
|
if(response.status==200){
|
|
window.location.href = '/contact-us/complete';
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit}>
|
|
<p className="text-center font-weight-bold ft-20">お問い合わせ</p>
|
|
<div className="c-input mt-4">
|
|
<label htmlFor="email" className="c-input__label"> メールアドレス </label>
|
|
<input type="email" name="email" id="email" className="w-100 c-input__edit is-invalid" value={email} onChange={e=>setEmail(e.target.value)} required autoFocus/>
|
|
</div>
|
|
|
|
<div className="c-input mt-4">
|
|
<label htmlFor="text" className="c-input__label"> お問合せ内容 </label>
|
|
<textarea name="text" id="text" rows="7" className="w-100 c-input__edit is-invalid" value={text} onChange={e=>setText(e.target.value)} required/>
|
|
</div>
|
|
|
|
<div className="mt-4">
|
|
<LoadingButton type="submit" fullWidth className="p-3 rounded-20 ft-15 font-weight-bold text-black bg-color-2">送信</LoadingButton>
|
|
</div>
|
|
</form>
|
|
)
|
|
}
|
|
|
|
|
|
if(document.getElementById('contact')){
|
|
ReactDOM.render(
|
|
<Contact />,
|
|
document.getElementById('contact')
|
|
)
|
|
} |