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

Move submissions from /apply to user profile #638

Merged
merged 11 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 0 additions & 1 deletion frontend/pages/admin/[[...slug]].tsx
Copy link
Member

Choose a reason for hiding this comment

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

Just curious if there's any reason for this change, seems to pass lint regardless but the previous spacing was more consistent on first glance, IMO.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function AdminPage({
}

const router = useRouter()

const tabs = [
{
name: 'bulk',
Expand Down
27 changes: 25 additions & 2 deletions frontend/pages/settings.tsx
Copy link
Member

Choose a reason for hiding this comment

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

I would appreciate if you can still use the existing SettingsProps type, e.g. edit it to include submissions and type the props for the Settings page again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm getting a lot of mismatch type errors when I do that– I believe because of getInitialProps. We can resolve during the meeting Friday

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ 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 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 @@ -34,7 +37,7 @@ type SettingsProps = {
authenticated: boolean | null
}

const Settings = ({ userInfo, authenticated }: SettingsProps) => {
const Settings = ({ userInfo, authenticated, submissions }) => {
/**
* Display the message to the user in the form of a toast.
* @param The message to show to the user.
Expand Down Expand Up @@ -67,6 +70,11 @@ const Settings = ({ userInfo, authenticated }: SettingsProps) => {
icon: 'bookmark',
content: <FavoritesTab key="subscription" keyword="subscription" />,
},
{
name: 'submissions',
label: 'Submissions',
content: () => <SubmissionsPage initialSubmissions={submissions} />,
},
{
name: 'Requests',
icon: 'user-check',
Expand Down Expand Up @@ -97,4 +105,19 @@ const Settings = ({ userInfo, authenticated }: SettingsProps) => {
)
}

type BulkResp = {
submissions: Array<ApplicationSubmission>
}

Settings.getInitialProps = async (ctx: NextPageContext) => {
const data: BulkResp = (await doBulkLookup(
['submissions', '/submissions/?format=json'],
Copy link
Member

Choose a reason for hiding this comment

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

cc @rm03

Copy link
Member

Choose a reason for hiding this comment

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

Looks like the ?format=json is not needed as doBulkLookup() automatically appends this to the end of any API call. Also, why are we calling doBulkLookup() here instead of doApiRequest()?

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

export default renderPage(Settings)
Loading