2023-09-03 12:02:34 +01:00
|
|
|
import { CheckCircle, RotateCcw, SkipForward, Sparkles } from 'lucide-react';
|
2023-09-02 23:09:02 +01:00
|
|
|
import { showLoginPopup } from '../../lib/popup';
|
|
|
|
|
|
|
|
|
|
type QuestionsProgressProps = {
|
2023-09-03 03:20:59 +01:00
|
|
|
isLoading?: boolean;
|
2023-09-02 23:09:02 +01:00
|
|
|
showLoginAlert?: boolean;
|
2023-09-03 12:02:34 +01:00
|
|
|
knowCount?: number;
|
|
|
|
|
didNotKnowCount?: number;
|
|
|
|
|
totalCount?: number;
|
|
|
|
|
skippedCount?: number;
|
2023-09-02 23:09:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function QuestionsProgress(props: QuestionsProgressProps) {
|
2023-09-03 12:02:34 +01:00
|
|
|
const {
|
|
|
|
|
showLoginAlert,
|
|
|
|
|
isLoading = false,
|
|
|
|
|
knowCount = 0,
|
|
|
|
|
didNotKnowCount = 0,
|
|
|
|
|
totalCount = 0,
|
|
|
|
|
skippedCount = 0,
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
const totalSolved = knowCount + didNotKnowCount + skippedCount;
|
|
|
|
|
const donePercentage = (totalSolved / totalCount) * 100;
|
2023-09-01 20:07:17 +01:00
|
|
|
|
|
|
|
|
return (
|
2023-09-02 23:09:02 +01:00
|
|
|
<div className="mb-5 overflow-hidden rounded-lg border border-gray-300 bg-white p-6">
|
2023-09-01 20:07:17 +01:00
|
|
|
<div className="mb-3 flex items-center text-gray-600">
|
|
|
|
|
<div className="relative w-full flex-1 rounded-xl bg-gray-200 p-1">
|
2023-09-03 12:02:34 +01:00
|
|
|
<div
|
|
|
|
|
className="absolute bottom-0 left-0 top-0 rounded-xl bg-slate-800"
|
|
|
|
|
style={{
|
|
|
|
|
width: `${donePercentage}%`,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-09-01 20:07:17 +01:00
|
|
|
</div>
|
2023-09-03 12:02:34 +01:00
|
|
|
<span className="ml-3 text-sm">
|
|
|
|
|
{totalSolved} / {totalCount}
|
|
|
|
|
</span>
|
2023-09-01 20:07:17 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="relative -left-1 flex flex-col gap-2 text-sm text-black sm:flex-row sm:gap-3">
|
|
|
|
|
<span className="flex items-center">
|
|
|
|
|
<CheckCircle className="mr-1 h-4" />
|
2023-09-03 12:02:34 +01:00
|
|
|
<span>Knew</span>
|
2023-09-01 20:07:17 +01:00
|
|
|
<span className="ml-2 rounded-md bg-gray-200/80 px-1.5 font-medium text-black">
|
2023-09-03 12:02:34 +01:00
|
|
|
{knowCount} Questions
|
2023-09-01 20:07:17 +01:00
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span className="flex items-center">
|
|
|
|
|
<Sparkles className="mr-1 h-4" />
|
2023-09-03 12:02:34 +01:00
|
|
|
<span>Learnt</span>
|
2023-09-01 20:07:17 +01:00
|
|
|
<span className="ml-2 rounded-md bg-gray-200/80 px-1.5 font-medium text-black">
|
2023-09-03 12:02:34 +01:00
|
|
|
{didNotKnowCount} Questions
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span className="flex items-center">
|
|
|
|
|
<SkipForward className="mr-1 h-4" />
|
|
|
|
|
<span>Skipped</span>
|
|
|
|
|
<span className="ml-2 rounded-md bg-gray-200/80 px-1.5 font-medium text-black">
|
|
|
|
|
{skippedCount} Questions
|
2023-09-01 20:07:17 +01:00
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<button className="flex items-center text-red-600 hover:text-red-900">
|
|
|
|
|
<RotateCcw className="mr-1 h-4" />
|
2023-09-03 12:02:34 +01:00
|
|
|
Reset
|
2023-09-01 20:07:17 +01:00
|
|
|
</button>
|
|
|
|
|
</div>
|
2023-09-02 17:49:07 +01:00
|
|
|
|
2023-09-02 23:09:02 +01:00
|
|
|
{showLoginAlert && (
|
|
|
|
|
<p className="-mx-6 mt-6 -mb-6 border-t bg-yellow-100 py-3 text-sm text-yellow-900">
|
|
|
|
|
You progress is not saved. Please{' '}
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
showLoginPopup();
|
|
|
|
|
}}
|
|
|
|
|
className="underline-offset-3 font-medium underline hover:text-black"
|
|
|
|
|
>
|
|
|
|
|
login to save your progress.
|
|
|
|
|
</button>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
2023-09-01 20:07:17 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|