import React, { useEffect, useRef, useState } from "react" import { Col, Row, Table } from "reactstrap" import { format_angka } from "../util" import collect from "collect.js" const date = new Date() const cBulan = date.getMonth() + 1 const Sof = ({ dataSend }) => { const base_url = "" const [data, setData] = useState([]) const [total, setTotal] = useState({ totalC: 0, totalP1: 0, totalP2: 0 }) useEffect(() => { jQuery.get({ url: base_url + "kewilayahan/kytp/sebaranSof", dataType: "json", type: "POST", data: { ...dataSend, tahun: date.getFullYear(), bulan: cBulan }, success: (data) => { console.log(data) setData(data.data) setTotal({ totalC: collect(data.data).sum("JML_C"), totalP1: collect(data.data).sum("JML_P1"), totalP2: collect(data.data).sum("JML_P2") }) } }) }, [dataSend]) return ( <>
{data.map((val, idx) => { return ( ) })}
Lapisan s.d Sekarang s.d Bulan Lalu s.d 2 Bulan Lalu
Jml WP % Jml WP % Jml WP %
1 2 3 4 5 6 7
{val.LAPISAN} {val.JML_C} {((val.JML_C / total.totalC) * 100).toFixed(2) + "%"} {val.JML_P1} {((val.JML_P1 / total.totalP1) * 100).toFixed(2) + "%"} {val.JML_P2} {((val.JML_P2 / total.totalP2) * 100).toFixed(2) + "%"}
Total {total.totalC} 100% {total.totalP1} 100% {total.totalP2} 100%
) } export default Sof