From 7ad79c8e17b21a6a3789a594db26d34810090e4a Mon Sep 17 00:00:00 2001 From: "duc.vu" Date: Tue, 17 Sep 2024 09:29:37 +0300 Subject: [PATCH] add gec view --- client/components/GecView/index.js | 82 ++++++++++++++++++++++++++++++ client/components/Router.js | 9 +--- client/util/redux/gecReducer.js | 57 +++++++++++++++++++++ client/util/redux/index.js | 3 ++ 4 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 client/components/GecView/index.js create mode 100644 client/util/redux/gecReducer.js diff --git a/client/components/GecView/index.js b/client/components/GecView/index.js new file mode 100644 index 00000000..dc5ef2fe --- /dev/null +++ b/client/components/GecView/index.js @@ -0,0 +1,82 @@ +import React from 'react' +import { FormattedMessage } from 'react-intl' +import { useDispatch, useSelector } from 'react-redux' +import { checkGrammar, updateEssay } from 'Utilities/redux/gecReducer' + +const Word = ({ word, isError }) => { + return ( + + {word + ' '} + + ) +} + +const GrammarCheck = () => { + const dispatch = useDispatch() + const { essay, edits, pending } = useSelector(state => state.gec) + + const handleEssayChange = (event) => { + const newValue = event.target.value + dispatch(updateEssay(newValue)) + } + + const handleGrammarCheck = () => { + if (essay.trim() !== "") { + dispatch(checkGrammar(essay)) + } + } + + const renderTextWithHighlights = (text, edits) => { + const words = text.split(' ') + return words.map((word, index) => { + const isError = edits && edits.some(edit => edit.word === word) + return + }) + } + + return ( +
+