"use client"; import React, { useEffect, useState } from "react"; import axios from "axios"; export default function CallToAction() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchData() { try { setLoading(true); const res = await axios.get("/api/get-component-data", { params: { component_name: "CallToAction" }, }); setData(res.data.data); } catch (err) { setError("获取CallToAction数据失败"); } finally { setLoading(false); } } fetchData(); }, []); if (loading) return
Loading...
; if (error) return null; if (!data) return null; const title = data.title || ""; const subtitle = data.subtitle || ""; const buttonText = data.button_text || ""; const icon = data.icon || "/files/icon.svg"; const htmlCode = data.html_code || ""; return (
{htmlCode ? (
) : ( icon )}

{title}

{subtitle}

{/* /column */}
{/* /.row */}
{/* Begin Mailchimp Signup Form */}
e.preventDefault()} id="mc-embedded-subscribe-form2" name="mc-embedded-subscribe-form" className="validate" >
{/* real people should not fill this in and expect good things - do not remove this or risk form bot signups*/}
{/*End mc_embed_signup*/}
{/* /.newsletter-wrapper */}
{/* /column */}
{/* /.row */}
{/* /.container */}
); }