import React, { useState, useEffect } from 'react'; import { motion } from 'framer-motion'; import { contactService } from '../services/contactService'; import { fadeIn, slideUp, staggerChildren } from '../utils/motionVariants'; const Contact = () => { const [contactInfo, setContactInfo] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetchContactInfo(); }, []); const fetchContactInfo = async () => { try { setLoading(true); const response = await contactService.get(); if (response.success) { setContactInfo(response.data); } else { setError('Failed to load contact information'); } } catch (err) { setError('Failed to load contact information'); console.error('Error fetching contact info:', err); } finally { setLoading(false); } }; const defaultContact = { address: 'Jl. Mastrip PO Box 164, Jember 68121, Jawa Timur, Indonesia', phone: '+62 331-123456', email: 'satgasppkpt@polije.ac.id', instagram: '@satgasppkpt_polije', whatsapp: '+62 812-3456-7890' }; const contact = contactInfo || defaultContact; const contactMethods = [ { icon: ( ), label: 'Telepon', value: contact.phone, href: `tel:${contact.phone}`, color: 'text-primary' }, { icon: ( ), label: 'Email', value: contact.email, href: `mailto:${contact.email}`, color: 'text-primary' }, { icon: ( ), label: 'WhatsApp', value: contact.whatsapp, href: `https://wa.me/${contact.whatsapp?.replace(/[^0-9]/g, '')}`, color: 'text-accent' } ]; const socialMedia = [ { name: 'Instagram', icon: ( ), href: `https://instagram.com/${contact.instagram?.replace('@', '')}`, color: 'hover:text-pink-600' } ]; return (
{/* Background Pattern */}
{/* Section Header */} Hubungi Kami Kami siap membantu Anda. Jangan ragu untuk menghubungi kami melalui berbagai metode komunikasi yang tersedia. {/* Loading State */} {loading && (

Memuat informasi kontak...

)} {/* Contact Content */} {!loading && (
{/* Contact Information */}

Informasi Kontak

{/* Contact Methods */}
{contactMethods.map((method, index) => (
{method.icon}

{method.label}

{method.value}
))}
{/* Address */}

Alamat

{contact.address}

{/* Social Media */}

Ikuti Kami

{socialMedia.map((social, index) => ( {social.icon} ))}
{/* Emergency Contact */}

Butuh Bantuan Darurat?

Jika Anda atau orang lain berada dalam situasi darurat, segera hubungi kami untuk respons cepat 24/7.

Hubungi WhatsApp Darurat
Respons 24/7 - Privasi Terjamin
)}
); }; export default Contact;