Skip to content

Commit 020f09a

Browse files
committed
Tutorial Completed Modal
1 parent fead4b4 commit 020f09a

1 file changed

Lines changed: 41 additions & 7 deletions

File tree

src/pages/Settings.tsx

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import {
33
UNSAFE_NavigationContext,
44
useLocation,
55
useSearchParams,
6+
useNavigate,
67
} from 'react-router-dom';
78
import {
89
Save,
910
AlertTriangle,
1011
Settings as SettingsIcon,
1112
Check,
13+
RotateCcw,
1214
} from 'lucide-react';
1315
import type {
1416
Settings,
@@ -30,6 +32,7 @@ import Button from '../components/common/Button';
3032
import Loader from '../components/common/Loader';
3133
import CustomTooltip from '../components/tutorial/CustomToolTip';
3234
import Modal from '../components/common/Modal';
35+
import { useAuth } from '../hooks/auth/useAuth';
3336

3437
function useCustomBlocker(shouldBlock: boolean, onBlock: () => void) {
3538
const navigator = useContext(UNSAFE_NavigationContext)?.navigator;
@@ -61,6 +64,7 @@ function useCustomBlocker(shouldBlock: boolean, onBlock: () => void) {
6164

6265
export default function Settings() {
6366
const { settings, updateSettings, loading } = useSettings();
67+
const { refreshUser } = useAuth();
6468
const [localSettings, setLocalSettings] = useState<Settings | null>(null);
6569
const [saving, setSaving] = useState(false);
6670
const [hasChanges, setHasChanges] = useState(false);
@@ -71,6 +75,7 @@ export default function Settings() {
7175

7276
const [searchParams] = useSearchParams();
7377
const startTutorial = searchParams.get('tutorial') === 'true';
78+
const navigate = useNavigate();
7479

7580
useEffect(() => {
7681
if (settings) {
@@ -211,6 +216,20 @@ export default function Settings() {
211216
}
212217
};
213218

219+
const handleRestartTutorial = async () => {
220+
try {
221+
const success = await updateTutorialStatus(false);
222+
if (success) {
223+
await refreshUser();
224+
navigate('/?tutorial=true');
225+
} else {
226+
console.error('Failed to reset tutorial.');
227+
}
228+
} catch (error) {
229+
console.error('Error resetting tutorial:', error);
230+
}
231+
};
232+
214233
if (loading)
215234
return (
216235
<div className="min-h-screen bg-zinc-950 text-white flex items-center justify-center">
@@ -415,13 +434,28 @@ export default function Settings() {
415434
title="Tutorial Completed!"
416435
variant="success"
417436
footer={
418-
<Button
419-
size="sm"
420-
variant="success"
421-
onClick={() => setShowTutorialCompleteModal(false)}
422-
>
423-
Got it!
424-
</Button>
437+
<div className="flex gap-2">
438+
{' '}
439+
<Button
440+
onClick={() => {
441+
setShowTutorialCompleteModal(false);
442+
handleRestartTutorial();
443+
}}
444+
variant="outline"
445+
size="sm"
446+
className="border-yellow-700/50 text-yellow-400 hover:bg-yellow-900/20 hover:border-yellow-600"
447+
>
448+
<RotateCcw className="w-4 h-4 mr-2" />
449+
Restart Tutorial
450+
</Button>
451+
<Button
452+
onClick={() => setShowTutorialCompleteModal(false)}
453+
variant="success"
454+
size="sm"
455+
>
456+
Got it!
457+
</Button>
458+
</div>
425459
}
426460
>
427461
<div className="flex items-center gap-4 mb-4">

0 commit comments

Comments
 (0)