|
|
@@ -1,371 +0,0 @@
|
|
|
-import React, { Component } from "react";
|
|
|
-import Router from "next/router";
|
|
|
-import { connect } from "react-redux";
|
|
|
-import ContentWrapper from "@/components/Layout/ContentWrapper";
|
|
|
-import { Row, Col, Card, CardHeader, CardBody, Button, FormGroup, Popover, PopoverHeader } from "reactstrap";
|
|
|
-// import { Editor } from 'react-draft-wysiwyg';
|
|
|
-import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
|
|
|
-import { EditorState, ContentState, convertFromHTML, convertToRaw, convertFromRaw } from 'draft-js';
|
|
|
-// import 'draft-js/dist/Draft.css';
|
|
|
-import dynamic from 'next/dynamic';
|
|
|
-const Editor = dynamic(
|
|
|
- () => import('react-draft-wysiwyg').then(mod => mod.Editor),
|
|
|
- { ssr: false })
|
|
|
-import draftToHtml from 'draftjs-to-html';
|
|
|
-import pdfMake from "pdfmake/build/pdfmake";
|
|
|
-import StateToPdfMake from "draft-js-export-pdfmake";
|
|
|
-import pdfFonts from "pdfmake/build/vfs_fonts";
|
|
|
-import { toast } from "react-toastify";
|
|
|
-import { addCatatan, getOneCatatan, updateCatatan } from "../../../actions/catatan";
|
|
|
-import { getCsrf } from "../../../actions/security";
|
|
|
-pdfMake.vfs = pdfFonts.pdfMake.vfs;
|
|
|
-import { ENV } from '../../../env.js';
|
|
|
-import CopyToClipboard from "react-copy-to-clipboard";
|
|
|
-import ReactToPrint from "react-to-print";
|
|
|
-import ComponentToPrint from "../../../components/Main/presensi_print.js";
|
|
|
-import htmlToPdfmake from "html-to-pdfmake"
|
|
|
-// import htmlToDraft from 'html-to-draftjs';
|
|
|
-import SummerNote from "../../../components/Extras/summernote";
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class EditFile extends Component {
|
|
|
- constructor(props) {
|
|
|
- super(props);
|
|
|
- this.state = {
|
|
|
- editorState: null,
|
|
|
- copiedd: false,
|
|
|
- judul: "",
|
|
|
-
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- static getInitialProps = async ({ query }) => {
|
|
|
- return { query };
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- componentDidMount = async () => {
|
|
|
- const { token, query } = this.props;
|
|
|
- const { id } = query;
|
|
|
- const getCatatan = await getOneCatatan(token, id)
|
|
|
- const catatan = getCatatan.data
|
|
|
- const judul = catatan.judul
|
|
|
- this.setState({ catatan, judul });
|
|
|
- // let blocksFromHTML;
|
|
|
- // let editorState;
|
|
|
- // if (typeof window !== 'undefined') {
|
|
|
- // const htmlToDraft = require('html-to-draftjs').default;
|
|
|
- // const isi = catatan.isi
|
|
|
- // blocksFromHTML = htmlToDraft((isi));
|
|
|
- // console.log(blocksFromHTML)
|
|
|
- // editorState = ContentState.createFromBlockArray(
|
|
|
- // blocksFromHTML.contentBlocks,
|
|
|
- // blocksFromHTML.entityMap
|
|
|
- // );
|
|
|
- // }
|
|
|
-
|
|
|
- this.setState({
|
|
|
- // editorState: EditorState.createWithContent(editorState)
|
|
|
- editorState: catatan?.isi
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- onEditorStateChange = (editorState) => {
|
|
|
- this.setState({
|
|
|
- editorState,
|
|
|
- });
|
|
|
- // localStorage.setItem("editorState", draftToHtml(convertToRaw(editorState.getCurrentContent())))
|
|
|
- };
|
|
|
-
|
|
|
- handelSimpan = async (data) => {
|
|
|
- if (this.props?.user?.role.id === 2071) {
|
|
|
- Swal.fire({
|
|
|
- icon: 'error',
|
|
|
- title: 'Oops...',
|
|
|
- html: 'Maaf anda tidak memiliki akses untuk menyelesaikan<p> proses ini.</p>',
|
|
|
- confirmButtonColor: "#3e3a8e",
|
|
|
- confirmButtonText: 'Oke'
|
|
|
- })
|
|
|
- } else {
|
|
|
- const getToken = await getCsrf();
|
|
|
- const _csrf = getToken.token;
|
|
|
- const { token, query } = this.props;
|
|
|
- const { id } = query;
|
|
|
- // const isi = ("editorState", draftToHtml(convertToRaw(this.state.editorState.getCurrentContent())))
|
|
|
- const toastid = toast.loading("Please wait...");
|
|
|
- const added = await updateCatatan(token, this.state.catatan.sanksi_id, {
|
|
|
- "judul": this.state.judul,
|
|
|
- "isi": this.state.editorState,
|
|
|
- "catatan_id": id,
|
|
|
- "menu": "Perpanjangan Sanksi"
|
|
|
- }, _csrf);
|
|
|
- if (!added) {
|
|
|
- toast.update(toastid, { render: "Error", type: "error", isLoading: false, autoClose: true, closeButton: true });
|
|
|
- } else {
|
|
|
- toast.update(toastid, { render: "Success", type: "success", isLoading: false, autoClose: true, closeButton: true });
|
|
|
- Router.push(`/app/perpanjangan-sanksi/detail?id=${this.state.catatan.sanksi_id}`);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
- handleGeneratePDF = () => {
|
|
|
- // const htmlContent = draftToHtml(convertToRaw(this.state.editorState.getCurrentContent()))
|
|
|
- const htmlToPrint = htmlToPdfmake(this.state.editorState)
|
|
|
- const siapPrint = { content: htmlToPrint }
|
|
|
- pdfMake.createPdf(siapPrint).download();
|
|
|
- };
|
|
|
- setHandleJudul = (e) => {
|
|
|
- this.setState({ judul: e.target.value });
|
|
|
- };
|
|
|
- CloseCopiedd = () => {
|
|
|
-
|
|
|
- setTimeout(() => {
|
|
|
- this.setState({
|
|
|
- copiedd: !this.state.copiedd
|
|
|
- });
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
-
|
|
|
- Copiedd = () => this.setState({
|
|
|
- copiedd: !this.state.copiedd
|
|
|
- })
|
|
|
-
|
|
|
- render() {
|
|
|
- const { editorState, catatan } = this.state;
|
|
|
- console.log(editorState)
|
|
|
- return (
|
|
|
- <ContentWrapper>
|
|
|
- <Row>
|
|
|
- <Col lg={12}>
|
|
|
- <Card body className="card-default">
|
|
|
- <FormGroup row>
|
|
|
- <label className="col-md-1 col-form-label">Judul Catatan</label>
|
|
|
- <div className="col-md-8">
|
|
|
-
|
|
|
- <input type="text" name="article-title" placeholder="Judul Catatan" className="mb-3 form-control form-control-lg" onChange={this.setHandleJudul} value={this.state.judul} />
|
|
|
- </div>
|
|
|
- <div className="col-md-3">
|
|
|
- <span className=" d-inline-flex">
|
|
|
- <Button className="btn-login mr-2" color onClick={this.handleGeneratePDF}>
|
|
|
- <span className="font-color-white">
|
|
|
- Print Notulensi
|
|
|
- </span>
|
|
|
- </Button>
|
|
|
- </span>
|
|
|
- <span className=" d-inline-flex">
|
|
|
- <ReactToPrint
|
|
|
- trigger={() => {
|
|
|
- return <span>
|
|
|
- <Button color className="btn-login">
|
|
|
- <span className="font-color-white">
|
|
|
- Print Presensi
|
|
|
- </span>
|
|
|
- </Button>
|
|
|
- </span>
|
|
|
- }}
|
|
|
- content={() => this.componentRef}
|
|
|
- />
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </FormGroup>
|
|
|
- <div style={{ display: "none" }}>
|
|
|
- <ComponentToPrint ref={el => (this.componentRef = el)} query={this.props.query} />
|
|
|
- </div>
|
|
|
- {/* <Editor
|
|
|
- editorState={editorState}
|
|
|
- // wrapperClassName="demo-wrapper"
|
|
|
- // editorClassName="demo-editor"
|
|
|
- editorStyle={{ height: 500 }}
|
|
|
- wrapperClassName="wysiwig-editor-wrapper"
|
|
|
- editorClassName="form-control"
|
|
|
- onEditorStateChange={this.onEditorStateChange}
|
|
|
- toolbar={{
|
|
|
- image: {
|
|
|
- previewImage: true,
|
|
|
- uploadCallback: (file) => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- const reader = new FileReader();
|
|
|
- reader.onloadend = () => {
|
|
|
- resolve({
|
|
|
- data: {
|
|
|
- url: reader.result,
|
|
|
- },
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- reader.onerror = (reason) => reject(reason);
|
|
|
-
|
|
|
- reader.readAsDataURL(file);
|
|
|
- });
|
|
|
- },
|
|
|
- alt: { present: false, mandatory: false },
|
|
|
- inputAccept: 'image/gif,image/jpeg,image/jpg,image/png,image/svg',
|
|
|
-
|
|
|
- },
|
|
|
- }}
|
|
|
- /> */}
|
|
|
- <SummerNote
|
|
|
- id='editor1'
|
|
|
- destroy={false}
|
|
|
- value={editorState}
|
|
|
- options={{
|
|
|
- lang: "eng",
|
|
|
- height: 800,
|
|
|
- dialogsInBody: true,
|
|
|
- toolbar: [
|
|
|
- ["style", ["style", "customStyle", "copyFormatting"]],
|
|
|
- ["font", ["bold", "italic", "underline", "strikethrough", "superscript", "subscript", "clear", "customCleaner"]],
|
|
|
- ["fontname", ["fontname", "customFont"]],
|
|
|
- ["fontsize", ["fontsizeInput"]],
|
|
|
- ['color', ['forecolor', 'backcolor']],
|
|
|
- ["para", ["ul", "ol", "listStyles", "paragraph"]],
|
|
|
- ["table", ["table", "jMerge", "jBackcolor", "jBorderColor", "jAlign", "jTableInfo", "jWidthHeightReset"]],
|
|
|
- ["tableRow", ["jRowHeight"]],
|
|
|
- ["tableCol", ["jColWidth"]],
|
|
|
- ["insert", ["pasteHTML", "link", "unlink", "picture", "imageMap", "video", "customSpecialChar"]],
|
|
|
- ["anchor", ["anchor", "toc", "markAnchor", "editAnchor"]],
|
|
|
- ["comment", ["editPopover", "removePopover"]],
|
|
|
- ["view", ["fullscreen", "codeview", "help"]],
|
|
|
- ],
|
|
|
-
|
|
|
- canViewClasslist: true,
|
|
|
- tableClassName: 'jtable table-bordered color-black',
|
|
|
- customFont: {
|
|
|
- fontNames: [
|
|
|
- 'Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Helvetica', 'Impact', 'Tahoma', 'Times New Roman', 'Verdana',
|
|
|
- { name: '新細明體', value: '新細明體, serif' },
|
|
|
- { name: '微軟正黑體', value: '微軟正黑體, sans-serif' },
|
|
|
- { name: '標楷體', value: '標楷體, DFKai-SB, BiauKaiTC' }
|
|
|
- ]
|
|
|
- },
|
|
|
- }}
|
|
|
- onChange={(editorState) => {
|
|
|
- this.setState({
|
|
|
- editorState,
|
|
|
- });
|
|
|
- }}
|
|
|
- // onImageUpload={this.onImageUpload}
|
|
|
- // ref={this.editor}
|
|
|
-
|
|
|
- />
|
|
|
-
|
|
|
- <br />
|
|
|
- <Row>
|
|
|
- <Col xl={{ size: 8, offset: 2 }}>
|
|
|
- <div className="mb-5" >
|
|
|
- <div className='header-ttd signature-border pt-1 pb-1'>
|
|
|
- <text className='header-ttd font-weight-bold '>PESERTA RAPAT</text>
|
|
|
- </div>
|
|
|
- <div id="ttd">
|
|
|
- {catatan
|
|
|
- ? catatan.daftar_kehadiran_peserta?.map((value) => (
|
|
|
- <div className='ttd-div'>
|
|
|
- <div className='sign-ttd'>
|
|
|
- <img
|
|
|
- className='sign-ttd'
|
|
|
- src={value.ttd.path} />
|
|
|
- </div>
|
|
|
- <div className='sign-nama'>
|
|
|
- <text>
|
|
|
- {value.nama}
|
|
|
- </text>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- )) : ""}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
-
|
|
|
-
|
|
|
- <Row>
|
|
|
- <Col>
|
|
|
- {ENV === "local" &&
|
|
|
- <CopyToClipboard
|
|
|
- text={`http://localhost:3000/signature/letter/${catatan?._id}`}
|
|
|
- options={{ asHtml: true }}
|
|
|
- >
|
|
|
- <div>
|
|
|
- <span className="btn-radius">
|
|
|
- <Button color id="Popover1" className="ml-0 mb-2 btn-v1-outline-purple" onClick={() => {
|
|
|
- this.CloseCopiedd()
|
|
|
- }} ><span><em className="fas fa-project-diagram float-left mt-1 mr-1" /> Link Dokumen Berita Acara</span>
|
|
|
-
|
|
|
- {/* <h5 className="p-0 mt-3 float-right"> <em className="fas fa-project-diagram float-left mt-1" /> Link Dokumen Berita Acara</h5> */}
|
|
|
- </Button>
|
|
|
- </span>
|
|
|
- <Popover placement="bottom" isOpen={this.state.copiedd} target="Popover1" toggle={this.Copiedd}>
|
|
|
- <PopoverHeader>Link Berhasil Disalin</PopoverHeader>
|
|
|
- </Popover>
|
|
|
- </div>
|
|
|
-
|
|
|
- </CopyToClipboard>
|
|
|
- }
|
|
|
- {ENV === "production" &&
|
|
|
- <CopyToClipboard
|
|
|
- text={`https://sidali.kemdikbud.go.id/signature/letter/${catatan?._id}`}
|
|
|
- options={{ asHtml: true }}
|
|
|
- >
|
|
|
- <div>
|
|
|
- <span className="btn-radius">
|
|
|
- <Button color id="Popover1" className="ml-0 mt-2 mb-2 btn-v1-outline-purple" onClick={() => {
|
|
|
- this.CloseCopiedd()
|
|
|
- }} ><span><em className="fas fa-project-diagram float-left mt-1 mr-1" /> Link Dokumen Berita Acara</span>
|
|
|
-
|
|
|
- {/* <h5 className="p-0 mt-3 float-right"> <em className="fas fa-project-diagram float-left mt-1" /> Link Dokumen Berita Acara</h5> */}
|
|
|
- </Button>
|
|
|
- </span>
|
|
|
- <Popover placement="bottom" isOpen={this.state.copiedd} target="Popover1" toggle={this.Copiedd}>
|
|
|
- <PopoverHeader>Link Berhasil Disalin</PopoverHeader>
|
|
|
- </Popover>
|
|
|
- </div>
|
|
|
-
|
|
|
- </CopyToClipboard>
|
|
|
- }
|
|
|
- {ENV === "development" &&
|
|
|
- <CopyToClipboard
|
|
|
- text={`https://dev.sidali.kemdikbud.go.id/signature/letter/${catatan?._id}`}
|
|
|
- options={{ asHtml: true }}
|
|
|
- >
|
|
|
- <div>
|
|
|
- <span className="btn-radius">
|
|
|
- <Button color id="Popover1" className="ml-0 mt-2 mb-2 btn-v1-outline-purple" onClick={() => {
|
|
|
- this.CloseCopiedd()
|
|
|
- }} ><span><em className="fas fa-project-diagram float-left mt-1 mr-1" /> Link Dokumen Berita Acara</span>
|
|
|
-
|
|
|
- {/* <h5 className="p-0 mt-3 float-right"> <em className="fas fa-project-diagram float-left mt-1" /> Link Dokumen Berita Acara</h5> */}
|
|
|
- </Button>
|
|
|
- </span>
|
|
|
- <Popover placement="bottom" isOpen={this.state.copiedd} target="Popover1" toggle={this.Copiedd}>
|
|
|
- <PopoverHeader>Link Berhasil Disalin</PopoverHeader>
|
|
|
- </Popover>
|
|
|
- </div>
|
|
|
-
|
|
|
- </CopyToClipboard>
|
|
|
- }
|
|
|
-
|
|
|
- </Col>
|
|
|
- <Col>
|
|
|
- <div>
|
|
|
- <Button color className="btn-login float-right" onClick={this.handelSimpan} >
|
|
|
- <span className="font-color-white">
|
|
|
- Simpan Catatan
|
|
|
- </span>
|
|
|
- </Button>
|
|
|
- </div>
|
|
|
-
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
-
|
|
|
- </Card>
|
|
|
- </Col>
|
|
|
-
|
|
|
- </Row>
|
|
|
- </ContentWrapper>
|
|
|
- );
|
|
|
- }
|
|
|
-}
|
|
|
-const mapStateToProps = (state) => ({ user: state.user, token: state.token });
|
|
|
-export default connect(mapStateToProps)(EditFile);
|