Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Submissions #718

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 37 additions & 34 deletions frontend/components/Applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,41 +103,44 @@ function ApplicationsPage({ whartonapplications }): ReactElement {
<AppsContainer>
<div className="columns is-multiline is-desktop is-tablet">
{whartonapplications != null && whartonapplications.length > 0 ? (
whartonapplications.map((application) => (
<CardWrapper className={'column is-half-desktop'}>
<Link href={application.external_url} target="_blank">
<Card className="card">
<MainInfo>
<div>
<ClubName>{application.name}</ClubName>
<DateInterval
start={application.application_start_time}
end={application.application_end_time}
/>
</div>
<div>
{application.club_image_url != null &&
application.club_image_url !== '' && (
<LazyLoad>
<Image src={application.club_image_url} />
</LazyLoad>
)}
</div>
</MainInfo>
{application.description &&
application.description.length && (
<DescriptionWrapper
dangerouslySetInnerHTML={{
__html: application.description,
}}
></DescriptionWrapper>
)}
</Card>
</Link>
</CardWrapper>
))
<div>
<Text>Only Wharton applications displayed here!</Text>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rephrase as "Note: only current Wharton applications are displayed on this page"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes

{whartonapplications.map((application) => (
<CardWrapper className={'column is-half-desktop'}>
<Link href={application.external_url} target="_blank">
<Card className="card">
<MainInfo>
<div>
<ClubName>{application.name}</ClubName>
<DateInterval
start={application.application_start_time}
end={application.application_end_time}
/>
</div>
<div>
{application.club_image_url != null &&
application.club_image_url !== '' && (
<LazyLoad>
<Image src={application.club_image_url} />
</LazyLoad>
)}
</div>
</MainInfo>
{application.description &&
application.description.length && (
<DescriptionWrapper
dangerouslySetInnerHTML={{
__html: application.description,
}}
></DescriptionWrapper>
)}
</Card>
</Link>
</CardWrapper>
))}
</div>
) : (
<Text>No applications are currently available.</Text>
<Text>No Wharton applications are currently available.</Text>
)}
</div>
</AppsContainer>
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@
"engines": {
"node": "^20.0.0"
}
}
}
49 changes: 46 additions & 3 deletions frontend/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import FavoritesTab from 'components/Settings/FavoritesTab'
import MembershipRequestsTab from 'components/Settings/MembershipRequestsTab'
import ProfileTab from 'components/Settings/ProfileTab'
import HashTabView from 'components/TabView'
import { NextPageContext } from 'next'
import React, { ReactNode } from 'react'
import { toast, TypeOptions } from 'react-toastify'
import renderPage from 'renderPage'
import styled from 'styled-components'
import { UserInfo } from 'types'
import { ApplicationSubmission, UserInfo } from 'types'
import { OBJECT_NAME_TITLE, SHOW_MEMBERSHIP_REQUEST } from 'utils/branding'

import ApplicationsPage from '~/components/Applications'
import TicketsTab from '~/components/Settings/TicketsTab'
import SubmissionsPage from '~/components/Submissions'
import { BG_GRADIENT, CLUBS_BLUE, WHITE } from '~/constants/colors'
import { BORDER_RADIUS } from '~/constants/measurements'
import { doBulkLookup } from '~/utils'

const Notification = styled.span`
border-radius: ${BORDER_RADIUS};
Expand All @@ -31,11 +35,18 @@ const Notification = styled.span`
`

type SettingsProps = {
userInfo: UserInfo
userInfo?: UserInfo
authenticated: boolean | null
submissions: ApplicationSubmission[]
whartonApplications: any
}

const Settings = ({ userInfo, authenticated }: SettingsProps) => {
const Settings = ({
userInfo,
authenticated,
whartonApplications,
submissions,
}: SettingsProps) => {
/**
* Display the message to the user in the form of a toast.
* @param The message to show to the user.
Expand Down Expand Up @@ -68,6 +79,16 @@ const Settings = ({ userInfo, authenticated }: SettingsProps) => {
icon: 'bookmark',
content: <FavoritesTab key="subscription" keyword="subscription" />,
},
{
name: 'submissions',
label: 'Submissions',
content: <SubmissionsPage initialSubmissions={submissions} />,
},
{
name: 'applications',
label: 'Applications',
content: <ApplicationsPage whartonapplications={whartonApplications} />,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be appropriate to also rename the prop in ApplicationsPage to be camelcase for simplicity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes

},
{
name: 'Requests',
icon: 'user-check',
Expand Down Expand Up @@ -103,4 +124,26 @@ const Settings = ({ userInfo, authenticated }: SettingsProps) => {
)
}

type BulkResp = {
whartonapplications: any
submissions: Array<ApplicationSubmission>
}

Settings.getInitialProps = async (ctx: NextPageContext) => {
const data: BulkResp = (await doBulkLookup(
['whartonapplications', 'submissions'],
ctx,
)) as BulkResp

const returner = {
whartonApplications: data.whartonapplications,
submissions: data.submissions,
}

return {
...returner,
fair: ctx.query.fair != null ? parseInt(ctx.query.fair as string) : null,
}
}

export default renderPage(Settings)
Loading