-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from simonyiszk/feature/questions
questions from the web
- Loading branch information
Showing
11 changed files
with
257 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { RoomQuestion } from '@/components/tiles/question-tile'; | ||
import { getPresentationData } from '@/models/get-presentation-data'; | ||
|
||
export default async function questionsPage() { | ||
const presentations = await getPresentationData(); | ||
return ( | ||
<div className='flex flex-col px-4 sm:px-6 xl:px-0 max-w-6xl w-full overflow-hidden'> | ||
<h1 className='mb-16 mt-8'>Kérdezz az elődóktól!</h1> | ||
|
||
<div className='grid grid-cols-1 sm:grid-cols-2 gap-6'> | ||
<div className='order-1'> | ||
<h2 className='text-4xl text-center'>IB028</h2> | ||
</div> | ||
<div className='order-3 sm:order-2'> | ||
<h2 className='text-4xl text-center'>IB025</h2> | ||
</div> | ||
<div className='order-2 sm:order-3'> | ||
<RoomQuestion presentations={presentations ?? []} room='IB028' /> | ||
</div> | ||
<div className='order-4'> | ||
<RoomQuestion presentations={presentations ?? []} room='IB025' /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Dialog } from '@headlessui/react'; | ||
import { useState } from 'react'; | ||
import { useGoogleReCaptcha } from 'react-google-recaptcha-v3'; | ||
import { FaCheckCircle } from 'react-icons/fa'; | ||
|
||
import { sendQuestion } from '@/app/actions'; | ||
import { WhiteButton } from '@/components/white-button'; | ||
|
||
interface PresentationQuestionFormProps { | ||
slug: string; | ||
} | ||
|
||
export function PresentationQuestionForm({ slug }: PresentationQuestionFormProps) { | ||
const { executeRecaptcha } = useGoogleReCaptcha(); | ||
const [isSuccessOpen, setIsSuccessOpen] = useState(false); | ||
|
||
const [error, setError] = useState(''); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [question, setQuestion] = useState(''); | ||
|
||
const onSend = async () => { | ||
if (!executeRecaptcha) return; | ||
const recaptchaToken = await executeRecaptcha('presentation_question'); | ||
if (question.trim()) { | ||
setIsLoading(true); | ||
const status = await sendQuestion({ question, slug, recaptchaToken }); | ||
setIsLoading(false); | ||
switch (status) { | ||
case 201: | ||
setIsSuccessOpen(true); | ||
setQuestion(''); | ||
break; | ||
case 400: | ||
setError('Hibás formátum!'); | ||
break; | ||
default: | ||
setError('Ismeretlen hiba!'); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<div className='mt-10 w-full'> | ||
<textarea | ||
className='w-full rounded-md p-2 bg-transparent border-white border-[0.5px]' | ||
value={question} | ||
onChange={(e) => setQuestion(e.target.value)} | ||
rows={4} | ||
placeholder='Ide írd a kérdésed!' | ||
/> | ||
{error && <p className='text-red-500 my-2'>{error}</p>} | ||
<div className='w-full my-4 flex justify-center'> | ||
<WhiteButton onClick={onSend} disabled={!question.trim() || isLoading || !executeRecaptcha}> | ||
Kérdés küldése | ||
</WhiteButton> | ||
</div> | ||
<Dialog open={isSuccessOpen} onClose={() => setIsSuccessOpen(false)} className='relative z-50'> | ||
<div className='fixed inset-0 bg-black/80' aria-hidden='true' /> | ||
|
||
<div className='fixed inset-0 flex w-screen items-center justify-center p-4'> | ||
<Dialog.Panel className='mx-auto max-w-lg rounded bg-[#0f181c] p-8 flex flex-col items-center gap-5'> | ||
<div className='text-8xl text-white'> | ||
<FaCheckCircle /> | ||
</div> | ||
<Dialog.Title className='font-bold text-2xl mb-5 text-center'> | ||
A kérdésed megkaptuk és moderálás után a felolvasandó kérdések közé kerül. Köszönjük! | ||
</Dialog.Title> | ||
|
||
<WhiteButton onClick={() => setIsSuccessOpen(false)}>Rendben</WhiteButton> | ||
</Dialog.Panel> | ||
</div> | ||
</Dialog> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use client'; | ||
import { PresentationWithDates } from '@/models/models'; | ||
import { getCurrentDate } from '@/utils/dateHelper'; | ||
|
||
import { PresentationTile } from '../presentation/PresentationGrid'; | ||
|
||
type Props = { | ||
presentations: PresentationWithDates[]; | ||
room: 'IB028' | 'IB025'; | ||
}; | ||
|
||
export function RoomQuestion({ presentations, room }: Props) { | ||
const now = getCurrentDate(); | ||
const presentation = presentations.find((p) => p.room === room && p.startDate < now && p.endDate > now); | ||
return presentation ? ( | ||
<PresentationTile presentation={presentation} preview /> | ||
) : ( | ||
<p className='text-stone-200 text-base sm:text-[20px] text-center'> | ||
Jelenleg nincs előadás ebben a teremben, nézz vissza később! | ||
</p> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.