|
@@ -3,7 +3,7 @@ import ContentWrapper from "@/components/Layout/ContentWrapper";
|
|
|
import { Card, CardBody, CardHeader, CardTitle } from "reactstrap";
|
|
import { Card, CardBody, CardHeader, CardTitle } from "reactstrap";
|
|
|
import { getPelaporan } from "@/actions/pelaporan";
|
|
import { getPelaporan } from "@/actions/pelaporan";
|
|
|
import { updateJadwal } from "@/actions/penjadwalan";
|
|
import { updateJadwal } from "@/actions/penjadwalan";
|
|
|
-import DetailLaporan from "@/components/Penjadwalan/DetailLaporan";
|
|
|
|
|
|
|
+import DetailLaporan from "@/components/Main/DetailLaporan";
|
|
|
import Link from "next/link";
|
|
import Link from "next/link";
|
|
|
import FullCalendar from "@fullcalendar/react";
|
|
import FullCalendar from "@fullcalendar/react";
|
|
|
import dayGridPlugin from "@fullcalendar/daygrid";
|
|
import dayGridPlugin from "@fullcalendar/daygrid";
|
|
@@ -12,7 +12,14 @@ import interactionPlugin, { Draggable } from "@fullcalendar/interaction";
|
|
|
import listPlugin from "@fullcalendar/list";
|
|
import listPlugin from "@fullcalendar/list";
|
|
|
import bootstrapPlugin from "@fullcalendar/bootstrap";
|
|
import bootstrapPlugin from "@fullcalendar/bootstrap";
|
|
|
import events from "./calendar.events";
|
|
import events from "./calendar.events";
|
|
|
-
|
|
|
|
|
|
|
+import Select from "react-select";
|
|
|
|
|
+import { addStatus } from "@/actions/pelaporan";
|
|
|
|
|
+
|
|
|
|
|
+const status = [
|
|
|
|
|
+ { value: "Ditindaklanjuti Dikti Ristek", label: "Ditindaklanjuti Dikti Ristek", className: "State-ACT" },
|
|
|
|
|
+ { value: "Delegasi ke LLDIKTI", label: "Delegasi ke LLDIKTI", className: "State-ACT" },
|
|
|
|
|
+ { value: "Ditutup", label: "Ditutup", className: "State-ACT" },
|
|
|
|
|
+];
|
|
|
class Calendar extends Component {
|
|
class Calendar extends Component {
|
|
|
calendarEvents = events;
|
|
calendarEvents = events;
|
|
|
|
|
|
|
@@ -38,6 +45,8 @@ class Calendar extends Component {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static getInitialProps = ({ query }) => ({ query });
|
|
|
|
|
+
|
|
|
async componentDidMount() {
|
|
async componentDidMount() {
|
|
|
/* initialize the external events */
|
|
/* initialize the external events */
|
|
|
new Draggable(this.refs.externalEventsList, {
|
|
new Draggable(this.refs.externalEventsList, {
|
|
@@ -50,15 +59,15 @@ class Calendar extends Component {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const dataLaporan = await getPelaporan({ penjadwalan: true });
|
|
const dataLaporan = await getPelaporan({ penjadwalan: true });
|
|
|
- const { data } = await getPelaporan({ number: this.props.query.number, ptId: this.props.query.ptId });
|
|
|
|
|
|
|
+ const laporan = await getPelaporan({ number: this.props.query.number, ptId: this.props.query.ptId });
|
|
|
this.setState({ dataLaporan });
|
|
this.setState({ dataLaporan });
|
|
|
this.getDataEvent();
|
|
this.getDataEvent();
|
|
|
-
|
|
|
|
|
|
|
+ await this.defaultStatus(laporan.data[0]);
|
|
|
// const cek = this.state.dataLaporan.data.filter((e) => e._number === this.props.query.number && e.pt_id == this.props.query.ptId)[0];
|
|
// const cek = this.state.dataLaporan.data.filter((e) => e._number === this.props.query.number && e.pt_id == this.props.query.ptId)[0];
|
|
|
- this.setState({ laporan: data[0] });
|
|
|
|
|
|
|
+ this.setState({ laporan });
|
|
|
let color = "#" + Math.floor(Math.random() * 16777215).toString(16);
|
|
let color = "#" + Math.floor(Math.random() * 16777215).toString(16);
|
|
|
- if (data[0].penjadwalan) {
|
|
|
|
|
- color = data[0].penjadwalan.background_color;
|
|
|
|
|
|
|
+ if (laporan.data[0].penjadwalan) {
|
|
|
|
|
+ color = laporan.data[0].penjadwalan.background_color;
|
|
|
}
|
|
}
|
|
|
this.setState({ externalEvents: [{ id: this.props.query.number, color: color, name: `Jadwal Pemeriksaan - BI: ${this.props.query.number} - Universitas Satyagama` }] });
|
|
this.setState({ externalEvents: [{ id: this.props.query.number, color: color, name: `Jadwal Pemeriksaan - BI: ${this.props.query.number} - Universitas Satyagama` }] });
|
|
|
}
|
|
}
|
|
@@ -108,8 +117,19 @@ class Calendar extends Component {
|
|
|
const update = await updateJadwal({ number, ptId }, data);
|
|
const update = await updateJadwal({ number, ptId }, data);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- handleChangeSelect = (selectedOption) => {
|
|
|
|
|
|
|
+ defaultStatus = async (data) => {
|
|
|
|
|
+ const { ptId, number } = this.props.query;
|
|
|
|
|
+ if (!data.status) {
|
|
|
|
|
+ await addStatus({ number, ptId }, { status: status[0].value });
|
|
|
|
|
+ return this.setState({ selectedOption: status[0] });
|
|
|
|
|
+ }
|
|
|
|
|
+ return this.setState({ selectedOption: status.filter((e) => e.value === data.status)[0] });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ handleChangeSelect = async (selectedOption) => {
|
|
|
|
|
+ const { ptId, number } = this.props.query;
|
|
|
this.setState({ selectedOption });
|
|
this.setState({ selectedOption });
|
|
|
|
|
+ await addStatus({ number, ptId }, { status: selectedOption.value });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
@@ -128,11 +148,26 @@ class Calendar extends Component {
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="calendar-app">
|
|
<div className="calendar-app">
|
|
|
|
|
+ <div class="row">
|
|
|
|
|
+ <div class="col">
|
|
|
|
|
+ <Card className="card-default">
|
|
|
|
|
+ <CardBody>{laporan.data && <DetailLaporan noStatus query={this.props.query} data={laporan.data[0]} handleChangeSelect={this.handleChangeSelect} />}</CardBody>
|
|
|
|
|
+ </Card>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
<div className="row">
|
|
<div className="row">
|
|
|
<div className="col-xl-4 col-lg-5">
|
|
<div className="col-xl-4 col-lg-5">
|
|
|
<div className="row">
|
|
<div className="row">
|
|
|
<div className="col-lg-12 col-md-6 col-12">
|
|
<div className="col-lg-12 col-md-6 col-12">
|
|
|
- {selectedOption && selectedOption.value === "Ditutup" ? (
|
|
|
|
|
|
|
+ <Card className="card-default">
|
|
|
|
|
+ <CardHeader>
|
|
|
|
|
+ <CardTitle tag="h4">Status Pelaporan</CardTitle>
|
|
|
|
|
+ </CardHeader>
|
|
|
|
|
+ <CardBody>
|
|
|
|
|
+ <Select value={selectedOption} onChange={this.handleChangeSelect} options={status} required />
|
|
|
|
|
+ </CardBody>
|
|
|
|
|
+ </Card>
|
|
|
|
|
+ {selectedOption?.value === "Ditutup" ? (
|
|
|
""
|
|
""
|
|
|
) : (
|
|
) : (
|
|
|
<Card className="card-default" title="">
|
|
<Card className="card-default" title="">
|
|
@@ -157,7 +192,6 @@ class Calendar extends Component {
|
|
|
</CardBody>
|
|
</CardBody>
|
|
|
</Card>
|
|
</Card>
|
|
|
)}
|
|
)}
|
|
|
- {laporan && <DetailLaporan query={this.props.query} data={laporan} handleChangeSelect={this.handleChangeSelect} />}
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|