Skip to content

Commit 63b1914

Browse files
committed
refactor: remove unused "hint" button
1 parent 63e5b01 commit 63b1914

File tree

3 files changed

+14
-37
lines changed

3 files changed

+14
-37
lines changed

app/(app)/challenges/[id]/_components/ide/index.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ export default function PracticeIDE({ id }: PracticeIDEProps) {
4646

4747
const handleSubmit = async (answer: string) => {
4848
const loading = toast.loading("正在送出答案");
49-
await submitAnswer({
50-
variables: {
51-
id,
52-
answer,
53-
},
54-
});
55-
toast.dismiss(loading);
49+
setDisabled(true);
50+
51+
try {
52+
await submitAnswer({
53+
variables: {
54+
id,
55+
answer,
56+
},
57+
});
58+
} finally {
59+
toast.dismiss(loading);
60+
setDisabled(false);
61+
}
5662
};
5763

5864
return (
@@ -73,16 +79,6 @@ export default function PracticeIDE({ id }: PracticeIDEProps) {
7379
id={id}
7480
disabled={disabled}
7581
onSubmit={handleSubmit}
76-
onHint={(hint) => {
77-
toast.info("hint", {
78-
description: hint,
79-
});
80-
81-
setDisabled(true);
82-
setTimeout(() => {
83-
setDisabled(false);
84-
}, 1000);
85-
}}
8682
/>
8783

8884
{/* Database Relationship */}

app/(app)/challenges/[id]/_components/ide/sql-editor.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ interface SQLEditorProps {
2222
id: string;
2323
disabled: boolean;
2424
onSubmit: (value: string) => void;
25-
onHint: (value: string) => void;
2625
}
2726

2827
export function SQLEditor({
2928
id,
3029
disabled,
3130
onSubmit,
32-
onHint,
3331
}: SQLEditorProps) {
3432
const { data } = useSuspenseQuery(SQL_EDITOR_CONTEXT, {
3533
variables: { id },
@@ -42,7 +40,6 @@ export function SQLEditor({
4240
disabled={disabled}
4341
structureFragment={database}
4442
onSubmit={onSubmit}
45-
onHint={onHint}
4643
/>
4744
);
4845
}

app/(app)/challenges/[id]/_components/sql-editor/editor.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import { Button } from "@/components/ui/button";
22
import { sql, SQLite } from "@codemirror/lang-sql";
33
import CodeMirror, { type ReactCodeMirrorRef } from "@uiw/react-codemirror";
4-
import { Code, Lightbulb, Play } from "lucide-react";
4+
import { Code, Play } from "lucide-react";
55
import { useRef } from "react";
66
import { toast } from "sonner";
77

88
export interface SQLEditorProps {
99
disabled?: boolean;
1010
onSubmit?: (value: string) => void;
11-
onHint?: (value: string) => void;
1211
schema?: Record<string, string[]>;
1312
defaultValue?: string;
1413
}
1514

1615
export default function SQLEditor({
1716
onSubmit,
18-
onHint,
1917
schema,
2018
disabled,
2119
defaultValue,
@@ -26,10 +24,6 @@ export default function SQLEditor({
2624
onSubmit?.(codeMirrorRef.current?.view?.state?.doc.toString() ?? "");
2725
};
2826

29-
const handleHint = () => {
30-
onHint?.(codeMirrorRef.current?.view?.state?.doc.toString() ?? "");
31-
};
32-
3327
const handleFormat = async () => {
3428
const { formatDialect, sqlite: formatterSqlite } = await import(
3529
"sql-formatter"
@@ -65,16 +59,6 @@ export default function SQLEditor({
6559

6660
<div className="flex justify-between">
6761
<div className="flex gap-2">
68-
<Button
69-
variant="outline"
70-
size="sm"
71-
onClick={handleHint}
72-
disabled={disabled}
73-
>
74-
<Lightbulb />
75-
提示
76-
</Button>
77-
7862
<Button
7963
variant="outline"
8064
size="sm"

0 commit comments

Comments
 (0)