Skip to content

Commit

Permalink
hackathon-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
COdevra committed Jul 28, 2024
1 parent 4af1e31 commit 840d46b
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nepalingo-web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import ReactGA from "react-ga4";
import { PrivateRoutes } from "@/components/PrivateRoutes";
import { LanguageProvider } from "./contexts/LanguageContext";
import QuizComponent from './components/QuizComponent';
import RandomQuoteComponent from "./components/randomQuotes";

const App: React.FC = () => {
Expand All @@ -26,7 +27,11 @@ const App: React.FC = () => {
<Route path="/dictionary" element={<DictionaryPage />} />
</Route>
</Routes>
</Router></>
</Router>
<div className="min-h-screen flex justify-center items-center">
<QuizComponent />
</div>
</>
);
};

Expand Down
46 changes: 46 additions & 0 deletions nepalingo-web/src/components/ExitModal.tsx
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;
38 changes: 38 additions & 0 deletions nepalingo-web/src/components/FeedbackForm.tsx
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;
26 changes: 26 additions & 0 deletions nepalingo-web/src/components/QuizComponent.tsx
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;

0 comments on commit 840d46b

Please sign in to comment.