add accepted cover requests
This commit is contained in:
@ -35,6 +35,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
throw new Error('Model is required as a part of the URL path.');
|
throw new Error('Model is required as a part of the URL path.');
|
||||||
}
|
}
|
||||||
const modelName = modelArray[0]; // Get the first part of the model array
|
const modelName = modelArray[0]; // Get the first part of the model array
|
||||||
|
if (!prisma[modelName]) {
|
||||||
|
throw new Error(`Model ${modelName} not found in Prisma client.`);
|
||||||
|
}
|
||||||
const result = await prisma[modelName].findMany(queryOptions);
|
const result = await prisma[modelName].findMany(queryOptions);
|
||||||
res.status(200).json(result);
|
res.status(200).json(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -25,26 +25,11 @@ export default function EventLogList() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchLocations = async () => {
|
const fetchLocations = async () => {
|
||||||
try {
|
try {
|
||||||
console.log("fetching locations");
|
const { data: eventLogsData } = await axiosInstance.get(`/api/data/prisma/eventLog?where={"type":"${EventLogType.AssignmentReplacementAccepted}"}
|
||||||
const { data: locData } = await axiosInstance.get("/api/data/locations");
|
&include={"publisher":{"select":{"firstName":true,"lastName":true}},"shift":{"include":{"publishers":{"select":{"firstName":true,"lastName":true}}}}}`);
|
||||||
setLocations(locData);
|
|
||||||
console.log(locData);
|
|
||||||
axiosInstance.get(`/api/data/eventlogs`)
|
|
||||||
.then((res) => {
|
|
||||||
// let reports = res.data;
|
|
||||||
// reports.forEach((report) => {
|
|
||||||
// report.location = data.find((loc) => loc.id === report.locationId);
|
|
||||||
// });
|
|
||||||
setEventLog(res.data);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: eventLogsData } = await axiosInstance.get(`/api/data/prisma/eventlog?where={"type":"${EventLogType.AssignmentReplacementAccepted}"}`)
|
|
||||||
setEventLog(eventLogsData);
|
setEventLog(eventLogsData);
|
||||||
//get shifts where publicGuid is 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}}}`)
|
const { data: shiftsData } = await axiosInstance.get(`/api/data/prisma/assignment?where={"publicGuid":{"not":"null"}}&include={"shift":{"include":{"publishers":{"select":{"firstName":true,"lastName":true}}}},"publisher":{"select":{"firstName":true,"lastName":true}}}`)
|
||||||
setRequestedAssignments(shiftsData);
|
setRequestedAssignments(shiftsData);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -71,7 +56,7 @@ export default function EventLogList() {
|
|||||||
|
|
||||||
<label className={`cursor-pointer px-4 py-2 rounded-full ${!showOpenRequests ? 'bg-blue-500 text-white' : 'bg-gray-200 text-gray-800'}`}>
|
<label className={`cursor-pointer px-4 py-2 rounded-full ${!showOpenRequests ? 'bg-blue-500 text-white' : 'bg-gray-200 text-gray-800'}`}>
|
||||||
<input type="radio" name="reportType" value="ServiceReport" onChange={() => setShowOpenRequests(false)} checked={!showOpenRequests} className="sr-only" />
|
<input type="radio" name="reportType" value="ServiceReport" onChange={() => setShowOpenRequests(false)} checked={!showOpenRequests} className="sr-only" />
|
||||||
Заявки
|
Приети заявки
|
||||||
</label>
|
</label>
|
||||||
<label className={`cursor-pointer px-4 py-2 rounded-full ${showOpenRequests ? 'bg-blue-500 text-white' : 'bg-gray-200 text-gray-800'}`}>
|
<label className={`cursor-pointer px-4 py-2 rounded-full ${showOpenRequests ? 'bg-blue-500 text-white' : 'bg-gray-200 text-gray-800'}`}>
|
||||||
<input type="radio" name="reportType" value="Experience" onChange={() => setShowOpenRequests(true)} checked={showOpenRequests} className="sr-only" />
|
<input type="radio" name="reportType" value="Experience" onChange={() => setShowOpenRequests(true)} checked={showOpenRequests} className="sr-only" />
|
||||||
@ -92,7 +77,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.startTime))}</td>
|
<td className="border px-2 py-2">{common.getDateFormated(new Date(event.date))}</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}
|
||||||
@ -111,7 +96,9 @@ export default function EventLogList() {
|
|||||||
<td className="border px-2 py-2">{assignment.publisher.firstName + " " + assignment.publisher.lastName}</td>
|
<td className="border px-2 py-2">{assignment.publisher.firstName + " " + assignment.publisher.lastName}</td>
|
||||||
<td className="border px-2 py-2">{new Date(assignment.shift.startTime).toLocaleString('bg')}</td>
|
<td className="border px-2 py-2">{new Date(assignment.shift.startTime).toLocaleString('bg')}</td>
|
||||||
<td className="border px-2 py-2">
|
<td className="border px-2 py-2">
|
||||||
{assignment.shift.content}
|
{assignment.shift.publishers.map((publisher) => (
|
||||||
|
<div key={publisher.id}>{publisher.firstName + " " + publisher.lastName}</div>
|
||||||
|
))}
|
||||||
</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