import { Card, CardDescription, CardHeader, CardTitle } from "./ui/card";
import { MagnifierIcon, WalletIcon, ChartIcon } from "./Icons";
import cubeLeg from "../assets/cube-leg.png";
import {useEffect, useState} from "react";
import {extractSubstring} from "@/services/api.ts";
import axios from "axios";
interface ServiceProps {
title: string;
content: string;
icon: JSX.Element;
}
let serviceList: ServiceProps[] = [];
const iconList = [, , ];
// const serviceList: ServiceProps[] = [
// {
// title: "Code Collaboration",
// description:
// "Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi nesciunt est nostrum omnis ab sapiente.",
// icon: ,
// },
// {
// title: "Project Management",
// description:
// "Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi nesciunt est nostrum omnis ab sapiente.",
// icon: ,
// },
// {
// title: "Task Automation",
// description:
// "Lorem ipsum dolor sit amet consectetur adipisicing elit. Nisi nesciunt est nostrum omnis ab sapiente.",
// icon: ,
// },
// ];
export const Services = () => {
const [loading, setLoading] = useState(true);
useEffect(() => {
// 使用 axios 进行 API 调用
const fetchData = async () => {
try {
const websiteCode = extractSubstring(window.location.pathname);
const response = await axios.get('/api/website/template/getWebsiteByWebsiteCode', {
params: {
websiteCode: websiteCode
}
});
const userWebsiteId = response.data.data.id;
const response2 = await axios.get('/api/website/template/blogs', {
params: {
userWebsiteId: userWebsiteId
}
});
serviceList = response2.data.data.map((item, index) => {
return {
title: item.name,
content: item.content.substring(0, 200) + '...',
icon: iconList[index % iconList.length],
}
})
} catch (err) {
console.error('Error fetching data:', err);
} finally {
setLoading(false);
}
};
fetchData();
}, []);
// 处理加载和错误状态
if (loading) {
return
Loading...
;
}
return (
Blog
Latest blog.
{serviceList.map(({ icon, title, content }: ServiceProps) => (
{icon}
{title}
{content}
))}
);
};