Skip to content

Commit

Permalink
Revert "support approved on as well as frontend cleanup"
Browse files Browse the repository at this point in the history
This reverts commit 9bf437c.
  • Loading branch information
rohangpta committed Aug 16, 2023
1 parent 9bf437c commit 9ecfb41
Show file tree
Hide file tree
Showing 20 changed files with 6,011 additions and 6,015 deletions.
1 change: 0 additions & 1 deletion backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,6 @@ class Meta(ClubSerializer.Meta):
"terms",
"owners",
"officers",
"approved_on",
]


Expand Down
15 changes: 7 additions & 8 deletions frontend/components/Applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ function ApplicationsPage({ whartonapplications }): ReactElement {
)}
</div>
</MainInfo>
{application.description &&
application.description.length && (
<DescriptionWrapper
dangerouslySetInnerHTML={{
__html: application.description,
}}
></DescriptionWrapper>
)}
{application.description && application.description.length && (
<DescriptionWrapper
dangerouslySetInnerHTML={{
__html: application.description,
}}
></DescriptionWrapper>
)}
</Card>
</a>
</Link>
Expand Down
11 changes: 9 additions & 2 deletions frontend/components/ClubCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ type ClubCardProps = {
}

const ClubCard = ({ club, fullWidth }: ClubCardProps): ReactElement => {
const { name, active, approved, subtitle, tags, enables_subscription, code } =
club
const {
name,
active,
approved,
subtitle,
tags,
enables_subscription,
code,
} = club
const img = club.image_url
const textDescription = shorten(subtitle || 'This club has no description.')

Expand Down
16 changes: 10 additions & 6 deletions frontend/components/ClubEditPage/ApplicationsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ const ApplicationModal = (props: {
committeeChoices,
} = props
// TODO: I'm positive that this is something that Formik should do for me
const [questionType, setQuestionType] =
useState<ApplicationQuestionType | null>()
const [multipleChoices, setMultipleChoices] =
useState<[{ label: string; value: string }]>()
const [committees, setCommittees] =
useState<[{ label: string; value: string }]>()
const [
questionType,
setQuestionType,
] = useState<ApplicationQuestionType | null>()
const [multipleChoices, setMultipleChoices] = useState<
[{ label: string; value: string }]
>()
const [committees, setCommittees] = useState<
[{ label: string; value: string }]
>()
const [committeeQuestion, setCommitteeQuestion] = useState<boolean>()

const validateWordCount = (value) => {
Expand Down
28 changes: 17 additions & 11 deletions frontend/components/ClubEditPage/ApplicationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,20 @@ export default function ApplicationsPage({
club: Club
}): ReactElement {
const [applications, setApplications] = useState<Array<Application>>([])
const [currentApplication, setCurrentApplication] =
useState<Application | null>(null)
const [
currentApplication,
setCurrentApplication,
] = useState<Application | null>(null)
const [submissions, setSubmissions] = useState<{
[key: number]: Array<ApplicationSubmission>
}>([])
const [showModal, setShowModal] = useState<boolean>(false)
const [showNotifModal, setShowNotifModal] = useState<boolean>(false)
const [showReasonModal, setShowReasonModal] = useState<boolean>(false)
const [currentSubmission, setCurrentSubmission] =
useState<ApplicationSubmission | null>(null)
const [
currentSubmission,
setCurrentSubmission,
] = useState<ApplicationSubmission | null>(null)
const [pageIndex, setPageIndex] = useState<number>(0)
const [statusToggle, setStatusToggle] = useState<boolean>(false)
const [categoriesSelectAll, setCategoriesSelectAll] = useState<Array<string>>(
Expand Down Expand Up @@ -604,8 +608,9 @@ export default function ApplicationsPage({
categoriesSelectAll.includes(statusLabel)

if (deselecting) {
const newCategoriesSelectAll =
categoriesSelectAll.filter((e) => e !== statusLabel)
const newCategoriesSelectAll = categoriesSelectAll.filter(
(e) => e !== statusLabel,
)
setCategoriesSelectAll(newCategoriesSelectAll)
} else {
const newCategoriesSelectAll = categoriesSelectAll
Expand Down Expand Up @@ -668,11 +673,12 @@ export default function ApplicationsPage({
<ScrollWrapper>
<TableWrapper>
<Table
data={submissions[currentApplication.id].map(
(item, index) =>
item.pk
? { ...item, id: item.pk }
: { ...item, id: index },
data={submissions[
currentApplication.id
].map((item, index) =>
item.pk
? { ...item, id: item.pk }
: { ...item, id: index },
)}
columns={responseTableFields}
searchableColumns={['name']}
Expand Down
50 changes: 27 additions & 23 deletions frontend/components/ClubEditPage/ClubEditCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,25 +195,29 @@ export default function ClubEditCard({
),
)

const [showSchoolYearProgramming, setSchoolYearProgramming] =
useState<boolean>(
!!(
club.target_majors?.length ||
club.target_schools?.length ||
club.target_years?.length ||
club.student_types?.length
),
)
const [
showSchoolYearProgramming,
setSchoolYearProgramming,
] = useState<boolean>(
!!(
club.target_majors?.length ||
club.target_schools?.length ||
club.target_years?.length ||
club.student_types?.length
),
)

const [showStudentTypeProgramming, setStudentTypeProgramming] =
useState<boolean>(
!!(
club.target_majors?.length ||
club.target_schools?.length ||
club.target_years?.length ||
club.student_types?.length
),
)
const [
showStudentTypeProgramming,
setStudentTypeProgramming,
] = useState<boolean>(
!!(
club.target_majors?.length ||
club.target_schools?.length ||
club.target_years?.length ||
club.student_types?.length
),
)

const [showSchoolProgramming, setSchoolProgramming] = useState<boolean>(
!!(
Expand All @@ -239,10 +243,10 @@ export default function ClubEditCard({
)

// sorry ts
const exclusives = categorizeFilter(
const exclusives = (categorizeFilter(
exclusiveEntries,
([key]) => key.match(/^exclusive:(.+?):(.+?)$/)?.[1] ?? 'unknown',
) as unknown as {
) as unknown) as {
year: Array<[string, { checked?: boolean; detail?: string }]>
// major: Array<[string, { checked?: boolean; detail?: string }]>
student_type: Array<[string, { checked?: boolean; detail?: string }]>
Expand Down Expand Up @@ -492,7 +496,8 @@ export default function ClubEditCard({
label: 'Location',
required: false,
type: 'location',
help: 'Remember, this will be available to the public. Please only include information you feel comfortable sharing.',
help:
'Remember, this will be available to the public. Please only include information you feel comfortable sharing.',
},
{
name: 'email',
Expand Down Expand Up @@ -860,8 +865,7 @@ export default function ClubEditCard({
image: FileField,
address: FormikAddressField,
checkboxText: CheckboxTextField,
creatableMultiSelect:
CreatableMultipleSelectField,
creatableMultiSelect: CreatableMultipleSelectField,
}[props.type] ?? TextField
}
{...other}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/FormComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import DatePicker from 'react-datepicker'
import Select from 'react-select'
import CreatableSelect from 'react-select/creatable'
import styled from 'styled-components'
import { v4 as uuid } from 'uuid'
import uuid from 'uuid'

import { DynamicQuestion } from '../types'
import { titleize } from '../utils'
Expand Down
6 changes: 4 additions & 2 deletions frontend/components/ModelForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ export const ModelTable = ({
*/
export const ModelForm = (props: ModelFormProps): ReactElement => {
const [objects, setObjects] = useState<ModelObject[]>([])
const [currentlyEditing, changeCurrentlyEditing] =
useState<ModelObject | null>(null)
const [
currentlyEditing,
changeCurrentlyEditing,
] = useState<ModelObject | null>(null)
const [newCount, changeNewCount] = useState<number>(0)
const [createObject, changeCreateObject] = useState<ModelObject>(
props.defaultObject != null
Expand Down
6 changes: 4 additions & 2 deletions frontend/components/Submissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ function SubmissionsPage({
formatSubmissions(initialSubmissions),
)
const [showModal, setShowModal] = useState<boolean>(false)
const [currentSubmission, setCurrentSubmission] =
useState<ApplicationSubmission | null>(null)
const [
currentSubmission,
setCurrentSubmission,
] = useState<ApplicationSubmission | null>(null)

const responseTableFields = [
{ label: 'Application', name: 'name' },
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/common/AuthPrompt.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default {
component: AuthPrompt,
}

export const Default: Story<React.ComponentProps<typeof AuthPrompt>> =
AuthPrompt.bind({})
export const Default: Story<
React.ComponentProps<typeof AuthPrompt>
> = AuthPrompt.bind({})

Default.args = {
title: undefined,
Expand Down
42 changes: 21 additions & 21 deletions frontend/components/reports/ReportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,28 @@ type Props = {
/**
* Try to reconcile the JSON format for tags/badges returned by the API and the format that the field is expecting.
*/
export const fixDeserialize =
(options: { id: number; label?: string; name?: string }[]) =>
(value): { id: number; label: string }[] => {
if (typeof value === 'string') {
return value
.trim()
.split(',')
.filter((tag) => tag.length > 0)
.map((tag) => {
const id = parseInt(tag)
const trueVal = options.find((oth) => oth.id === id)
if (trueVal != null) {
trueVal.label = trueVal.label ?? trueVal.name ?? 'Unknown'
}
return trueVal != null ? trueVal : { id, label: 'Unknown' }
}) as { id: number; label: string }[]
}
if (Array.isArray(value)) {
return value.map(({ id, name }) => ({ id, label: name }))
}
return []
export const fixDeserialize = (
options: { id: number; label?: string; name?: string }[],
) => (value): { id: number; label: string }[] => {
if (typeof value === 'string') {
return value
.trim()
.split(',')
.filter((tag) => tag.length > 0)
.map((tag) => {
const id = parseInt(tag)
const trueVal = options.find((oth) => oth.id === id)
if (trueVal != null) {
trueVal.label = trueVal.label ?? trueVal.name ?? 'Unknown'
}
return trueVal != null ? trueVal : { id, label: 'Unknown' }
}) as { id: number; label: string }[]
}
if (Array.isArray(value)) {
return value.map(({ id, name }) => ({ id, label: name }))
}
return []
}

const ReportForm = ({
fields,
Expand Down
2 changes: 1 addition & 1 deletion frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
? process.env.DOMAIN.startsWith('http')
? process.env.DOMAIN
: `https://${process.env.DOMAIN}`
: `http://127.0.0.1:${process.env.PORT || 3000}`,
: `http://localhost:${process.env.PORT || 3000}`,
NEXT_PUBLIC_SITE_NAME: process.env.NEXT_PUBLIC_SITE_NAME || 'clubs',
SENTRY_URL: process.env.SENTRY_URL,
},
Expand Down
3 changes: 1 addition & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@storybook/react": "^6.1.15",
"@types/cheerio": "^0.22.21",
"@types/node": "^14.14.22",
"@types/react": "18.0.1",
"@types/react": "^17.0.0",
"@types/react-select": "^4.0.11",
"@types/showdown": "^1.9.3",
"@types/styled-components": "^5.1.1",
Expand All @@ -103,7 +103,6 @@
"nyc": "^15.0.0",
"prettier": "^2.0.5",
"typescript": "^4.1.2",
"uuid": "^9.0.0",
"wait-on": "^5.2.0"
}
}
27 changes: 15 additions & 12 deletions frontend/pages/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ const parseDateRange = (
}
} else {
const max = new Date(
Math.max(...(range as unknown as number[])) + 24 * 60 * 60 * 1000,
Math.max(...((range as unknown) as number[])) + 24 * 60 * 60 * 1000,
)
const min = new Date(Math.min(...(range as unknown as number[])))
const min = new Date(Math.min(...((range as unknown) as number[])))
range = { start: min, end: max }
}
}
Expand Down Expand Up @@ -435,8 +435,9 @@ function EventPage({
clubs,
fair,
}: EventPageProps): ReactElement {
const [calendarEvents, setCalendarEvents] =
useState<ClubEvent[]>(initialEvents)
const [calendarEvents, setCalendarEvents] = useState<ClubEvent[]>(
initialEvents,
)

const isFair = fair != null

Expand All @@ -458,8 +459,9 @@ function EventPage({
EventsViewOption.LIST,
)

const [dateRange, setDateRange] =
useState<CalendarDateRange>(initialDateRange)
const [dateRange, setDateRange] = useState<CalendarDateRange>(
initialDateRange,
)

const currentSearch = useRef<
[SearchInput, EventsViewOption, CalendarDateRange]
Expand Down Expand Up @@ -882,9 +884,9 @@ EventPage.getInitialProps = async (ctx: NextPageContext) => {
: await cache(
'pages:events:fair',
async () => {
return doApiRequest('/clubfairs/current/?format=json').then(
(resp) => resp.json(),
)
return doApiRequest(
'/clubfairs/current/?format=json',
).then((resp) => resp.json())
},
60 * 1000,
)
Expand All @@ -896,9 +898,10 @@ EventPage.getInitialProps = async (ctx: NextPageContext) => {
async () => {
const [tags, badges, clubs] = await Promise.all([
doApiRequest('/tags/?format=json', data).then((resp) => resp.json()),
doApiRequest(`/badges/?fair=${cachedFair?.id}&format=json`, data).then(
(resp) => resp.json(),
),
doApiRequest(
`/badges/?fair=${cachedFair?.id}&format=json`,
data,
).then((resp) => resp.json()),
doApiRequest('/clubs/directory/?format=json', data)
.then((resp) => resp.json())
.then((resp) => resp.filter(({ approved }) => approved)),
Expand Down
Loading

0 comments on commit 9ecfb41

Please sign in to comment.