From bf0ab14f6746af05bad879383e2177c6ded9d49b Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Sat, 27 May 2023 17:04:12 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20style(promptComponent,=20textAre?= =?UTF-8?q?aComponent):=20fix=20indentation=20and=20whitespace=20The=20cha?= =?UTF-8?q?nges=20in=20these=20files=20are=20purely=20cosmetic,=20fixing?= =?UTF-8?q?=20indentation=20and=20whitespace=20to=20improve=20code=20reada?= =?UTF-8?q?bility.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔨 refactor(genericModal/index.tsx): improve code readability and add destructuring to props The code has been refactored to improve readability and make it easier to understand. Destructuring has been added to the props to make it easier to access the values. --- .../src/components/promptComponent/index.tsx | 4 +- .../components/textAreaComponent/index.tsx | 4 +- .../src/modals/genericModal/index.tsx | 297 +++++++++--------- 3 files changed, 152 insertions(+), 153 deletions(-) diff --git a/src/frontend/src/components/promptComponent/index.tsx b/src/frontend/src/components/promptComponent/index.tsx index 96c91baac..10ac41281 100644 --- a/src/frontend/src/components/promptComponent/index.tsx +++ b/src/frontend/src/components/promptComponent/index.tsx @@ -32,7 +32,7 @@ export default function PromptAreaComponent({ { setMyValue(t); onChange(t); @@ -53,7 +53,7 @@ export default function PromptAreaComponent({ { setMyValue(t); onChange(t); diff --git a/src/frontend/src/components/textAreaComponent/index.tsx b/src/frontend/src/components/textAreaComponent/index.tsx index edc21f044..b4ec85fe3 100644 --- a/src/frontend/src/components/textAreaComponent/index.tsx +++ b/src/frontend/src/components/textAreaComponent/index.tsx @@ -24,7 +24,7 @@ export default function TextAreaComponent({ onClick={() => { openPopUp( { @@ -45,7 +45,7 @@ export default function TextAreaComponent({ onClick={() => { openPopUp( { diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index 7f2033164..b804803ea 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -6,156 +6,155 @@ import { darkContext } from "../../contexts/darkContext"; import { checkPrompt } from "../../controllers/API"; import { alertContext } from "../../contexts/alertContext"; export default function PromptAreaModal({ - value, - setValue, - buttonText, - modalTitle + value, + setValue, + buttonText, + modalTitle, }: { - setValue: (value: string) => void; - value: string; - buttonText: string; - modalTitle: string; + setValue: (value: string) => void; + value: string; + buttonText: string; + modalTitle: string; }) { + const [myButtonText, setmyButtonText] = useState(buttonText); + const [myModalTitle, setMyModalTitle] = useState(modalTitle); + const [open, setOpen] = useState(true); + const [myValue, setMyValue] = useState(value); + const { dark } = useContext(darkContext); + const { setErrorData, setSuccessData } = useContext(alertContext); + const { closePopUp } = useContext(PopUpContext); + const ref = useRef(); + function setModalOpen(x: boolean) { + setOpen(x); + if (x === false) { + setTimeout(() => { + closePopUp(); + }, 300); + } + } - const [myButtonText, setmyButtonText] = useState(buttonText); - const [myModalTitle, setMyModalTitle] = useState(modalTitle); - const [open, setOpen] = useState(true); - const [myValue, setMyValue] = useState(value); - const { dark } = useContext(darkContext); - const { setErrorData, setSuccessData } = useContext(alertContext); - const { closePopUp } = useContext(PopUpContext); - const ref = useRef(); - function setModalOpen(x: boolean) { - setOpen(x); - if (x === false) { - setTimeout(() => { - closePopUp(); - }, 300); - } - } + return ( + + + +
+ - return ( - - - -
- - -
-
- - -
- -
-
-
-
-
-
- - {myModalTitle} - -
-
-
-
-
-