42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
import { getSingleWebContents } from "@/utils/commonApi";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
export default function AboutUs() {
|
|
const [title, setTitle] = useState("AboutUs");
|
|
|
|
const { data, isLoading, isError, refetch } = useQuery({
|
|
queryKey: ["WebContents", title],
|
|
queryFn: () => getSingleWebContents(title),
|
|
refetchOnWindowFocus: false,
|
|
});
|
|
console.log(data);
|
|
|
|
useEffect(() => {
|
|
refetch();
|
|
}, [title, refetch]);
|
|
|
|
if (isLoading) {
|
|
return <p>Loading...</p>;
|
|
}
|
|
if (isError) {
|
|
return <p>Error fetching content.</p>;
|
|
}
|
|
|
|
const fetchedContent = data?.content || ""; // Assuming your API response has a 'content' property
|
|
|
|
return (
|
|
<div className="bg-white dark:bg-gray-900 w-screen pt-8">
|
|
<div
|
|
className="container flex font-[yekan]
|
|
text-[#7C838A] dark:text-white text-base font-medium leading-6 tracking-wide 3xl:text-lg 3xl:font-bold"
|
|
>
|
|
{/* Display fetched content */}
|
|
<div dangerouslySetInnerHTML={{ __html: fetchedContent }} />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|