From 1d2f840bd7a862ee152364071cefa31e9fdc7d0e Mon Sep 17 00:00:00 2001 From: Fabian Emilius Date: Thu, 31 Oct 2024 17:11:23 +0100 Subject: [PATCH] Improve request changes form --- .../ThesisFeedbackRequestButton.tsx | 63 ++++++------------- .../ls1/constants/StringLimits.java | 3 +- .../ls1/controller/ThesisController.java | 12 ++-- .../ls1/controller/TopicController.java | 16 ++--- 4 files changed, 36 insertions(+), 58 deletions(-) diff --git a/client/src/pages/ThesisPage/components/ThesisFeedbackRequestButton/ThesisFeedbackRequestButton.tsx b/client/src/pages/ThesisPage/components/ThesisFeedbackRequestButton/ThesisFeedbackRequestButton.tsx index 88533262..83a0f89c 100644 --- a/client/src/pages/ThesisPage/components/ThesisFeedbackRequestButton/ThesisFeedbackRequestButton.tsx +++ b/client/src/pages/ThesisPage/components/ThesisFeedbackRequestButton/ThesisFeedbackRequestButton.tsx @@ -3,12 +3,16 @@ import { useLoadedThesisContext, useThesisUpdateAction, } from '../../../../providers/ThesisProvider/hooks' -import { ActionIcon, Button, Checkbox, Group, Modal, Stack, TextInput } from '@mantine/core' +import { + Button, + Checkbox, + Modal, + Stack, + Textarea, +} from '@mantine/core' import { doRequest } from '../../../../requests/request' import { IThesis } from '../../../../requests/responses/thesis' import { ApiError } from '../../../../requests/handler' -import { randomId } from '@mantine/hooks' -import { X } from 'phosphor-react' interface IThesisFeedbackRequestButtonProps { type: string @@ -20,12 +24,7 @@ const ThesisFeedbackRequestButton = (props: IThesisFeedbackRequestButtonProps) = const { thesis } = useLoadedThesisContext() const [opened, setOpened] = useState(false) - const [newChanges, setNewChanges] = useState< - Array<{ - id: string - feedback: string - }> - >([]) + const [changes, setChanges] = useState('') const [editChanges, setEditChanges] = useState< Array<{ feedbackId: string @@ -34,10 +33,12 @@ const ThesisFeedbackRequestButton = (props: IThesisFeedbackRequestButtonProps) = >([]) useEffect(() => { - setNewChanges([{ feedback: '', id: randomId() }]) + setChanges('') setEditChanges([]) }, [opened]) + const newChanges = changes.split('\n').filter((x) => x.trim()) + const [loading, onSave] = useThesisUpdateAction(async () => { for (const editChange of editChanges) { await doRequest( @@ -55,7 +56,7 @@ const ThesisFeedbackRequestButton = (props: IThesisFeedbackRequestButtonProps) = data: { type, requestedChanges: newChanges.map((newChange) => ({ - feedback: newChange.feedback, + feedback: newChange, completed: false, })), }, @@ -77,6 +78,7 @@ const ThesisFeedbackRequestButton = (props: IThesisFeedbackRequestButtonProps) = opened={opened} onClose={() => setOpened(false)} onClick={(e) => e.stopPropagation()} + size='xl' > {thesis.feedback @@ -103,41 +105,16 @@ const ThesisFeedbackRequestButton = (props: IThesisFeedbackRequestButtonProps) = }} /> ))} - {newChanges.map((change) => ( - - { - change.feedback = e.target.value - setNewChanges([...newChanges]) - }} - /> - - setNewChanges((prev) => prev.filter((item) => item.id !== change.id)) - } - > - - - - ))} - - - +