Skip to content

Commit d315e68

Browse files
Certificate btn on last (#146)
* add loader to the validate button * add the types again and create handleValidateFunction * add the get certificate button * resolve the mergre conficts * refactor the code * add aditional check to validate that current lesson is last lesson * refactor the code * remove the fragmments * resolved the edge case * remove margin from certificate button and simplify tour completion state logic --------- Co-authored-by: JeelRajodiya <[email protected]>
1 parent 55e7afb commit d315e68

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

app/components/CertificateButton/CertificateButton.module.css

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.certificateButton {
22
font-size: small;
3-
margin-right: 32px;
43
display: flex;
54
align-items: center;
65
justify-content: center;

app/components/CodeEditor/CodeEditor.tsx

+25-20
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ import Editor, { Monaco } from "@monaco-editor/react";
77
import { Flex, useColorMode } from "@chakra-ui/react";
88
import { useEffect, useState, useRef } from "react";
99
import MyBtn from "../MyBtn";
10-
import { tryFormattingCode, validateCode } from "@/lib/client-functions";
10+
import {
11+
isTheTourCompleted,
12+
tryFormattingCode,
13+
validateCode,
14+
} from "@/lib/client-functions";
1115
import FiChevronRight from "@/app/styles/icons/HiChevronRightGreen";
1216
import { useRouter } from "next/navigation";
1317
import { useUserSolutionStore, useEditorStore } from "@/lib/stores";
1418
import { sendGAEvent } from "@next/third-parties/google";
1519
import { CodeFile, OutputResult } from "@/lib/types";
1620
import { OutputReducerAction } from "@/lib/reducers";
21+
import CertificateButton from "../CertificateButton/CertificateButton";
1722

1823
// Custom hook for editor theme setup
1924
const useEditorTheme = (monaco: Monaco, colorMode: "dark" | "light") => {
@@ -108,7 +113,6 @@ const EditorControls = ({
108113
outputResult: OutputResult;
109114
}) => {
110115
const router = useRouter();
111-
112116
return (
113117
<div className={styles.buttonsWrapper}>
114118
<Flex dir="row" gap="8px" alignItems="end">
@@ -127,25 +131,26 @@ const EditorControls = ({
127131
Reset
128132
</MyBtn>
129133
</Flex>
130-
<MyBtn
131-
onClick={() => {
132-
if (nextStepPath) router.push("/" + nextStepPath);
133-
}}
134-
variant={
135-
outputResult.validityStatus === "valid" ? "default" : "success"
136-
}
137-
isDisabled={!nextStepPath}
138-
size={outputResult.validityStatus === "valid" ? "sm" : "xs"}
139-
>
140-
Next <span style={{ marginLeft: "4px" }}></span>
141-
<FiChevronRight
142-
color={
143-
outputResult.validityStatus === "valid"
144-
? "white"
145-
: "hsl(var(--success))"
134+
{!nextStepPath ? (
135+
<CertificateButton />
136+
) : (
137+
<MyBtn
138+
onClick={() => router.push("/" + nextStepPath)}
139+
variant={
140+
outputResult.validityStatus === "valid" ? "default" : "success"
146141
}
147-
/>
148-
</MyBtn>
142+
size={outputResult.validityStatus === "valid" ? "sm" : "xs"}
143+
>
144+
Next <span style={{ marginLeft: "4px" }}></span>
145+
<FiChevronRight
146+
color={
147+
outputResult.validityStatus === "valid"
148+
? "white"
149+
: "hsl(var(--success))"
150+
}
151+
/>
152+
</MyBtn>
153+
)}
149154
</div>
150155
);
151156
};

app/components/OutlineDrawer/OutlineDrawer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function OutlineDrawer({
4242
<DrawerOverlay />
4343
<DrawerContent>
4444
<DrawerCloseButton />
45-
<DrawerHeader display={"flex"} justifyContent={"space-between"}>
45+
<DrawerHeader display={"flex"} justifyContent={"space-between"} paddingRight={12}>
4646
Outline
4747
<CertificateButton />
4848
</DrawerHeader>

0 commit comments

Comments
 (0)