|
|
@@ -1,7 +1,7 @@
|
|
|
import React, { Component } from "react";
|
|
|
import ContentWrapper from "@/components/Layout/ContentWrapper";
|
|
|
-import { Card, CardBody, CardHeader, CardTitle } from "reactstrap";
|
|
|
-import { getPelaporan, addStatus, removeLaporan, activeLaporan } from "@/actions/pelaporan";
|
|
|
+import { Card, CardBody, CardHeader, CardTitle, Button } from "reactstrap";
|
|
|
+import { getPelaporan, addStatus, removeLaporan, activeLaporan, changeRoleData } from "@/actions/pelaporan";
|
|
|
import { updateJadwal } from "@/actions/penjadwalan";
|
|
|
import DetailLaporan from "@/components/Main/DetailLaporan";
|
|
|
import Link from "next/link";
|
|
|
@@ -14,12 +14,19 @@ import bootstrapPlugin from "@fullcalendar/bootstrap";
|
|
|
import events from "./calendar.events";
|
|
|
import Select from "react-select";
|
|
|
import moment from "moment";
|
|
|
+import { connect } from "react-redux";
|
|
|
|
|
|
const status = [
|
|
|
- { value: "Ditindaklanjuti Dikti Ristek", label: "Ditindaklanjuti Dikti Ristek", className: "State-ACT" },
|
|
|
+ { value: "Ditindaklanjuti DIKTI", label: "Ditindaklanjuti DIKTI", className: "State-ACT" },
|
|
|
{ value: "Delegasi ke LLDIKTI", label: "Delegasi ke LLDIKTI", className: "State-ACT" },
|
|
|
{ value: "Ditutup", label: "Ditutup", className: "State-ACT" },
|
|
|
];
|
|
|
+
|
|
|
+const statusLLDIKTI = [
|
|
|
+ { value: "Ditindaklanjuti LLDIKTI", label: "Ditindaklanjuti LLDIKTI", className: "State-ACT" },
|
|
|
+ { value: "Delegasi ke DIKTI", label: "Delegasi ke DIKTI", className: "State-ACT" },
|
|
|
+ { value: "Ditutup", label: "Ditutup", className: "State-ACT" },
|
|
|
+];
|
|
|
class Calendar extends Component {
|
|
|
calendarEvents = events;
|
|
|
|
|
|
@@ -58,7 +65,12 @@ class Calendar extends Component {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- const dataLaporan = await getPelaporan({ penjadwalan: true, active: true });
|
|
|
+ const { organisasi, peran } = this.props.user.peran[0];
|
|
|
+
|
|
|
+ const queryDataLaporan = { role: peran.id === 2021 ? "lldikti" : "dikti", penjadwalan: true, active: true };
|
|
|
+ if (peran.id === 2021) queryDataLaporan.orgId = organisasi.id;
|
|
|
+ const dataLaporan = await getPelaporan(queryDataLaporan);
|
|
|
+
|
|
|
const laporan = await getPelaporan({ number: this.props.query.number, ptId: this.props.query.ptId });
|
|
|
|
|
|
this.setState({ dataLaporan });
|
|
|
@@ -73,6 +85,8 @@ class Calendar extends Component {
|
|
|
this.setState({ externalEvents: [{ id: this.props.query.number, color, name: `Jadwal Pemeriksaan - No.Laporan : ${this.props.query.number} - ${laporan.data[0].pt.nama}`, allDay: true }] });
|
|
|
}
|
|
|
|
|
|
+ getStatus = () => (this.props.user.peran[0].peran.id === 2021 ? statusLLDIKTI : status);
|
|
|
+
|
|
|
getDataEvent = () => {
|
|
|
const dataEvent = this.state.dataLaporan.data
|
|
|
.filter((e) => e.penjadwalan)
|
|
|
@@ -122,6 +136,7 @@ class Calendar extends Component {
|
|
|
|
|
|
defaultStatus = async (data) => {
|
|
|
const { ptId, number } = this.props.query;
|
|
|
+ const status = this.getStatus();
|
|
|
if (!data.status) {
|
|
|
await addStatus({ number, ptId }, { status: status[0].value });
|
|
|
return this.setState({ selectedOption: status[0] });
|
|
|
@@ -129,15 +144,25 @@ class Calendar extends Component {
|
|
|
return this.setState({ selectedOption: status.filter((e) => e.value === data.status)[0] });
|
|
|
};
|
|
|
|
|
|
- handleChangeSelect = async (selectedOption) => {
|
|
|
+ handleChangeSelect = (selectedOption) => this.setState({ selectedOption });
|
|
|
+
|
|
|
+ handleSimpan = async (e) => {
|
|
|
+ const { selectedOption } = this.state;
|
|
|
const { ptId, number } = this.props.query;
|
|
|
this.setState({ selectedOption });
|
|
|
- await addStatus({ number, ptId }, { status: selectedOption.value });
|
|
|
- if (selectedOption.value === "Ditutup") {
|
|
|
+ if (selectedOption.value === this.getStatus()[1].value) {
|
|
|
+ const roleId = this.props.user.peran[0].peran.id;
|
|
|
+ await changeRoleData({ number, ptId }, { role_data: roleId === 2021 ? "dikti" : "lldikti" });
|
|
|
+ const statusData = roleId === 2021 ? status : statusLLDIKTI;
|
|
|
+ await addStatus({ number, ptId }, { status: statusData[0].value });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (selectedOption.value === this.getStatus()[2].value) {
|
|
|
await removeLaporan({ number, ptId });
|
|
|
} else if (!this.state.laporan.data[0].active) {
|
|
|
await activeLaporan({ number, ptId });
|
|
|
}
|
|
|
+ await addStatus({ number, ptId }, { status: selectedOption.value });
|
|
|
};
|
|
|
|
|
|
render() {
|
|
|
@@ -169,10 +194,13 @@ class Calendar extends Component {
|
|
|
<CardTitle tag="h4">Status Pelaporan</CardTitle>
|
|
|
</CardHeader>
|
|
|
<CardBody>
|
|
|
- <Select value={selectedOption} onChange={this.handleChangeSelect} options={status} required />
|
|
|
+ <Select value={selectedOption} onChange={this.handleChangeSelect} options={this.getStatus()} required />
|
|
|
+ <Button onClick={this.handleSimpan} className="mt-2" color="primary" block>
|
|
|
+ Simpan
|
|
|
+ </Button>
|
|
|
</CardBody>
|
|
|
</Card>
|
|
|
- {selectedOption?.value === "Ditutup" ? (
|
|
|
+ {selectedOption?.value === this.getStatus()[2].value || selectedOption?.value === this.getStatus()[1].value ? (
|
|
|
""
|
|
|
) : (
|
|
|
<>
|
|
|
@@ -268,4 +296,5 @@ class Calendar extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export default Calendar;
|
|
|
+const mapStateToProps = (state) => ({ user: state.user });
|
|
|
+export default connect(mapStateToProps)(Calendar);
|