detail.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. import React, { Component } from "react";
  2. import Link from "next/link";
  3. import Select from "react-select";
  4. import Datatable from "@/components/Tables/Datatable";
  5. import DetailSanksi from "@/components/Main/DetailSanksi";
  6. import Header from "@/components/Main/Header";
  7. import DetailPT from "@/components/Main/DetailPT";
  8. import { getSanksi } from "@/actions/sanksi";
  9. import ContentWrapper from "@/components/Layout/ContentWrapper";
  10. import {
  11. Row,
  12. Col,
  13. Card,
  14. CardHeader,
  15. CardBody,
  16. CardTitle,
  17. FormGroup,
  18. FormFeedback,
  19. FormText,
  20. Label,
  21. InputGroup,
  22. InputGroupAddon,
  23. InputGroupButtonDropdown,
  24. InputGroupText,
  25. Input,
  26. Button,
  27. DropdownToggle,
  28. DropdownMenu,
  29. CustomInput,
  30. DropdownItem,
  31. } from "reactstrap";
  32. let Dropzone = null;
  33. class DropzoneWrapper extends Component {
  34. state = {
  35. isClient: false,
  36. };
  37. componentDidMount = () => {
  38. Dropzone = require("react-dropzone").default;
  39. this.setState({ isClient: true });
  40. };
  41. render() {
  42. return Dropzone ? <Dropzone {...this.props}>{this.props.children}</Dropzone> : null;
  43. }
  44. }
  45. const selectInstanceId = 1;
  46. class UploadKeberatan extends Component {
  47. constructor(props) {
  48. super(props);
  49. this.state = {
  50. selectedOption: null,
  51. files: [],
  52. };
  53. }
  54. static getInitialProps = async ({ query }) => {
  55. const sanksi = await getSanksi(query);
  56. return { sanksi, query };
  57. };
  58. handleChangeSelect = (selectedOption) => {
  59. this.setState({ selectedOption });
  60. };
  61. onDrop = (files) => {
  62. this.setState({
  63. files: files.map((file) =>
  64. Object.assign(file, {
  65. preview: URL.createObjectURL(file),
  66. })
  67. ),
  68. stat: "Added " + files.length + " file(s)",
  69. });
  70. };
  71. uploadFiles = (e) => {
  72. e.preventDefault();
  73. e.stopPropagation();
  74. this.setState({
  75. stat: this.state.files.length ? "Dropzone ready to upload " + this.state.files.length + " file(s)" : "No files added.",
  76. });
  77. };
  78. clearFiles = (e) => {
  79. e.preventDefault();
  80. e.stopPropagation();
  81. this.setState({
  82. stat: this.state.files.length ? this.state.files.length + " file(s) cleared." : "No files to clear.",
  83. });
  84. this.setState({
  85. files: [],
  86. });
  87. };
  88. render() {
  89. const { files } = this.state;
  90. const { sanksi } = this.props;
  91. console.log(sanksi);
  92. const thumbs = files.map((file, index) => (
  93. <Col md={3} key={index}>
  94. <img className="img-fluid mb-2" src={file.preview} alt="Item" />
  95. </Col>
  96. ));
  97. return (
  98. <ContentWrapper unwrap>
  99. <Header />
  100. <div className="p-3">
  101. <div className="content-heading">
  102. <div>
  103. Permohonan Keberatan
  104. {/* <small>Form pembuatan laporan baru v.0.1</small> */}
  105. </div>
  106. <div className="ml-auto">
  107. <Link href="/app/pt/keberatan">
  108. <button className="btn btn-sm btn-secondary text-sm">&lt; back</button>
  109. </Link>
  110. </div>
  111. </div>
  112. <Row>
  113. <Col xl="9">
  114. <Card className="card-default">
  115. {/* <CardHeader>
  116. <label>Informasi Dokumen</label>
  117. </CardHeader> */}
  118. <CardBody>
  119. <Row>
  120. <Col lg={6}>
  121. <DetailSanksi data={sanksi.data[0]} />
  122. </Col>
  123. <Col lg={6}>
  124. <p className="lead bb">Jawaban</p>
  125. <form className="form-horizontal" method="get" action="/" onSubmit={this.onSubmit}>
  126. <FormGroup>
  127. <label className="row-form-label">Status:</label>
  128. <div className="row-md-10">
  129. <Select
  130. instanceId={selectInstanceId + 1}
  131. value={this.state.selectedOption}
  132. onChange={this.handleChangeSelect}
  133. options={[
  134. { value: "ditolak", label: "Ditolak", className: "State-ACT" },
  135. { value: "mengubah sanksi", label: "Mengubah Sanksi", className: "State-ACT" },
  136. { value: "mencabut sanksi", label: "Mencabut Sanksi", className: "State-ACT" },
  137. ]}
  138. required
  139. />
  140. {/* <span className="form-text">Pilih Jenis Pelanggaran</span> */}
  141. </div>
  142. </FormGroup>
  143. <FormGroup>
  144. <label className="row-form-label">Keterangan Dokumen:</label>
  145. <div className="row-md-10">
  146. <Input type="textarea" value={this.state.keteranganLaporan} onChange={this.setKeteranganPelaporan} required />
  147. {/* <span className="form-text">Deskripsi pelaporan minimum karakter 50 maksimum 200 karakter</span> */}
  148. </div>
  149. </FormGroup>
  150. <FormGroup>
  151. <label className="row-form-label">Dokumen Jawaban:</label>
  152. <div className="row-md-10">
  153. <DropzoneWrapper className="" onDrop={this.onDrop}>
  154. {({ getRootProps, getInputProps, isDragActive }) => {
  155. return (
  156. <div {...getRootProps()} className={"dropzone card p-3 " + (isDragActive ? "dropzone-drag-active" : "")}>
  157. <input {...getInputProps()} />
  158. <div className="dropzone-previews flex">
  159. {this.state.files.length > 0 ? <Row>{thumbs}</Row> : <div className="text-center dz-default dz-message">Drop files here to upload</div>}
  160. </div>
  161. <div className="d-flex align-items-center">
  162. <small className="ml-auto">
  163. <button type="button" className="btn btn-link" onClick={this.clearFiles}>
  164. Clear files
  165. </button>
  166. </small>
  167. </div>
  168. </div>
  169. );
  170. }}
  171. </DropzoneWrapper>
  172. </div>
  173. </FormGroup>
  174. <FormGroup>
  175. <div className="row-xl-10">
  176. <button className="btn btn-sm btn-primary" type="submit">
  177. Simpan
  178. </button>
  179. </div>
  180. </FormGroup>
  181. </form>
  182. </Col>
  183. </Row>
  184. </CardBody>
  185. </Card>
  186. {/* END card */}
  187. </Col>
  188. <Col xl="3">
  189. <DetailPT />
  190. </Col>
  191. </Row>
  192. <Row>
  193. <Col>
  194. <Card className="card-default">
  195. <CardHeader>
  196. <CardTitle>Riwayat</CardTitle>
  197. {/* <div className="text-sm">DataTables has most features enabled by default, so all you need to do to use it with your own tables is to call the construction function: $().DataTable();.</div> */}
  198. </CardHeader>
  199. <CardBody>
  200. <Datatable options={{ responsive: true }}>
  201. <table className="table table-striped my-4 w-100">
  202. <thead>
  203. <tr>
  204. <th>Tanggal</th>
  205. <th>Status</th>
  206. <th>Keterangan Dokumen</th>
  207. <th>Dokumen Jawaban</th>
  208. </tr>
  209. </thead>
  210. <tbody>
  211. <tr>
  212. <td>23/01/2022</td>
  213. <td>Ditolak</td>
  214. <td>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos, maxime.</td>
  215. <td>
  216. <em className="fa-lg far fa-file-code"></em>
  217. <a className="text-muted" href="">
  218. database.controller.js
  219. </a>
  220. </td>
  221. </tr>
  222. <tr>
  223. <td>23/01/2022</td>
  224. <td>Ditolak</td>
  225. <td>Lorem ipsum dolor sit amet consectetur adipisicing.</td>
  226. <td>
  227. <em className="fa-lg far fa-file-code"></em>
  228. <a className="text-muted" href="">
  229. database.controller.js
  230. </a>
  231. </td>
  232. </tr>
  233. <tr>
  234. <td>23/01/2022</td>
  235. <td>Ditolak</td>
  236. <td>Lorem ipsum dolor sit.</td>
  237. <td>
  238. <em className="fa-lg far fa-file-code"></em>
  239. <a className="text-muted" href="">
  240. database.controller.js
  241. </a>
  242. </td>
  243. </tr>
  244. </tbody>
  245. </table>
  246. </Datatable>
  247. </CardBody>
  248. </Card>
  249. </Col>
  250. </Row>
  251. </div>
  252. </ContentWrapper>
  253. );
  254. }
  255. }
  256. export default UploadKeberatan;