import React, { Component } from "react"; import ContentWrapper from "@/components/Layout/ContentWrapper"; import Header from "@/components/Main/Header"; import DetailPT from "@/components/Main/DetailPT"; import { getLogPT } from "@/actions/log"; import { getPT } from "@/actions/PT"; import { Row, Col, ModalHeader, ModalBody, ModalFooter, Modal, FormFeedback, Button } from "reactstrap"; import Timeline from "@/components/Main/Timeline"; import { connect } from "react-redux"; import Loader from "@/components/Common/Loader"; import { createotp, getkontakpt, createkontak } from "../../actions/auth"; import PhoneInput from 'react-phone-input-2' import 'react-phone-input-2/lib/style.css' import OtpInput from 'react-otp-input'; import { ToastContainer, toast } from "react-toastify"; class Pemantauan extends Component { constructor(props) { super(props); this.state = { log: [], pt: {}, modalPhone: false, otpClose: false, modalOTP: false, otp: "", phone: "" }; } componentDidMount = async () => { const { token } = this.props; const log = await getLogPT(token); const pt = await getPT(token); const kontakPT = await getkontakpt(token); this.setState({ log, pt, kontakPT }); if (kontakPT=== undefined) { this.setState({modalPhone:true}) } }; otpClose = () => { // return location.href = '/pt/pemantauan'; this.setState({ modalOTP: false, modalPhone: false }) } handleSubmitTelepon = async () => { const { token } = this.props const create = createotp({ no_hp: this.state.phone }, token) await toast.promise(create, { pending: "Loading...", // success: "Berhasil ", error: "Error", },) this.setState({ modalPhone: false, modalOTP: true }) } handleSubmitOtp = async () => { const { token } = this.props const create = createkontak({ otp: this.state.otp, no_hp: this.state.phone }, token) await toast.promise(create, { pending: "Loading...", success: "Success", error: "Error", },) this.setState({ modalPhone: false, modalOTP: false }) } render() { const { log, pt } = this.state; return ( {this.state.kontakPT === undefined &&

Konfirmasi Nomor Telepon Perguruan Tinggi

this.setState({ phone })} />
}

Masukan Kode OTP

{/*
*/}
{ this.setState({ otp }) }} numInputs={4} renderSeparator={-} renderInput={(props) => } />

*Kode OTP terkirim ke nomor WA {this.state.phone}

Kode verifikasi harus diisi
{pt?.data ?
: }
{log.data ? ( ) : ( )} {pt.data && }
); } } const mapStateToProps = (state) => ({ user: state.user, token: state.token }); export default connect(mapStateToProps)(Pemantauan);