-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
116 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { useState } from 'react'; | ||
import FeedbackForm from './FeedbackForm'; | ||
|
||
interface ExitModalProps { | ||
onClose: () => void; | ||
} | ||
|
||
const ExitModal: React.FC<ExitModalProps> = ({ onClose }) => { | ||
const [showFeedbackForm, setShowFeedbackForm] = useState(false); | ||
|
||
const handleYesClick = () => { | ||
setShowFeedbackForm(true); | ||
}; | ||
|
||
const handleNoClick = () => { | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<div className="fixed inset-0 bg-gray-800 bg-opacity-75 flex justify-center items-center"> | ||
{!showFeedbackForm ? ( | ||
<div className="bg-white p-6 rounded-lg"> | ||
<h2 className="text-lg mb-4">Are you sure you want to exit?</h2> | ||
<div className="flex justify-between"> | ||
<button | ||
className="bg-green-500 text-white px-4 py-2 rounded-md" | ||
onClick={handleYesClick} | ||
> | ||
Yes | ||
</button> | ||
<button | ||
className="bg-gray-500 text-white px-4 py-2 rounded-md" | ||
onClick={handleNoClick} | ||
> | ||
No | ||
</button> | ||
</div> | ||
</div> | ||
) : ( | ||
<FeedbackForm onClose={onClose} /> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ExitModal; |
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,38 @@ | ||
import React, { useState } from 'react'; | ||
|
||
interface FeedbackFormProps { | ||
onClose: () => void; | ||
} | ||
|
||
const FeedbackForm: React.FC<FeedbackFormProps> = ({ onClose }) => { | ||
const [rating, setRating] = useState<number | null>(null); | ||
|
||
const handleRating = (rate: number) => { | ||
setRating(rate); | ||
}; | ||
|
||
return ( | ||
<div className="bg-white p-6 rounded-lg"> | ||
<h2 className="text-lg mb-4">Please rate your experience</h2> | ||
<div className="flex mb-4"> | ||
{[1, 2, 3, 4, 5].map((star) => ( | ||
<button | ||
key={star} | ||
className={`text-2xl ${star <= (rating || 0) ? 'text-yellow-500' : 'text-gray-400'}`} | ||
onClick={() => handleRating(star)} | ||
> | ||
★ | ||
</button> | ||
))} | ||
</div> | ||
<button | ||
className="bg-blue-500 text-white px-4 py-2 rounded-md" | ||
onClick={onClose} | ||
> | ||
Submit | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FeedbackForm; |
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 React, { useState } from 'react'; | ||
import ExitModal from './ExitModal'; | ||
|
||
const QuizComponent: React.FC = () => { | ||
const [showExitModal, setShowExitModal] = useState(false); | ||
|
||
const handleExitClick = () => { | ||
setShowExitModal(true); | ||
}; | ||
|
||
return ( | ||
<div className="p-4"> | ||
<h1 className="text-2xl mb-4">Quiz Section</h1> | ||
{/* Quiz content here */} | ||
<button | ||
className="bg-red-500 text-white px-4 py-2 rounded-md" | ||
onClick={handleExitClick} | ||
> | ||
Exit | ||
</button> | ||
{showExitModal && <ExitModal onClose={() => setShowExitModal(false)} />} | ||
</div> | ||
); | ||
}; | ||
|
||
export default QuizComponent; |