import React, { Component } from "react";
import BasePage from "@/components/Layout/BasePage";
import { getPT } from "@/actions/PT";
import { getPelanggaran } from "@/actions/pelanggaran";
import Select from "react-select";
import AsyncSelect from "react-select/async";
import { Row, Col, FormGroup, Input, Card, CardBody, Button, CustomInput, Navbar, NavItem, NavLink, NavbarBrand, NavbarToggler, Nav, Collapse } from "reactstrap";
import ContentWrapper from "@/components/Layout/ContentWrapper";
import Link from "next/link";

const loadOptions = (inputValue, callback) => {
	setTimeout(async () => {
		const pt = await getPT({ search: inputValue });
		const data = pt.data.map((e) => ({ value: e.id, label: e.nama, className: "State-ACT" }));
		callback(data);
	}, 1000);
};

const menu = [
	{
		title: "Home",
		path: "/app",
	},
	{
		title: "Membuat Laporan",
		path: "/laporan/new",
	},
	{
		title: "Pemantauan",
		path: "/pemantauan",
	},
	{
		title: "Login",
		path: "/login",
	},
];
const selectInstanceId = 1;
class App extends Component {
	constructor(props) {
		super(props);
		this.state = {
			isOpen: false,
		};
	}

	static getInitialProps = ({ pathname }) => ({ pathname });

	toggleCollapse = () => {
		this.setState({
			isOpen: !this.state.isOpen,
		});
	};

	render() {
		return (
			<div>
				<Navbar color="info" expand="md" dark>
					<NavbarBrand href="/">
						<img className="img-fluid" src="/static/img/logo-single.png" alt="App Logo" /> Aldila Dikti
					</NavbarBrand>
					<NavbarToggler onClick={this.toggleCollapse} />
					<Collapse isOpen={this.state.isOpen} navbar>
						<Nav className="ml-auto" navbar>
							{menu.map((e) => (
								<NavItem active={e.path === this.props.pathname ? true : false}>
									<Link href={e.path}>
										<NavLink style={{ cursor: "pointer" }}>{e.title}</NavLink>
									</Link>
								</NavItem>
							))}
						</Nav>
					</Collapse>
				</Navbar>
				<ContentWrapper>
					<Row>
						<Col lg={8} className="block-center d-block "></Col>
					</Row>
				</ContentWrapper>
			</div>
		);
	}
}

App.Layout = BasePage;

export default App;
