index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import React from "react";
  2. import ContentWrapper from '@/components/Layout/ContentWrapper';
  3. import { Container, Row, Col, Card, CardBody, CardFooter, CardHeader, Input, Button } from 'reactstrap';
  4. import FormValidator from "@/components/Forms/Validator.js";
  5. import { ptPublic } from "@/actions/PT";
  6. import AsyncSelect from "react-select/async";
  7. import { loginToPt } from "../../../actions/auth";
  8. import { connect } from "react-redux";
  9. import { ToastContainer, toast } from "react-toastify";
  10. import { getCsrf } from "../../../actions/security";
  11. import Router from "next/router";
  12. const loadOptions = (inputValue, callback) => {
  13. setTimeout(async () => {
  14. const pt = await ptPublic({ search: inputValue });
  15. const data = pt?.data.map((e) => ({
  16. value: e.id,
  17. label: e.nama,
  18. className: "State-ACT",
  19. }));
  20. callback(data);
  21. }, 1000);
  22. };
  23. class BypassII extends React.Component {
  24. constructor(props) {
  25. super(props);
  26. this.state = {
  27. formLogin: {
  28. password: ""
  29. },
  30. loading: false,
  31. inputValue: "",
  32. pt_id: ""
  33. };
  34. }
  35. handleChangeSelectPerguruanTinggi = (selected_PT) => {
  36. this.setState({ pt_id: selected_PT.value });
  37. };
  38. handleClick = (e, PT_ID) => {
  39. e.preventDefault();
  40. Router.push({
  41. pathname: "/app/bypassII/detail",
  42. query: { ptId: PT_ID },
  43. });
  44. }
  45. render() {
  46. return (
  47. <ContentWrapper>
  48. <div className="content-heading">
  49. <span className="font-color-white">
  50. Bypass II
  51. </span>
  52. </div>
  53. <Container className="container-sm pt-5" >
  54. <Card
  55. style={{ margin: "20px", borderRadius: "15px" }}
  56. >
  57. <CardHeader className="text-center">
  58. <div className="card-title font-weight-bold mt-4 font-color-black"
  59. style={{ fontSize: "20px" }}
  60. >Pilih Perguruan tinggi</div>
  61. </CardHeader>
  62. <CardBody>
  63. <div className="form-group">
  64. <label className="col-form-label font-color-black mb-0 font-weight-bold">Perguruan Tinggi</label>
  65. <AsyncSelect
  66. style={{ borderRadius: "7px" }}
  67. cacheOptions
  68. loadOptions={loadOptions}
  69. defaultOptions
  70. onChange={(e) => {
  71. this.handleChangeSelectPerguruanTinggi(e);
  72. }}
  73. // onInputChange={this.handleInputChange}
  74. />
  75. <span className="invalid-feedback">Field is required</span>
  76. </div>
  77. <Button color className="btn-login float-right mt-3"
  78. style={{ borderRadius: "7px" }}
  79. onClick={(e) => this.handleClick(e, this.state.pt_id)}
  80. >
  81. <span className="font-color-white">
  82. {this.state.loading ? (
  83. <div class="d-flex justify-content-center">
  84. <div
  85. class="spinner-border spinner-border-sm"
  86. role="status"
  87. ></div>
  88. </div>
  89. ) : (
  90. "Pilih"
  91. )}
  92. </span>
  93. </Button>
  94. </CardBody>
  95. </Card>
  96. </Container>
  97. </ContentWrapper>)
  98. }
  99. }
  100. const mapStateToProps = (state) => ({ user: state.user, token: state.token });
  101. export default connect(mapStateToProps)(BypassII);