// Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. import * as vscode from "vscode"; import { leetCodeExecutor } from "../leetCodeExecutor"; import { leetCodeManager } from "../leetCodeManager"; import { DialogType, promptForOpenOutputChannel, promptForSignIn } from "../utils/uiUtils"; import { getActiveFilePath } from "../utils/workspaceUtils"; import { leetCodeSubmissionProvider } from "../webview/leetCodeSubmissionProvider"; export async function submitSolution(uri?: vscode.Uri): Promise { if (!leetCodeManager.getUser()) { promptForSignIn(); return; } const filePath: string | undefined = await getActiveFilePath(uri); if (!filePath) { return; } try { const result: string = await leetCodeExecutor.submitSolution(filePath); leetCodeSubmissionProvider.show(result); } catch (error) { await promptForOpenOutputChannel("Failed to submit the solution. Please open the output channel for details.", DialogType.error); } }