|
@@ -15,6 +15,7 @@ class Search extends Component {
|
|
|
pembina: [],
|
|
pembina: [],
|
|
|
selectedOptionMulti: [],
|
|
selectedOptionMulti: [],
|
|
|
data: [],
|
|
data: [],
|
|
|
|
|
+ nodata: false,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
componentDidMount = async () => {
|
|
componentDidMount = async () => {
|
|
@@ -53,27 +54,44 @@ class Search extends Component {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
fetchData = async () => {
|
|
fetchData = async () => {
|
|
|
- const pembina = this.props.user.role.id === 2021 ? null : this.state.selectedOptionMulti.map((e) => e.value).join(",");
|
|
|
|
|
|
|
+ const pembina = this.props.user.role.id === 2021 ? null : this.state.selectedOptionMulti?.map((e) => e.value).join(",");
|
|
|
const searchValue = document.getElementById("searchInput").value;
|
|
const searchValue = document.getElementById("searchInput").value;
|
|
|
const jsonData = await getPT(this.props.token, { search: searchValue, pembina });
|
|
const jsonData = await getPT(this.props.token, { search: searchValue, pembina });
|
|
|
this.setState({ data: jsonData.data ? jsonData.data : [] });
|
|
this.setState({ data: jsonData.data ? jsonData.data : [] });
|
|
|
|
|
+ // console.log(this.state.data)
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleApplyClick = () => {
|
|
|
|
|
- this.fetchData();
|
|
|
|
|
- if (this.state.data && this.state.data.length) {
|
|
|
|
|
- this.renderTableData();
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ // handleApplyClick = () => {
|
|
|
|
|
+ // this.fetchData();
|
|
|
|
|
+ // if (this.state.data && this.state.data.length > 0) {
|
|
|
|
|
+ // this.renderTableData();
|
|
|
|
|
+ // this.setState({ noData: true });
|
|
|
|
|
+ // // this.setState({ noData: false });
|
|
|
|
|
+
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.checknodata();
|
|
|
|
|
+ // // else {
|
|
|
|
|
+ // // this.setState({ noData: true })
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // handleSearchClick = () => {
|
|
|
|
|
+ // this.fetchData();
|
|
|
|
|
+ // if (this.state.data && this.state.data.length) {
|
|
|
|
|
+ // this.renderTableData();
|
|
|
|
|
+ // this.setState({ noData: true });
|
|
|
|
|
+ // // this.setState({ noData: false });
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else {
|
|
|
|
|
+ // // this.setState({ noData: true });
|
|
|
|
|
+
|
|
|
|
|
+ // this.checknodata();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // };
|
|
|
|
|
|
|
|
- handleSearchClick = () => {
|
|
|
|
|
- this.fetchData();
|
|
|
|
|
- if (this.state.data && this.state.data.length) {
|
|
|
|
|
- this.renderTableData();
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
|
|
|
renderTableData() {
|
|
renderTableData() {
|
|
|
|
|
+ console.log(this.state.data)
|
|
|
return (
|
|
return (
|
|
|
this.state.data &&
|
|
this.state.data &&
|
|
|
this.state.data.map((pt, index) => {
|
|
this.state.data.map((pt, index) => {
|
|
@@ -112,6 +130,22 @@ class Search extends Component {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ handleApplyClick = () => {
|
|
|
|
|
+ this.fetchData();
|
|
|
|
|
+ if (this.state.data && this.state.data.length > 0) {
|
|
|
|
|
+ this.renderTableData();
|
|
|
|
|
+ this.setState({ noData: true });
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ handleSearchClick = () => {
|
|
|
|
|
+ this.fetchData();
|
|
|
|
|
+ if (this.state.data && this.state.data.length) {
|
|
|
|
|
+ this.renderTableData();
|
|
|
|
|
+ this.setState({ noData: true });
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
const { selectedOptionMulti, pembina } = this.state;
|
|
const { selectedOptionMulti, pembina } = this.state;
|
|
|
return (
|
|
return (
|
|
@@ -133,6 +167,7 @@ class Search extends Component {
|
|
|
onKeyPress={(e) => {
|
|
onKeyPress={(e) => {
|
|
|
if (e.key === "Enter") {
|
|
if (e.key === "Enter") {
|
|
|
this.handleApplyClick();
|
|
this.handleApplyClick();
|
|
|
|
|
+ this.handleSearchClick();
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
@@ -158,7 +193,7 @@ class Search extends Component {
|
|
|
</Table>
|
|
</Table>
|
|
|
{/* END table-responsive */}
|
|
{/* END table-responsive */}
|
|
|
<div className="card-footer">
|
|
<div className="card-footer">
|
|
|
- <div className="d-flex"></div>
|
|
|
|
|
|
|
+ <div >{!this.state.data.length > 0 && this.state.noData && (<h3 className=" text-center">Data tidak ditemukan</h3>)}</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
{/* END card */}
|
|
{/* END card */}
|