-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inidividual event report feature (#125)
* Added event report submitted or not, and graphql query/mutation * added frontend for the individual event report * event report updated and refactored * updated individual report - fixed issues * download report modified and download event added * Updated package lock file * File format * Updated Event Report and Event PDF download templates and formatted the files * formatting updated and iiith color logo added * line breaks adjusted * download option for event report in doc format added * final draft of templates for event report * Move event components into corresponding folder * paragraph spacing changed * Fix event bills status not coming on the page * added bill status into full event * bill status error handling changed * Separate out eventBills from FULL_EVENT and handle error accordingly * back button added and cc image size adjusted in doc * btn variant changed * warnings cleared * Updated react-pdf to latest version * added eventstatus in finance section --------- Co-authored-by: Bhav Beri <[email protected]>
- Loading branch information
1 parent
257b556
commit b8c1583
Showing
24 changed files
with
5,123 additions
and
380 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use server"; | ||
|
||
import { getClient } from "gql/client"; | ||
import { ADD_EVENT_REPORT } from "gql/mutations/events"; | ||
|
||
export async function createEventReportAction(details) { | ||
const response = { ok: false, data: null, error: null }; | ||
|
||
try { | ||
const client = getClient(); | ||
const result = await client.mutation(ADD_EVENT_REPORT, { details }); | ||
|
||
if (result.error) { | ||
response.error = { | ||
title: result.error.name, | ||
messages: result.error.graphQLErrors?.map((ge) => ge.message) || [ | ||
result.error.message, | ||
], | ||
}; | ||
} else if (result.data) { | ||
response.ok = true; | ||
response.data = result.data.addEventReport; | ||
} else { | ||
response.error = { | ||
title: "Unexpected Error", | ||
messages: ["No data returned from GraphQL server."], | ||
}; | ||
} | ||
} catch (error) { | ||
response.error = { | ||
title: "Request Error", | ||
messages: [error.message], | ||
}; | ||
} | ||
|
||
return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { getClient } from "gql/client"; | ||
import { GET_FULL_EVENT } from "gql/queries/events"; | ||
import { redirect } from "next/navigation"; | ||
import { GET_USER } from "gql/queries/auth"; | ||
|
||
import { Container, Typography } from "@mui/material"; | ||
|
||
import EventReportForm from "components/events/report/EventReportForm"; | ||
|
||
export const metadata = { | ||
title: "Create Event Report", | ||
}; | ||
|
||
function transformEvent(event) { | ||
return { | ||
...event, | ||
datetimeperiod: [ | ||
new Date(event?.datetimeperiod[0]), | ||
new Date(event?.datetimeperiod[1]), | ||
], | ||
budget: | ||
event?.budget?.map((budget, key) => ({ | ||
...budget, | ||
id: budget?.id || key, | ||
})) || [], | ||
population: parseInt(event?.population || 0), | ||
additional: event?.additional || "", | ||
equipment: event?.equipment || "", | ||
poc: event?.poc, | ||
collabclubs: event?.collabclubs || [], | ||
}; | ||
} | ||
|
||
export default async function NewEventReport({ params }) { | ||
const { id } = params; | ||
const { data: { userMeta, userProfile } = {} } = await getClient().query( | ||
GET_USER, | ||
{ userInput: null } | ||
); | ||
const user = { ...userMeta, ...userProfile }; | ||
|
||
try { | ||
const { data: { event } = {} } = await getClient().query(GET_FULL_EVENT, { | ||
eventid: id, | ||
}); | ||
if ( | ||
!event || | ||
event?.eventReportSubmitted || | ||
user?.uid !== event.clubid || | ||
event.status.state !== "approved" | ||
) { | ||
return redirect("/404"); | ||
} | ||
return ( | ||
<Container> | ||
<Typography variant="h3" gutterBottom mb={3}> | ||
Create Event Report | ||
</Typography> | ||
|
||
<EventReportForm | ||
id={id} | ||
defaultValues={transformEvent(event)} | ||
action="create" | ||
/> | ||
</Container> | ||
); | ||
} catch (error) { | ||
return redirect("/404"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { getClient } from "gql/client"; | ||
import { GET_EVENT_REPORT, GET_FULL_EVENT } from "gql/queries/events"; | ||
import { GET_ACTIVE_CLUBS } from "gql/queries/clubs"; | ||
import { getFullUser } from "actions/users/get/full/server_action"; | ||
import { EventReportDetails } from "components/events/report/EventReportDetails"; | ||
import { GET_USER } from "gql/queries/auth"; | ||
import { redirect } from "next/navigation"; | ||
|
||
export default async function EventReport({ params }) { | ||
const { id } = params; | ||
|
||
try { | ||
const { data: { event } = {} } = await getClient().query(GET_FULL_EVENT, { | ||
eventid: id, | ||
}); | ||
|
||
const { data: { userMeta, userProfile } = {} } = await getClient().query( | ||
GET_USER, | ||
{ userInput: null }, | ||
); | ||
const user = { ...userMeta, ...userProfile }; | ||
user?.role === "club" && | ||
user?.uid !== event.clubid && | ||
!event?.collabclubs.includes(user?.uid) && | ||
redirect("/404"); | ||
|
||
if (!event || !event?.eventReportSubmitted) { | ||
return redirect("/404"); | ||
} | ||
|
||
const { data: { eventReport } = {} } = await getClient().query( | ||
GET_EVENT_REPORT, | ||
{ | ||
eventid: id, | ||
} | ||
); | ||
|
||
const { | ||
data: { activeClubs }, | ||
} = await getClient().query(GET_ACTIVE_CLUBS); | ||
|
||
const submittedUserProfile = await getFullUser(eventReport?.submittedBy); | ||
if (!submittedUserProfile || !eventReport) { | ||
return redirect("/404"); | ||
} | ||
|
||
return ( | ||
<EventReportDetails | ||
event={event} | ||
eventReport={eventReport} | ||
submittedUser={submittedUserProfile} | ||
clubs={activeClubs} | ||
/> | ||
); | ||
} catch (error) { | ||
return redirect("/404"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,74 @@ | ||
import { getClient } from "gql/client"; | ||
import { GET_EVENT_BILLS_STATUS } from "gql/queries/events"; | ||
import { redirect, notFound } from "next/navigation"; | ||
import Link from "next/link"; | ||
|
||
import { Button, Container, Stack, Typography } from "@mui/material"; | ||
|
||
import BillsStatusForm from "components/events/EditBillsStatus"; | ||
import BillsStatusForm from "components/events/bills/EditBillsStatus"; | ||
|
||
export const metadata = { | ||
title: "Edit Bill Status", | ||
}; | ||
|
||
export default async function EditHoliday({ params }) { | ||
export default async function EditFinance({ params }) { | ||
const { id } = params; | ||
|
||
try { | ||
const { data, error } = await getClient().query(GET_EVENT_BILLS_STATUS, { | ||
eventid: id, | ||
}); | ||
|
||
if ((error || !data) && !error?.message.includes("Bills status not found")) | ||
notFound(); | ||
|
||
const defaultValues = { | ||
state: null, | ||
sloComment: null, | ||
}; | ||
|
||
const eventBills = data?.eventBills || defaultValues; | ||
const { data, error } = await getClient().query(GET_EVENT_BILLS_STATUS, { | ||
eventid: id, | ||
}); | ||
|
||
if (error && !error.message.includes("no bills status")) { | ||
return ( | ||
<Container> | ||
<Stack | ||
direction="row" | ||
alignItems="center" | ||
justifyContent="space-between" | ||
mb={3} | ||
> | ||
<Typography variant="h3" gutterBottom> | ||
Edit Bill Status Details | ||
</Typography> | ||
<Typography variant="h4" align="center" mt={5} px={2}> | ||
Error: {error.message.slice(10)} | ||
</Typography> | ||
<Stack direction="column" alignItems="center" mt={2}> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
component={Link} | ||
href={`/manage/events/${id}`} | ||
href={`/manage/finances`} | ||
> | ||
<Typography variant="button" color="opposite"> | ||
View Event | ||
Go Back | ||
</Typography> | ||
</Button> | ||
</Stack> | ||
<BillsStatusForm id={id} defaultValues={eventBills} /> | ||
</Container> | ||
); | ||
} catch (error) { | ||
return redirect("/404"); | ||
} | ||
|
||
const defaultValues = { | ||
state: null, | ||
sloComment: null, | ||
}; | ||
|
||
const eventBills = data?.eventBills || defaultValues; | ||
|
||
return ( | ||
<Container> | ||
<Stack | ||
direction="row" | ||
alignItems="center" | ||
justifyContent="space-between" | ||
mb={3} | ||
> | ||
<Typography variant="h3" gutterBottom> | ||
Edit Bill Status Details | ||
</Typography> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
component={Link} | ||
href={`/manage/events/${id}`} | ||
> | ||
<Typography variant="button" color="opposite"> | ||
View Event | ||
</Typography> | ||
</Button> | ||
</Stack> | ||
<BillsStatusForm id={id} defaultValues={eventBills} /> | ||
</Container> | ||
); | ||
} |
Oops, something went wrong.