import React, { Component } from "react"; import ContentWrapper from "@/components/Layout/ContentWrapper"; import Header from "@/components/Main/Header"; 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"; import swal from "sweetalert2"; class DetailPT extends Component { state = { phone: "", ddselected: false, modalOTP: false, loadingProses: false, otp: "" } componentDidMount = async () => { const { token } = this.props; const kontakPT = await getkontakpt(token); const oldPhone = kontakPT?.data.map((data) => (data.no_hp)).toString() if (oldPhone) { this.setState({ phone: oldPhone }) } } OpenEditNoTelp = () => this.setState({ ddselected: !this.state.ddselected }) handleSubmitTelepon = async () => { this.setState({ loadingProses: true }) const { token } = this.props await createotp({ no_hp: this.state.phone }, token) this.setState({ modalPhone: false, modalOTP: true }) } otpClose = () => { this.setState({ modalOTP: false, ddselected: false, loadingProses: false, otp: "" }) // localStorage.setItem("closeverif", "true"); } handleSubmitOtp = async () => { const { token } = this.props const create = await createkontak({ otp: this.state.otp, no_hp: this.state.phone }, token) if (create.error) { swal.fire({ title: create.error.message, icon: "error", content: create.error.message, confirmButtonColor: "#3e3a8e", }); } else { swal.fire({ title: "Data berhasil dikirim", icon: "success", confirmButtonColor: "#3e3a8e", }); this.setState({ ddselected: false, modalOTP: false, loadingProses: false, otp: "" }) } } render() { const { data } = this.props; return (
*Kode OTP terkirim ke nomor WA {this.state.phone}
{data.sk_pendirian}
Pembina: {data.pembina.nama}
{`${data.alamat.jalan} ${data.alamat.rt ? `rt ${data.alamat.rt}` : ""} ${data.alamat.rw ? `rt ${data.alamat.rw}` : ""}, ${data.alamat.kab_kota.nama}, ${data.propinsi.nama}`}