generated from json-schema-org/repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
3cec64f
commit f0fb6ca
Showing
9 changed files
with
37 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
'use client' | ||
|
||
import { useEffect } from 'react' | ||
import { useRouter } from 'next/navigation' | ||
import { getCheckPoint } from '@/lib/progressSaving' | ||
"use client"; | ||
|
||
import { useEffect } from "react"; | ||
import { useRouter } from "next/navigation"; | ||
import { getCheckPoint } from "@/lib/progressSaving"; | ||
|
||
export default function CheckpointRedirect() { | ||
const router = useRouter() | ||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
const checkpoint = getCheckPoint() | ||
const checkpoint = getCheckPoint(); | ||
if (checkpoint) { | ||
router.push(`content/${checkpoint}`) | ||
router.push(`content/${checkpoint}`); | ||
} | ||
}, [router]) | ||
}, [router]); | ||
|
||
return null | ||
} | ||
return null; | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export { default as default } from "./CheckPointRedirect"; | ||
export { default as default } from "./CheckPointRedirect"; |
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
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 |
---|---|---|
|
@@ -74,4 +74,4 @@ html { | |
|
||
main { | ||
height: 100%; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -78,4 +78,4 @@ | |
|
||
.footerText { | ||
font-weight: 700; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,43 +1,43 @@ | ||
export function setCheckpoint(path: string) { | ||
if (typeof window === "undefined") return false; | ||
const checkpoint = path | ||
const checkpoint = path; | ||
|
||
localStorage.setItem("checkPoint", JSON.stringify(checkpoint)); | ||
} | ||
|
||
export function getCheckPoint(){ | ||
export function getCheckPoint() { | ||
if (typeof window === "undefined") return false; | ||
|
||
const checkpoint = localStorage.getItem('checkPoint') | ||
if(checkpoint){ | ||
return JSON.parse(checkpoint) | ||
const checkpoint = localStorage.getItem("checkPoint"); | ||
|
||
if (checkpoint) { | ||
return JSON.parse(checkpoint); | ||
} | ||
return null | ||
return null; | ||
} | ||
|
||
export function persistCode(chapter:number, lesson: number, code:string){ | ||
const codeData = JSON.parse(localStorage.getItem('codeData') || '{}'); | ||
export function persistCode(chapter: number, lesson: number, code: string) { | ||
const codeData = JSON.parse(localStorage.getItem("codeData") || "{}"); | ||
|
||
const key = `${chapter}.${lesson}` | ||
const key = `${chapter}.${lesson}`; | ||
|
||
codeData[key] = code; | ||
|
||
localStorage.setItem('codeData',JSON.stringify(codeData)) | ||
localStorage.setItem("codeData", JSON.stringify(codeData)); | ||
} | ||
|
||
export function getCode(chapter: number,lesson:number){ | ||
const codeData = JSON.parse(localStorage.getItem('codeData') || '{}'); | ||
export function getCode(chapter: number, lesson: number) { | ||
const codeData = JSON.parse(localStorage.getItem("codeData") || "{}"); | ||
|
||
const key = `${chapter}.${lesson}`; | ||
|
||
return codeData[key] | ||
return codeData[key]; | ||
} | ||
|
||
export function resetCode(chapter: number, lesson: number){ | ||
const codeData = JSON.parse(localStorage.getItem('codeData') || '{}'); | ||
export function resetCode(chapter: number, lesson: number) { | ||
const codeData = JSON.parse(localStorage.getItem("codeData") || "{}"); | ||
|
||
const key = `${chapter}.${lesson}`; | ||
|
||
codeData[key] = null; | ||
} | ||
} |