Skip to content

Commit

Permalink
added bill status into full event
Browse files Browse the repository at this point in the history
  • Loading branch information
Dileepadari committed Dec 24, 2024
1 parent f142017 commit badcee3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/app/manage/events/[id]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function generateMetadata({ params }) {
export default async function ManageEventID({ params }) {
const { id } = params;

const { data: { event } = {} } = await getClient().query(GET_FULL_EVENT, {
const { data: { event, eventBills } = {} } = await getClient().query(GET_FULL_EVENT, {
eventid: id,
});

Expand Down Expand Up @@ -98,6 +98,7 @@ export default async function ManageEventID({ params }) {
event={event}
clubs={activeClubs}
pocProfile={pocProfile}
eventBills={eventBills}
/>
}
/>
Expand Down Expand Up @@ -190,7 +191,7 @@ export default async function ManageEventID({ params }) {
{EventApprovalStatus(event?.status, event?.studentBodyEvent)}

{/* show post event information */}
{["cc", "club", "slo"].includes(user?.role) && EventBillStatus(event)}
{["cc", "club", "slo"].includes(user?.role) && EventBillStatus(event, eventBills)}
{["cc", "club", "slo"].includes(user?.role) &&
EventReportStatus(event, user)}
</Box>
Expand Down
7 changes: 4 additions & 3 deletions src/app/manage/events/[id]/report/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export default async function EventReport({ params }) {
{ userInput: null },
);
const user = { ...userMeta, ...userProfile };
if (user?.role === "club" && user?.uid !== event?.clubid) {
return redirect("/404");
}
user?.role === "club" &&
user?.uid !== event.clubid &&
!event?.collabclubs.includes(user?.uid) &&
redirect("/404");

if (!event || !event?.eventReportSubmitted) {
return redirect("/404");
Expand Down
13 changes: 2 additions & 11 deletions src/components/events/bills/EventBillStatus.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { getClient } from "gql/client";
import { GET_EVENT_BILLS_STATUS } from "gql/queries/events";

import { Box, Grid, Typography, Divider } from "@mui/material";

import { billsStateLabel } from "utils/formatEvent";

export default async function EventBillStatus(event) {
export default async function EventBillStatus(event, eventBills) {
if (
event?.status?.state !== "approved" ||
new Date(event?.datetimeperiod[1]) > new Date() ||
event?.budget?.length === 0
)
return null;

const { data, error } = await getClient().query(GET_EVENT_BILLS_STATUS, {
eventid: event?._id,
});

if (error || !data) return null;

const eventBills = data?.eventBills;
if (!eventBills) return null;

return (
<>
Expand Down
15 changes: 7 additions & 8 deletions src/components/events/report/EventpdfDownloads.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export function DownloadEventReport({
);
}

export function DownloadEvent({ event, clubs, pocProfile }) {
export function DownloadEvent({ event, clubs, pocProfile, eventBills }) {
const startDate = event?.datetimeperiod
? formatDateTime(event.datetimeperiod[0])
: null;
Expand Down Expand Up @@ -719,23 +719,22 @@ export function DownloadEvent({ event, clubs, pocProfile }) {
event?.budget?.length
? `
<div class="section">
<h2>Bill Status</h2>
<h2>Bill Information</h2>
${
event?.billStatus
eventBills
? `
<div>
<h3>Bill Information</h3>
<p><strong>Bills Status:</strong> ${
event?.billStatus?.state == null
eventBills?.state == null
? "Information not available"
: billsStateLabel(event?.billStatus?.state)?.name
: billsStateLabel(eventBills?.state)?.name
}</p>
<p><strong>Last Updated:</strong> ${
event?.billStatus?.updatedTime || "Information not available"
eventBills?.updatedTime || "Information not available"
}</p>
<p><strong>SLO Comment:</strong> ${
event?.billStatus?.sloComment || "-"
eventBills?.sloComment || "-"
}</p>
</div>
`
Expand Down
5 changes: 5 additions & 0 deletions src/gql/queries/events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ export const GET_FULL_EVENT = gql`
}
eventReportSubmitted
}
eventBills(eventid: $eventid) {
state
sloComment
updatedTime
}
}
`;

Expand Down

0 comments on commit badcee3

Please sign in to comment.