import React, { useEffect, useMemo, useRef, useState } from 'react' import ReactDOM from 'react-dom' import { store } from '../kytp/store/store' import { Provider, useDispatch, useSelector } from 'react-redux' import { Card, CardBody, CardFooter, CardHeader, CardSubtitle, CardTitle, Col, Label, Nav, NavItem, NavLink, Row, TabContent, TabPane } from 'reactstrap' import collect from 'collect.js' import { MultiSelect } from 'react-multi-select-component' import { Toast } from 'primereact/toast' import { Button as ButtonP } from 'primereact/button' import 'primereact/resources/themes/bootstrap4-light-blue/theme.css' import 'primeflex/primeflex.css' import Tanggal from '../commons/Tanggal' import jquery, { data, getJSON } from 'jquery' import Kanwil from './componentMonitoring/Kanwil' import Kpp from './componentMonitoring/Kpp' import Seksi from './componentMonitoring/Seksi' import { TabPanel, TabView } from 'primereact/tabview' import Pegawai from './componentMonitoring/Pegawai' import { setDataMonitoring, setDataUrut } from '../kytp/store/KpdlStore' import { Skeleton } from 'primereact/skeleton' const date = new Date() const App = () => { const base_url = '/engineN/' const toast = useRef(null) const [active, setActive] = useState(0) const refTab = useRef() const toggle = (tab) => { setActive(tab) } const [kanwil, setKanwil] = useState([]) const [kanwilSelected, setKanwilSelected] = useState([]) const [kpp, setKpp] = useState([]) const [kppSelected, setKppSelected] = useState([]) const [tanggalAwal, setTanggalAwal] = useState(new Date(date.getFullYear(), 0, 1).toISOString()) const [tanggalAkhir, setTanggalAkhir] = useState(date.toISOString()) const [paramSelected, setParamSelected] = useState({}) const [loading, setLoading] = useState(false) const storeKpdl = useSelector((state) => state.kpdl) const dispatch = useDispatch() useEffect(() => { jquery.ajax({ url: base_url + 'kewilayahan/ref/kanwil', method: 'GET', dataType: 'json', success: (data) => { setKanwil(data) } }) }, []) useEffect(() => { const kanwil = collect(kanwilSelected).pluck('value').all() setKppSelected([]) setKpp([]) if (!kanwil.length) { return } jquery.ajax({ url: base_url + 'kewilayahan/ref/kppmultikanwil', method: 'POST', dataType: 'json', data: { kanwil }, success: (data) => { setKpp(data) } }) }, [kanwilSelected]) const buttonProsesOnClick = () => { if (!kppSelected.length) { return toast.current.show({ severity: 'info', summary: 'Info', detail: 'KPP harus dipilih' }) } if (!tanggalAwal) { return toast.current.show({ severity: 'info', summary: 'Info', detail: 'Periode Awal harus dipilih' }) } if (!tanggalAkhir) { return toast.current.show({ severity: 'info', summary: 'Info', detail: 'Periode Akhir harus dipilih' }) } setActive(0) setParamSelected({ kanwilSelected, kppSelected, tanggalAwal, tanggalAkhir }) const kanwil = collect(kanwilSelected).pluck('value').all() const kpp = collect(kppSelected).pluck('value').all() setLoading(true) jquery .ajax({ url: base_url + 'kewilayahan/monitoring/kegiatan/data', method: 'POST', dataType: 'json', data: { kanwil, kpp, tanggalAwal, tanggalAkhir }, success: (dataReturn) => { dispatch(setDataMonitoring(dataReturn.data)) dispatch( setDataUrut({ urutKanwil: dataReturn.urutKanwil, urutKpp: dataReturn.urutKpp, urutSeksi: dataReturn.urutSeksi, urutPegawai: dataReturn.urutPegawai }) ) } }) .done(() => { setLoading(false) }) } return ( <> Pilih Unit Kerja Perekam dan Tanggal Kegiatan { setKanwilSelected(e) }} labelledBy="Pilih Kanwil" overrideStrings={{ allItemsAreSelected: 'Semua dipilih', selectSomeItems: 'Pilih Kanwil' }} /> { setKppSelected(e) }} labelledBy="Pilih KPP" overrideStrings={{ allItemsAreSelected: 'Semua dipilih', selectSomeItems: 'Pilih KPP' }} /> buttonProsesOnClick()} label="Proses" severity="" rounded className="w-10rem text-white text-base" /> Monitoring Kegiatan KPDL Seksi Pengawasan Sesuai dengan lingkup pilihan pencarian {loading ? ( ) : ( <> setActive(e.index)} className="p-0" pt={{ panelContainer: { className: 'p-0' } }}> )} ) } const container = document.getElementById('app') const component = ( ) ReactDOM.render(component, container)