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 20 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
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"
}
}
}
43 changes: 40 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
Copy link
Member

Choose a reason for hiding this comment

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

Nit: camel case variable name and adding types would be nice (I know the reference code didn't have either but it would be good practice)

}

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.

Now that the page is more visible in the profile, would be nice to clarify that it's for Wharton Cycle applications specifically (maybe change it to all eventually but not needed now).

},
{
name: 'Requests',
icon: 'user-check',
Expand Down Expand Up @@ -103,4 +124,20 @@ 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
return {
...data,
fair: ctx.query.fair != null ? parseInt(ctx.query.fair as string) : null,
}
}

export default renderPage(Settings)
Loading