From 6dc351cc65e2076c71ebdf5153d0ed25635270e6 Mon Sep 17 00:00:00 2001 From: Faisal Sayed Date: Wed, 8 May 2024 11:22:57 -0400 Subject: [PATCH] fix: remove old code --- src/components/popups-etc/stuck-popup.tsx | 132 ---------------------- 1 file changed, 132 deletions(-) delete mode 100644 src/components/popups-etc/stuck-popup.tsx diff --git a/src/components/popups-etc/stuck-popup.tsx b/src/components/popups-etc/stuck-popup.tsx deleted file mode 100644 index 30e773cf6..000000000 --- a/src/components/popups-etc/stuck-popup.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import { Signal, useSignal } from "@preact/signals"; -import { - PersistenceState, - codeMirror, - editSessionLength, - errorLog, -} from "../../lib/state"; -import Button from "../design-system/button"; -import Textarea from "../design-system/textarea"; -import styles from "../navbar.module.css"; - -interface StuckPopupProps { - persistenceState: Signal; - showStuckPopup: Signal; -} - -type StuckCategory = "Logic Error" | "Syntax Error" | "Other"; - -type StuckData = { - category: StuckCategory; - description: string; -}; - -export default function StuckPopup(props: StuckPopupProps) { - // we will accept the current user's - // - name, - // - the category of issue they - // - their description of the issue - const stuckData = useSignal({ - category: "Other", - description: "", - }); - // keep track of the submit status for "I'm stuck" requests - const isSubmitting = useSignal(false); - - return ( - <> -
-
{ - event.preventDefault(); // prevent the browser from reloading after form submit - - isSubmitting.value = true; - - // 'from' and 'to' represent the index of character where the selection is started to where it's ended - // if 'from' and 'to' are equal, then it's the cursor position - // from && to being -1 means the cursor is not in the editor - const selectionRange = codeMirror.value?.state.selection - .ranges[0] ?? { from: -1, to: -1 }; - - // Store a copy of the user's code, currently active errors and the length of their editing session - // along with their description of the issue - const payload = { - selection: JSON.stringify({ - from: selectionRange.from, - to: selectionRange.to, - }), - email: props.persistenceState.value.session?.user - .email, - code: codeMirror.value?.state.doc.toString(), - error: errorLog.value, - sessionLength: - (new Date().getTime() - - editSessionLength.value.getTime()) / - 1000, // calculate the session length in seconds - ...stuckData.value, - }; - - try { - const response = await fetch("/api/stuck-request", { - method: "POST", - body: JSON.stringify(payload), - }); - // Let the user know we'll get back to them after we've receive their complaint - if (response.ok) { - alert( - "We received your request and will get back to you via email." - ); - } else - alert( - "We couldn't send your request. Please make sure you're connected and try again." - ); - } catch (err) { - console.error(err); - } finally { - isSubmitting.value = false; - } - }} - > - - - -