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 all 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
84 changes: 45 additions & 39 deletions frontend/components/Applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,50 +94,55 @@ const AppsContainer = styled.div`
min-height: 60vh;
`

function ApplicationsPage({ whartonapplications }): ReactElement {
if ('detail' in whartonapplications) {
return <Text>{whartonapplications.detail}</Text>
function ApplicationsPage({ whartonApplications }): ReactElement {
if ('detail' in whartonApplications) {
return <Text>{whartonApplications.detail}</Text>
}

return (
<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>
))
{whartonApplications != null && whartonApplications.length > 0 ? (
<div>
<Text>
Note: only current Wharton applications are displayed on this page{' '}
</Text>
{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 All @@ -153,8 +158,9 @@ ApplicationsPage.getInitialProps = async (ctx: NextPageContext) => {
['whartonapplications'],
ctx,
)) as BulkResp

return {
...data,
whartonApplications: data.whartonapplications,
fair: ctx.query.fair != null ? parseInt(ctx.query.fair as string) : null,
}
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/pages/apply/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ApplicationsPage from '~/components/Applications'
import SubmissionsPage from '~/components/Submissions'
import { BrowserTabView } from '~/components/TabView'
import { APPLY_ROUTE, BG_GRADIENT, WHITE } from '~/constants'
import { ApplicationSubmission } from '~/types'
import { Application, ApplicationSubmission } from '~/types'

function ApplyDashboard({
whartonapplications,
Expand All @@ -24,7 +24,7 @@ function ApplyDashboard({
name: 'applications',
label: 'Applications',
content: () => (
<ApplicationsPage whartonapplications={whartonapplications} />
<ApplicationsPage whartonApplications={whartonapplications} />
),
},
{
Expand Down Expand Up @@ -56,7 +56,7 @@ function ApplyDashboard({
}

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

Expand Down
45 changes: 42 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 { Application, 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} />,
},
{
name: 'Requests',
icon: 'user-check',
Expand Down Expand Up @@ -103,4 +124,22 @@ const Settings = ({ userInfo, authenticated }: SettingsProps) => {
)
}

type BulkResp = {
whartonapplications: Application[]
submissions: Array<ApplicationSubmission>
}

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

return {
whartonApplications: data.whartonapplications,
submissions: data.submissions,
fair: ctx.query.fair != null ? parseInt(ctx.query.fair as string) : null,
}
}

export default renderPage(Settings)
Loading