| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 | import React, { Component } from "react";import ContentWrapper from "@/components/Layout/ContentWrapper";import Link from "next/link";import { Row, Col, Button } from "reactstrap";import { getPelaporan } from "@/actions/pelaporan";import { getGraph } from "@/actions/graph";import CaseProgress from "@/components/Pelaporan/CaseProgress";import TableLaporan from "@/components/Main/TableLaporan";import { connect } from "react-redux";import Loader from "@/components/Common/Loader";class Pelaporan extends Component {	constructor(props) {		super(props);		this.state = {			pelaporan: {},			graph: {},			tahun: new Date().getFullYear(),			newLaporan: [],		};	}	componentDidMount = async () => {		const pelaporan = await getPelaporan(this.props.token);		const graph = await getGraph(this.props.token, { laporanTahun: true, newLaporan: true });		const newLaporan = graph.data.newLaporan;		this.setState({ pelaporan, graph, newLaporan });	};	nextButton = async () => {		const tahun = this.state.tahun + 1;		const graph = await getGraph(this.props.token, { laporanTahun: true, tahun });		this.setState({ graph, tahun });	};	prevButton = async () => {		const tahun = this.state.tahun - 1;		const graph = await getGraph(this.props.token, { laporanTahun: true, tahun });		this.setState({ graph, tahun });	};	shouldComponentUpdate = (prevProps, prevState) => {		if (prevState.graph !== this.state.graph) return true;	};	render() {		const { pelaporan, graph, newLaporan } = this.state;		return (			<ContentWrapper>				<div className="content-heading">					Pelaporan					<div className="ml-auto"></div>					<Link href="/app/penjadwalan">						<Button className="btn-header" color="info">							<h4>Penjadwalan ></h4>						</Button>					</Link>				</div>				<Row>					<Col lg="4">{graph?.data ? <CaseProgress data={graph.data} nextButton={this.nextButton} prevButton={this.prevButton} tahun={this.state.tahun} newLaporan={newLaporan} /> : <Loader />}</Col>					<Col lg="8">						<div className="mb-3 d-flex">							<div>								<Link href="/app/pelaporan/search">									<Button color="primary">Laporan Baru</Button>								</Link>							</div>						</div>						{pelaporan?.data ? <TableLaporan listData={pelaporan.data} to="/app/pelaporan/detail" linkName="Detail" /> : <Loader />}					</Col>				</Row>			</ContentWrapper>		);	}}const mapStateToProps = (state) => ({ user: state.user, token: state.token });export default connect(mapStateToProps)(Pelaporan);
 |