import { FreeMode, Autoplay } from "swiper"; import { Swiper, SwiperSlide } from "swiper/react"; import ArrowRight from "../../../public/assets/imgs/portfolio/11/arrow-right.png"; import Link from "next/link"; import Image from "next/image"; import { useState } from "react"; import { toast } from 'react-hot-toast'; // Import Swiper styles import "swiper/css"; import "swiper/css/autoplay"; import "swiper/css/free-mode"; import { useEffect, useRef } from "react"; export default function Footer5() { const menuAnim = useRef(); const menuAnim2 = useRef(); useEffect(() => { if (menuAnim.current) { menuAnimation(menuAnim); } if (menuAnim2.current) { menuAnimation(menuAnim2); } }, []); const menuAnimation = (data) => { let rootParent = data.current.children; for (let i = 0; i < rootParent.length; i++) { let firstParent = rootParent[i].children; let arr = firstParent[0].textContent.split("") let spanData = '' for (let j = 0; j < arr.length; j++) { if (arr[j] == ' ') { spanData += `${arr[j]}`; } else { spanData += `${arr[j]}`; } } let result = '
'; firstParent[0].innerHTML = result } }; const [formData, setFormData] = useState({ timestamp: new Date().toLocaleString() + "", email: "", sheetId: process.env.NEXT_PUBLIC_SUBSCRIBERS_SHEET_ID }); const handleChange = (e) => { setFormData({ ...formData, [e.target.name]: e.target.value, }); }; const handleSubmit = async (e) => { e.preventDefault(); try { toast.loading('Adding your email to our newsletter...') await fetch("/api/sheets/subscribers-sheet", { method: "POST", body: JSON.stringify(formData), headers: { "Content-Type": "application/json", }, }); setFormData({ timestamp: new Date().toLocaleString() + "", email: "", sheetId: process.env.NEXT_PUBLIC_SUBSCRIBERS_SHEET_ID }) toast.dismiss(); toast.success('You have successfully subscribed to our newsletter!'); } catch (error) { toast.error('Opps! Something Went Wrong...') console.error("Error submitting form:", error); } }; return ( <> > ); }