|
@@ -3,7 +3,7 @@ import Router from "next/router";
|
|
|
import ContentWrapper from "@/components/Layout/ContentWrapper";
|
|
import ContentWrapper from "@/components/Layout/ContentWrapper";
|
|
|
import { Row, Col, Button, Table, Pagination, PaginationItem, PaginationLink } from "reactstrap";
|
|
import { Row, Col, Button, Table, Pagination, PaginationItem, PaginationLink } from "reactstrap";
|
|
|
// React Slider
|
|
// React Slider
|
|
|
-import { getPT } from "@/actions/PT";
|
|
|
|
|
|
|
+import { getPT, getPembina } from "@/actions/PT";
|
|
|
import Slider from "rc-slider";
|
|
import Slider from "rc-slider";
|
|
|
import "rc-slider/assets/index.css";
|
|
import "rc-slider/assets/index.css";
|
|
|
// React Select
|
|
// React Select
|
|
@@ -18,19 +18,22 @@ import CardTool from "@/components/Common/CardTool";
|
|
|
|
|
|
|
|
import dummyData from "../PT-ID.json";
|
|
import dummyData from "../PT-ID.json";
|
|
|
|
|
|
|
|
-var pembina = [];
|
|
|
|
|
-
|
|
|
|
|
|
|
+const selectInstanceId = 1;
|
|
|
class Search extends Component {
|
|
class Search extends Component {
|
|
|
- static async getInitialProps(ctx) {
|
|
|
|
|
- pembina = [];
|
|
|
|
|
- const httpsAgent = new https.Agent({
|
|
|
|
|
- rejectUnauthorized: false,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
state = {
|
|
state = {
|
|
|
|
|
+ pembina: [],
|
|
|
selectedOptionMulti: [],
|
|
selectedOptionMulti: [],
|
|
|
data: [],
|
|
data: [],
|
|
|
|
|
+ search: "",
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ componentDidMount = async () => {
|
|
|
|
|
+ const dataPembina = await getPembina();
|
|
|
|
|
+ this.setState({ pembina: dataPembina.data });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ optionsPembina = (pembina) => {
|
|
|
|
|
+ return pembina.map((e) => ({ value: e.id, label: e.nama, className: "State-ACT" }));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
handleChangeSelectMulti = (selectedOptionMulti) => {
|
|
handleChangeSelectMulti = (selectedOptionMulti) => {
|
|
@@ -49,7 +52,6 @@ class Search extends Component {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
handleClick = (e, PT_ID) => {
|
|
handleClick = (e, PT_ID) => {
|
|
|
- const query = { ptId: PT_ID };
|
|
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
Router.push({
|
|
Router.push({
|
|
|
pathname: "/app/pemantauan/timeline",
|
|
pathname: "/app/pemantauan/timeline",
|
|
@@ -59,13 +61,13 @@ class Search extends Component {
|
|
|
|
|
|
|
|
fetchData = async () => {
|
|
fetchData = async () => {
|
|
|
const searchValue = document.getElementById("searchInput").value;
|
|
const searchValue = document.getElementById("searchInput").value;
|
|
|
|
|
+ this.setState({ search: searchValue });
|
|
|
const jsonData = await getPT({ search: searchValue });
|
|
const jsonData = await getPT({ search: searchValue });
|
|
|
- console.log(jsonData);
|
|
|
|
|
- // this.setState({ data: jsonData });
|
|
|
|
|
|
|
+ this.setState({ data: jsonData.data });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
handleApplyClick = () => {
|
|
handleApplyClick = () => {
|
|
|
- console.log("selectedOptionMulti : ", this.state.selectedOptionMulti);
|
|
|
|
|
|
|
+ // console.log("selectedOptionMulti : ", this.state.selectedOptionMulti);
|
|
|
this.fetchData();
|
|
this.fetchData();
|
|
|
if (this.state.data && this.state.data.length) {
|
|
if (this.state.data && this.state.data.length) {
|
|
|
this.renderTableData();
|
|
this.renderTableData();
|
|
@@ -74,9 +76,9 @@ class Search extends Component {
|
|
|
|
|
|
|
|
handleSearchClick = () => {
|
|
handleSearchClick = () => {
|
|
|
this.fetchData();
|
|
this.fetchData();
|
|
|
- // if (this.state.data && this.state.data.length) {
|
|
|
|
|
- // this.renderTableData();
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ if (this.state.data && this.state.data.length) {
|
|
|
|
|
+ this.renderTableData();
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
renderTableData() {
|
|
renderTableData() {
|
|
@@ -113,13 +115,11 @@ class Search extends Component {
|
|
|
);
|
|
);
|
|
|
})
|
|
})
|
|
|
);
|
|
);
|
|
|
- //}
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- // used for react select
|
|
|
|
|
- const { selectedOptionMulti } = this.state;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const { selectedOptionMulti, pembina } = this.state;
|
|
|
|
|
+ console.log(pembina);
|
|
|
return (
|
|
return (
|
|
|
<ContentWrapper>
|
|
<ContentWrapper>
|
|
|
<div className="content-heading">
|
|
<div className="content-heading">
|
|
@@ -164,7 +164,7 @@ class Search extends Component {
|
|
|
<div className="form-group mb-4">
|
|
<div className="form-group mb-4">
|
|
|
<label className="col-form-label mb-2">by Pembina</label>
|
|
<label className="col-form-label mb-2">by Pembina</label>
|
|
|
<br />
|
|
<br />
|
|
|
- <Select name="multi-select-name" multi simpleValue value={selectedOptionMulti} onChange={this.handleChangeSelectMulti} options={pembina} />
|
|
|
|
|
|
|
+ <Select instanceId={selectInstanceId + 1} isMulti value={selectedOptionMulti} onChange={this.handleChangeSelectMulti} options={pembina ? this.optionsPembina(pembina) : []} required />
|
|
|
</div>
|
|
</div>
|
|
|
<Button color="secondary" size="lg" onClick={(e) => this.handleApplyClick()}>
|
|
<Button color="secondary" size="lg" onClick={(e) => this.handleApplyClick()}>
|
|
|
Apply
|
|
Apply
|