Skip to content

Commit

Permalink
Fix ie-or-css3 (temporarily)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxLeiter committed May 7, 2023
1 parent e390ef7 commit ef1168d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
22 changes: 16 additions & 6 deletions app/(subpages)/ie-or-css3/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import supabase from '@lib/supabase/private'
import Link from '@components/link'
import IeOrCss, { UselessButton } from '@components/ie-or-css'
import { UselessButton } from '@components/ie-or-css'
import { Metadata } from 'next'

export const metadata = {
export const metadata: Metadata = {
title: 'IE or CSS3?',
description: 'Test your knowledge on CSS3 and Internet Explorer.',
alternates: {
Expand All @@ -11,7 +12,9 @@ export const metadata = {
}

const fetchQuestions = async () => {
const { data, error } = await supabase.from('Questions').select('id,question')
const { data, error } = await supabase
.from('Questions')
.select('id,question,isCSS')

if (error || !data) {
console.error(error)
Expand All @@ -23,10 +26,14 @@ const fetchQuestions = async () => {
}

const IeQuiz = async () => {
const questions = await fetchQuestions()
const questions = (await fetchQuestions()) as {
id: string
question: string
isCSS: boolean
}[]

return (
<>
{' '}
<p>
Welcome! This quiz is inspired by the{' '}
<Link href="https://youtu.be/Ck-e3hd3pKw?t=22032" external>
Expand All @@ -49,7 +56,10 @@ const IeQuiz = async () => {
If you think the feature is Internet Explorer specific or was used to
target IE, click <UselessButton text={'IE'} />
</p>
<IeOrCss questions={questions} />
<h3>
This page is currently on pause until I migrate to the latest supabase
Supabase.
</h3>
</>
)
}
Expand Down
8 changes: 4 additions & 4 deletions app/components/ie-or-css/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const IeOrCss = ({ questions }: IEQuizProps) => {
QuestionWithVotes[]
>([])

console.log('questions', questions)

// update questionsWithVotes on changes
useEffect(() => {
supabase
.from('Votes')
.on('*', (payload) => {
supabase.channel('votes').on('*', (payload) => {
const newObj = payload.new
setQuestionsWithVotes((questionsWithVotes) => {
const newQuestions = questionsWithVotes.map((q) => {
Expand All @@ -58,7 +58,7 @@ const IeOrCss = ({ questions }: IEQuizProps) => {
.subscribe()

return () => {
supabase.removeAllSubscriptions()
supabase.removeAllChannels()
}
}, [])

Expand Down

0 comments on commit ef1168d

Please sign in to comment.