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 ugly hack for dashboard auto refresh #42

Merged
merged 2 commits into from
Aug 26, 2023
Merged
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
17 changes: 1 addition & 16 deletions src/app/ApplicationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import Link from 'next/link'
import { useEffect, useState } from 'react'
import { useState } from 'react'

import { Box } from '@/components/Box'
import { Button } from '@/components/Button'
Expand Down Expand Up @@ -88,16 +88,6 @@ export function ApplicationForm() {
}
}

useEffect(() => {
window.addEventListener(
'beforeunload',
(e) => {
e.preventDefault()
},
{ capture: true },
)
}, [])

return (
<Box
id="applicationForm"
Expand Down Expand Up @@ -256,11 +246,6 @@ export function ApplicationForm() {
/>

<Heading level={3}>MLH Checkboxes</Heading>
<p>
We are currently in the process of partnering with MLH. The following 3
checkboxes are for this partnership. If we do not end up partnering with
MLH, your information will not be shared.
</p>
<Dropdown
id="agreedMlhCoC"
text={
Expand Down
11 changes: 8 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Image from 'next/image'

import { Box } from '@/components/Box'
import { LinkButton } from '@/components/Button'
import { Header } from '@/components/Header'
import { Heading } from '@/components/Heading'
import { Organizer, OrganizerProps } from '@/components/Organizer'
import clientPromise from '@/lib/db'
Expand Down Expand Up @@ -151,7 +150,7 @@ async function Dashboard({ user }: { user: JsonUser }) {

// Generate check-in PIN
if (user.checkInPin === undefined) {
const pin = randomInt(100_000, 999_999)
const pin = randomInt(1000, 9999)
await client
.db()
.collection<User>('users')
Expand Down Expand Up @@ -185,7 +184,8 @@ async function Dashboard({ user }: { user: JsonUser }) {
children = [
<p key="kid">
We&apos;ve received your application. Check back later to see if you get
accepted, and feel free to contact the organizers if you need any
accepted, and feel free to contact the organizers at{' '}
<a href="mailto:[email protected]">[email protected]</a> if you need any
assistance!
</p>,
]
Expand All @@ -209,6 +209,11 @@ async function Dashboard({ user }: { user: JsonUser }) {
>
{...children}
</Box>
<div
dangerouslySetInnerHTML={{
__html: `<!-- hey you found my ugly hack! --><script>setInterval(() => window.location.reload(), 60_000)</script>`,
}}
></div>
</Box>
)
}