usable open requests list
This commit is contained in:
@ -9,13 +9,13 @@ import { useSession } from "next-auth/react"
|
|||||||
import common from '../../../src/helpers/common';
|
import common from '../../../src/helpers/common';
|
||||||
import Layout from "../../../components/layout";
|
import Layout from "../../../components/layout";
|
||||||
import ProtectedRoute from '../../../components/protectedRoute';
|
import ProtectedRoute from '../../../components/protectedRoute';
|
||||||
import { Location, Shift, UserRole, EventLog, EventType } from "@prisma/client";
|
import { Location, Shift, UserRole, EventLog, EventType, EventLogType } from "@prisma/client";
|
||||||
import { set } from 'date-fns';
|
import { set } from 'date-fns';
|
||||||
|
|
||||||
|
|
||||||
export default function EventLogList() {
|
export default function EventLogList() {
|
||||||
const [eventLogs, setEventLog] = useState([]);
|
const [eventLogs, setEventLog] = useState([]);
|
||||||
const [publicShifts, setPublicShifts] = useState([]);
|
const [requestedAssignments, setRequestedAssignments] = useState([]);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
@ -40,9 +40,12 @@ export default function EventLogList() {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { data: eventLogsData } = await axiosInstance.get(`/api/data/prisma/eventlog?where={"type":"${EventLogType.AssignmentReplacementAccepted}"}`)
|
||||||
|
setEventLog(eventLogsData);
|
||||||
//get shifts where publicGuid is not null
|
//get shifts where publicGuid is not null
|
||||||
const { data: shiftsData } = await axiosInstance.get(`/api/data/prisma/assignment?where={"publicGuid":{"not":"NULL"}}`)
|
const { data: shiftsData } = await axiosInstance.get(`/api/data/prisma/assignment?where={"publicGuid":{"not":"null"}}&include={"shift":true,"publisher":{"select":{"firstName":true,"lastName":true}}}`)
|
||||||
setPublicShifts(shiftsData);
|
setRequestedAssignments(shiftsData);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -89,7 +92,7 @@ export default function EventLogList() {
|
|||||||
{!showOpenRequests && (eventLogs.map((event) => (
|
{!showOpenRequests && (eventLogs.map((event) => (
|
||||||
<tr key={event.id}>
|
<tr key={event.id}>
|
||||||
<td className="border px-2 py-2">{event.publisher.firstName + " " + event.publisher.lastName}</td>
|
<td className="border px-2 py-2">{event.publisher.firstName + " " + event.publisher.lastName}</td>
|
||||||
<td className="border px-2 py-2">{common.getDateFormated(new Date(event.date))}</td>
|
<td className="border px-2 py-2">{common.getDateFormated(new Date(event.startTime))}</td>
|
||||||
<td className="border px-2 py-2">{event.shift?.name}</td>
|
<td className="border px-2 py-2">{event.shift?.name}</td>
|
||||||
<td className="border px-2 py-2">
|
<td className="border px-2 py-2">
|
||||||
{event.content}
|
{event.content}
|
||||||
@ -103,13 +106,12 @@ export default function EventLogList() {
|
|||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
{showOpenRequests && (publicShifts.map((shift) => (
|
{showOpenRequests && (requestedAssignments.map((assignment) => (
|
||||||
<tr key={shift.id}>
|
<tr key={assignment.id}>
|
||||||
<td className="border px-2 py-2">{shift.publisher.firstName + " " + shift.publisher.lastName}</td>
|
<td className="border px-2 py-2">{assignment.publisher.firstName + " " + assignment.publisher.lastName}</td>
|
||||||
<td className="border px-2 py-2">{common.getDateFormated(new Date(shift.date))}</td>
|
<td className="border px-2 py-2">{new Date(assignment.shift.startTime).toLocaleString('bg')}</td>
|
||||||
<td className="border px-2 py-2">{shift.name}</td>
|
|
||||||
<td className="border px-2 py-2">
|
<td className="border px-2 py-2">
|
||||||
{shift.content}
|
{assignment.shift.content}
|
||||||
</td>
|
</td>
|
||||||
<td className="border px-4 py-2">
|
<td className="border px-4 py-2">
|
||||||
<button
|
<button
|
||||||
|
Reference in New Issue
Block a user