2026-05-04 01:01:36 +03:00

170 lines
5.0 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useState } from 'react'
import api from '../api'
import Toast from '../components/Toast'
import '../styles/global.css'
export default function Contact() {
const [formData, setFormData] = useState({
name: '',
email: '',
subject: '',
message: '',
})
const [loading, setLoading] = useState(false)
const [submitted, setSubmitted] = useState(false)
const [toast, setToast] = useState(null)
const handleChange = (e) => {
setFormData({
...formData,
[e.target.name]: e.target.value,
})
}
const handleSubmit = async (e) => {
e.preventDefault()
setLoading(true)
try {
await api.post('/contact', formData)
setSubmitted(true)
setFormData({
name: '',
email: '',
subject: '',
message: '',
})
setToast({ type: 'success', message: 'Message sent successfully! We\'ll get back to you soon.' })
setTimeout(() => {
setSubmitted(false)
}, 3000)
} catch (error) {
console.error('Error sending message:', error)
setToast({ type: 'error', message: 'Error sending message. Please try again.' })
} finally {
setLoading(false)
}
}
return (
<div className="contact-page">
<h1>Contact Us</h1>
<div className="contact-container">
<div className="contact-info">
<h2>Get in Touch</h2>
<div className="info-item">
<h3>📞 Phone</h3>
<p>+972 53-244-1361</p>
</div>
<div className="info-item">
<h3> Email</h3>
<p>info@brandmaster.com</p>
</div>
<div className="info-item">
<h3>Follow Us</h3>
<div className="social-icons">
<a
href="https://instagram.com"
target="_blank"
rel="noopener noreferrer"
className="social-icon instagram"
title="Follow us on Instagram"
>
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect>
<path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path>
<line x1="17.5" y1="6.5" x2="17.51" y2="6.5"></line>
</svg>
<span>Instagram</span>
</a>
<a
href="https://wa.me/972532441361"
target="_blank"
rel="noopener noreferrer"
className="social-icon whatsapp"
title="Contact us on WhatsApp"
>
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path>
</svg>
<span>WhatsApp</span>
</a>
</div>
</div>
</div>
<form onSubmit={handleSubmit} className="contact-form">
<h2>Send us a Message</h2>
{submitted && (
<div className="success-message">
Message sent successfully! We'll get back to you soon.
</div>
)}
<div className="form-group">
<label>Name</label>
<input
type="text"
name="name"
value={formData.name}
onChange={handleChange}
required
/>
</div>
<div className="form-group">
<label>Email</label>
<input
type="email"
name="email"
value={formData.email}
onChange={handleChange}
required
/>
</div>
<div className="form-group">
<label>Subject</label>
<input
type="text"
name="subject"
value={formData.subject}
onChange={handleChange}
required
/>
</div>
<div className="form-group">
<label>Message</label>
<textarea
name="message"
rows="5"
value={formData.message}
onChange={handleChange}
required
></textarea>
</div>
<button type="submit" className="btn btn-full" disabled={loading}>
{loading ? 'Sending...' : 'Send Message'}
</button>
</form>
</div>
{toast && (
<Toast
message={toast.message}
type={toast.type}
onClose={() => setToast(null)}
/>
)}
</div>
)
}