generated from json-schema-org/repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save the code and add checkpoint so the users can start from where th…
…ey left off (#102) * Save the code and a checkpoint so the users can start from where they left off * fixed required changes. * fix: format code * refactor: Add Nullish coalescing operator * refactor: added global state management * refactor: changed variable names * refactor: fixed minor bug * added continue button * refactor * rename class * fix rename * minor change * format files --------- Co-authored-by: JeelRajodiya <[email protected]>
- Loading branch information
1 parent
14a864e
commit 535d3b2
Showing
11 changed files
with
178 additions
and
10 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
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,12 @@ | ||
.continueBtn { | ||
display: flex; | ||
gap: 5px; | ||
} | ||
|
||
.rightIcon { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 10px; | ||
height: 10px; | ||
} |
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,39 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
import { getCheckPoint } from "@/lib/progressSaving"; | ||
import styles from "./ContinueBtn.module.css"; | ||
import RightArrow from "@/app/styles/icons/RightArrow"; | ||
import { Button } from "@chakra-ui/react"; | ||
|
||
export default function ContinueBtn() { | ||
const router = useRouter(); | ||
const checkpoint = getCheckPoint(); | ||
|
||
const handleClick = () => { | ||
const checkpoint = getCheckPoint(); | ||
if (checkpoint) { | ||
router.push(`/${checkpoint}`); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
{checkpoint && ( | ||
<Button | ||
variant={"default"} | ||
onClick={handleClick} | ||
size={"sm"} | ||
className={styles.continueBtn} | ||
> | ||
Continue | ||
<div className={styles.rightIcon}> | ||
<RightArrow /> | ||
</div> | ||
</Button> | ||
)} | ||
</> | ||
); | ||
|
||
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as default } from "./ContinueBtn"; |
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
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,17 @@ | ||
export function setCheckpoint(path: string) { | ||
if (typeof window === "undefined") return false; | ||
const checkpoint = path; | ||
|
||
localStorage.setItem("checkPoint", JSON.stringify(checkpoint)); | ||
} | ||
|
||
export function getCheckPoint() { | ||
if (typeof window === "undefined") return false; | ||
|
||
const checkpoint = localStorage.getItem("checkPoint"); | ||
|
||
if (checkpoint) { | ||
return JSON.parse(checkpoint); | ||
} | ||
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