Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
JiashuHarryHuang committed Apr 27, 2024
1 parent b395ba1 commit 9c3d193
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 131 deletions.
37 changes: 19 additions & 18 deletions components/Event/Event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { Media } from '@/lib/media';
import Footer from '@/components/Event/Footer';
import { BOOKEM_THEME } from '@/utils/constants';
import {message} from 'antd';
import { message } from 'antd';
import ApplicationPopup from './EventApplication/ApplicationPopup';

/**
Expand Down Expand Up @@ -45,22 +45,25 @@ const Event = ({ event }: { event: QueriedVolunteerEventDTO }) => {

useEffect(() => {
const fetchApplicationStatus = async () => {

// Fetch the submitted application
const response = await fetch(`/api/event/${event._id}/submitted-application`, {
method: 'GET'
});
const response = await fetch(
`/api/event/${event._id}/submitted-application`,
{
method: 'GET',
}
);

// console.log("response: ", response.status)

// if the application is not found, it means the user has not applied to the event
// do nothing
if (response.status === 404 || response.status === 400){
if (response.status === 404 || response.status === 400) {
return;
}

const {application: eventApplication, response: applicationResponse} = await response.json();


const { application: eventApplication, response: applicationResponse } =
await response.json();

// console.log("application: ", eventApplication)
// console.log("response: ", applicationResponse)

Expand All @@ -71,11 +74,10 @@ const Event = ({ event }: { event: QueriedVolunteerEventDTO }) => {
setApplicationResponse(applicationResponse);
};

if (event.applicationId != null){
if (event.applicationId != null) {
fetchApplicationStatus();
}
}
, [event._id, event.applicationId]);
}, [event._id, event.applicationId]);

/**
* Sign up/Unsign up the current user to the event
Expand Down Expand Up @@ -195,20 +197,19 @@ const Event = ({ event }: { event: QueriedVolunteerEventDTO }) => {
</Media>

{/* Application Popup */}
{
event.applicationId != null &&
<ApplicationPopup
{event.applicationId != null && (
<ApplicationPopup
event={event}
visible={showApplication}
visible={showApplication}
onClose={() => {
setShowApplication(false);
}}
}}
onSubmit={() => {
message.success('Application Submitted');
setSignedUp(true);
}}
/>
}
)}
</>
);
};
Expand Down
4 changes: 2 additions & 2 deletions components/Event/EventApplication/ApplicationPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ export default function ApplicationPopup({
});

// no application questions found
if(res.status === 404){
if (res.status === 404) {
return;
}

const data = await res.json();
const questions = data.message;
setQuestions(questions);
Expand Down
47 changes: 24 additions & 23 deletions components/Event/EventApplication/ApplicationStatusDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
import { StatusDisplayText } from '@/styles/components/Event/eventName.styles';
import { CheckCircleOutlined, ReadOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import {
CheckCircleOutlined,
ReadOutlined,
ExclamationCircleOutlined,
} from '@ant-design/icons';
import { useState, useEffect } from 'react';
import {
ApplicationStatus,
ApplicationResponseData,
QueriedVolunteerEventDTO,
} from 'bookem-shared/src/types/database';


const ApprovedText = () => (
<span>
<CheckCircleOutlined
style={{
color: 'green',
margin: '0 10px',
}}
/>
Approved
style={{
color: 'green',
margin: '0 10px',
}}
/>
Approved
</span>
);

const PendingText = () => (
<span>
<ReadOutlined
style={{
color: 'orange',
margin: '0 10px',
}}
/>
Under Review
style={{
color: 'orange',
margin: '0 10px',
}}
/>
Under Review
</span>
);

const RejectedText = () => (
<span>
<ExclamationCircleOutlined
style={{
color: 'red',
margin: '0 10px',
}}
/>
Rejected
style={{
color: 'red',
margin: '0 10px',
}}
/>
Rejected
</span>
);



const statusDisplayText = {
[ApplicationStatus.Pending]: <PendingText />,
[ApplicationStatus.Approved]: <ApprovedText />,
Expand All @@ -67,7 +68,7 @@ const ApplicationStatusDisplay = ({

return (
<StatusDisplayText>
Application Status:
Application Status:
<br />
{statusDisplayText[applicationResponses.status]}
</StatusDisplayText>
Expand Down
3 changes: 0 additions & 3 deletions components/Event/EventName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export const getEventLength = (event: QueriedVolunteerEventDTO) => {
else return 0;
};




/**
* Contain the Event name and sign up button
* @param event
Expand Down
Loading

0 comments on commit 9c3d193

Please sign in to comment.