"use client"; import IconTrashLines from '@/components/icon/icon-trash-lines'; import PanelCodeHighlight from '@/components/panel-code-highlight'; import ComponentsTablesSimple from '@/components/tables/components-tables-simple' import { formatUnixTimestamp } from '@/utils/helpers'; import Tippy from '@tippyjs/react'; import axios from 'axios'; import React, { useEffect, useState } from "react" type Props = {} const SungrowPlant = (props: Props) => { const [sites, setSites] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { const fetchSites = async () => { try { const res = await fetch("/api/sungrow/site") const data = await res.json() console.log("data", data) setSites(data) } catch (error) { console.error("Error fetching inverters:", error) } finally { setLoading(false) } } fetchSites() }, []) const statusLabels: Record = { 0: "Offline", 1: "Normal", } const plantTypeLabel: Record = { 3: "Commercial PV", 4: "Residential PV", } return (
{loading ?

Loading...

: (
{/* */} {sites.map((data) => ( {/* */} ))}
Site Name Status Plant TypeInstalled Power Real-time Power Yield Today Monthly Yield Annual Yield Total Yield Equivalent Hours RemarksAction
{data.ps_name}
{statusLabels[data.online_status] || "-"}
{plantTypeLabel[data.ps_type] || "-"}
)}
) } export default SungrowPlant