import { useState } from 'react' import { useMutation } from '@tanstack/react-query' import { toast } from 'sonner' import { Button } from '@/components/ui/Button' import { Input } from '@/components/ui/Input' import { Textarea } from '@/components/ui/Textarea' import { Select } from '@/components/ui/Select' import { api } from '@/lib/api' const Support = () => { const [formState, setFormState] = useState({ name: '', company: '', email: '', phone: '', issue: '', priority: 'medium', }) const [errors, setErrors] = useState({ name: '', company: '', email: '', issue: '', }) const mutation = useMutation({ mutationFn: (data) => api.post('/support', data), onSuccess: () => { toast.success('Thanks! We\'ll get back to you soon.') setFormState({ name: '', company: '', email: '', phone: '', issue: '', priority: 'medium', }) setErrors({ name: '', company: '', email: '', issue: '', }) }, onError: (error) => { toast.error(error.message || 'Failed to submit form. Please try again.') }, }) const validateForm = () => { const newErrors = { name: '', company: '', email: '', issue: '', } // Validate required fields if (!formState.name.trim()) newErrors.name = 'Name is required' if (!formState.company.trim()) newErrors.company = 'Company name is required' if (!formState.issue.trim()) newErrors.issue = 'Please describe your issue' // Validate email format const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ if (!formState.email.trim()) { newErrors.email = 'Email is required' } else if (!emailRegex.test(formState.email)) { newErrors.email = 'Please enter a valid email address' } // Validate issue minimum length (10 chars matches server-side Zod rule) if (formState.issue.trim().length < 10) { newErrors.issue = 'Issue description must be at least 10 characters' } const hasErrors = Object.values(newErrors).some(error => error !== '') setErrors(newErrors) if (hasErrors) { toast.error('Please fix the errors in the form') return false } return true } const handleSubmit = (e) => { e.preventDefault() if (!validateForm()) return mutation.mutate(formState) } const handleChange = (e) => { const { name, value } = e.target setFormState(prev => ({ ...prev, [name]: value })) // Clear error for this field as user types if (errors[name]) { setErrors(prev => ({ ...prev, [name]: '' })) } } return (
Need help with your communications or infrastructure? Submit a support request and we'll get back to you promptly.
We provide comprehensive support for all our services, including 24/7 monitoring, rapid response, and dedicated support engineers.
(906) 482-6616
24/7 Monitoring with rapid response SLAs
Low: General inquiries (response within 24 hours)
Medium: Standard issues (response within 4 hours)
High: Critical issues (response within 1 hour)