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 23 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
87 changes: 48 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,12 @@ ApplicationsPage.getInitialProps = async (ctx: NextPageContext) => {
['whartonapplications'],
ctx,
)) as BulkResp

const returner = {
whartonApplications: data.whartonapplications,
}
return {
...data,
...returner,
fair: ctx.query.fair != null ? parseInt(ctx.query.fair as string) : null,
}
}
Expand Down
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} />,
},
{
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