From 9d567f4667b3122f074b8385ee3d8151076684c7 Mon Sep 17 00:00:00 2001 From: mikkojamG Date: Tue, 4 Feb 2025 10:43:49 +0200 Subject: [PATCH 01/14] fix: sortableCommentList vote checkbox KER-422 --- src/components/SortableCommentList.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SortableCommentList.jsx b/src/components/SortableCommentList.jsx index 3e8ca07a5..398b183ce 100644 --- a/src/components/SortableCommentList.jsx +++ b/src/components/SortableCommentList.jsx @@ -245,7 +245,7 @@ const SortableCommentListComponent = ({ ], }); } else if (questionType === 'multiple-choice' && oldAnswer) { - listState({ + setListState({ answers: [ ...listState.answers.filter((answer) => answer.question !== questionId), { From 3df3e368e63e0a342e0990665cd011cedd49a853 Mon Sep 17 00:00:00 2001 From: mikkojamG Date: Tue, 4 Feb 2025 12:24:00 +0200 Subject: [PATCH 02/14] fix: organization included in comments KER-422 --- src/actions/index.js | 13 +- src/components/BaseCommentForm.jsx | 125 +++++++++--------- src/components/Hearing/Comment/index.jsx | 7 +- .../Hearing/Section/SectionContainer.jsx | 17 ++- .../__tests__/SectionContainer.test.jsx | 36 ++--- src/components/SortableCommentList.jsx | 21 +-- src/components/__tests__/BaseCommentForm.jsx | 12 +- src/components/plugins/MapQuestionnaire.jsx | 35 +++-- src/components/plugins/legacy/mapdon-hkr.jsx | 1 - src/components/plugins/legacy/mapdon-ksv.jsx | 1 - src/utils/section.js | 2 +- .../FullscreenHearingContainer.jsx | 16 ++- .../__tests__/HearingContainer.test.jsx | 4 +- test-utils.js | 2 +- 14 files changed, 163 insertions(+), 129 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index dfdc358ae..ef2f5bbe4 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -47,8 +47,8 @@ export function getResponseJSON(response) { } export const requestErrorHandler = ( - dispatch, - localizationKey = undefined + dispatch, + localizationKey = undefined ) => (err) => { Sentry.captureException(err); let payload; @@ -307,10 +307,14 @@ export function fetchAllSectionComments(hearingSlug, sectionId, ordering = '-n_v } export function postSectionComment(hearingSlug, sectionId, commentData = {}) { + // eslint-disable-next-line sonarjs/cognitive-complexity return (dispatch) => { const fetchAction = createAction("postingComment")({ hearingSlug, sectionId }); + dispatch(fetchAction); + const url = (`/v1/hearing/${hearingSlug}/sections/${sectionId}/comments/`); + let params = { content: commentData.text ? commentData.text : "", plugin_data: commentData.pluginData ? commentData.pluginData : null, @@ -321,10 +325,13 @@ export function postSectionComment(hearingSlug, sectionId, commentData = {}) { answers: commentData.answers ? commentData.answers : [], pinned: commentData.pinned ? commentData.pinned : false, map_comment_text: commentData.mapCommentText ? commentData.mapCommentText : "", + organization: commentData.organization ?? undefined }; + if (commentData.authorName) { params = Object.assign(params, { author_name: commentData.authorName }); } + if (commentData.comment) { params = { ...params, comment: commentData.comment }; } @@ -342,7 +349,7 @@ export function postSectionComment(hearingSlug, sectionId, commentData = {}) { createLocalizedAlert("commentReceived"); }).catch((err) => { requestErrorHandler(dispatch, "loginToComment")(err); - }); + }); }; } diff --git a/src/components/BaseCommentForm.jsx b/src/components/BaseCommentForm.jsx index 07cc00a01..900377f1b 100644 --- a/src/components/BaseCommentForm.jsx +++ b/src/components/BaseCommentForm.jsx @@ -68,28 +68,8 @@ const BaseCommentForm = ({ onPostComment, onChangeAnswers, }) => { - const dispatch = useDispatch(); - const defaultState = useMemo(() => ({ - commentText: '', - nickname: defaultNickname, - imageTooBig: false, - images: [], - pinned: false, - showAlert: true, - hideName: false, - geojson: {}, - mapCommentText: '', - commentRequiredError: false, - commentOrAnswerRequiredError: false, - }), [defaultNickname]); - - const [formData, setFormData] = useState({ - ...defaultState, - collapsed: true, - }); - /** * Determines whether the logged in user is admin or not. * The array in users with key adminOrganizations should be of length > 0 @@ -99,6 +79,29 @@ const BaseCommentForm = ({ [loggedIn, user], ); + const defaultState = useMemo( + () => ({ + commentText: '', + nickname: defaultNickname, + imageTooBig: false, + images: [], + pinned: false, + showAlert: true, + hideName: false, + geojson: {}, + mapCommentText: '', + commentRequiredError: false, + commentOrAnswerRequiredError: false, + organization: isUserAdmin ? user.adminOrganizations[0] : undefined, + }), + [defaultNickname, isUserAdmin, user.adminOrganizations], + ); + + const [formData, setFormData] = useState({ + ...defaultState, + collapsed: true, + }); + const hasQuestions = useMemo(() => hasAnyQuestions(section), [section]); const userAnsweredAllQuestions = useMemo( @@ -125,7 +128,11 @@ const BaseCommentForm = ({ onOverrideCollapse(); } } else { - dispatch(addToast(createLocalizedNotificationPayload(NOTIFICATION_TYPES.error, getSectionCommentingErrorMessage(section)))); + dispatch( + addToast( + createLocalizedNotificationPayload(NOTIFICATION_TYPES.error, getSectionCommentingErrorMessage(section)), + ), + ); } }, [canComment, defaultState, formData, onOverrideCollapse, section, dispatch]); @@ -193,7 +200,7 @@ const BaseCommentForm = ({ const pluginComment = getPluginComment(); let pluginData = getPluginData(); - const { nickname, commentText, geojson, images, pinned, mapCommentText, imageTooBig } = formData; + const { nickname, commentText, geojson, images, pinned, mapCommentText, imageTooBig, organization } = formData; const data = { nickname: nickname === '' ? nicknamePlaceholder : nickname, @@ -203,6 +210,7 @@ const BaseCommentForm = ({ pinned, mapCommentText, label: null, + organization, }; // plugin comment will override comment fields, if provided @@ -239,19 +247,20 @@ const BaseCommentForm = ({ // make sure empty comments are not added when not intended if (isEmptyCommentAllowed(section, hasAnyAnswers(answers)) && !data.commentText.trim()) { - data.setCommentText = config.emptyCommentString; + data.commentText = config.emptyCommentString; } - onPostComment( - data.commentText, - data.nickname, + onPostComment({ + text: data.commentText, + authorName: data.nickname, pluginData, - data.geojson, - data.label, - data.images, - data.pinned, - data.mapCommentText, - ); + geojson: data.geojson, + label: data.label, + images: data.images, + pinned: data.pinned, + mapCommentText: data.mapCommentText, + organization: data.organization ?? undefined, + }); setFormData({ ...formData, @@ -350,34 +359,30 @@ const BaseCommentForm = ({ /** * For admins, there is slightly different form. */ - const renderFormForAdmin = () => { - const organization = isUserAdmin && user.adminOrganizations[0]; - - return ( - <> - } - hideLabel - id='nickname' - placeholder={nicknamePlaceholder} - value={formData.nickname} - onChange={handleNicknameChange} - maxLength={32} - disabled - /> - } - hideLabel - id='organization' - placeholder={intl.formatMessage({ id: 'organization' })} - value={organization || ''} - onChange={() => {}} - maxLength={32} - disabled - /> - - ); - }; + const renderFormForAdmin = () => ( + <> + } + hideLabel + id='nickname' + placeholder={nicknamePlaceholder} + value={formData.nickname} + onChange={handleNicknameChange} + maxLength={32} + disabled + /> + } + hideLabel + id='organization' + placeholder={intl.formatMessage({ id: 'organization' })} + value={formData.organization} + onChange={() => {}} + maxLength={32} + disabled + /> + + ); /** * If an admin type of user is posting comment, the form is slightly different. diff --git a/src/components/Hearing/Comment/index.jsx b/src/components/Hearing/Comment/index.jsx index 8c976f859..a1801239d 100644 --- a/src/components/Hearing/Comment/index.jsx +++ b/src/components/Hearing/Comment/index.jsx @@ -169,15 +169,18 @@ const Comment = (props) => { /** * Handle posting of a reply */ - const handlePostReply = (text, authorName, pluginData, geojson, label, images) => { + const handlePostReply = (comment) => { const { section } = props; - let commentData = { text, authorName, pluginData, geojson, label, images }; + + let commentData = { ...comment }; + if (props.onPostReply && props.onPostReply instanceof Function) { if (props.isReply && props.parentComponentId) { commentData = { ...commentData, comment: props.parentComponentId }; } else { commentData = { ...commentData, comment: props.data.id }; } + props.onPostReply(section.id, { ...commentData }); } }; diff --git a/src/components/Hearing/Section/SectionContainer.jsx b/src/components/Hearing/Section/SectionContainer.jsx index db6889476..19044b175 100644 --- a/src/components/Hearing/Section/SectionContainer.jsx +++ b/src/components/Hearing/Section/SectionContainer.jsx @@ -38,7 +38,12 @@ import { fetchMoreSectionComments, getCommentSubComments, } from '../../../actions'; -import { getHearingWithSlug, getMainSectionComments, getSections, getHearingContacts } from '../../../selectors/hearing'; +import { + getHearingWithSlug, + getMainSectionComments, + getSections, + getHearingContacts, +} from '../../../selectors/hearing'; import getUser from '../../../selectors/user'; import 'react-image-lightbox/style.css'; import { getApiTokenFromStorage, getApiURL, get as apiGet } from '../../../api'; @@ -68,7 +73,7 @@ const SectionContainerComponent = ({ const [mainHearingAttachmentsOpen, setMainHearingAttachmentsOpen] = useState(false); const { hearingSlug, sectionId } = useParams(); - const { search } = useLocation(); + const { search } = useLocation(); const hearing = useSelector((state) => getHearingWithSlug(state, hearingSlug)); const sections = useSelector((state) => getSections(state, hearingSlug)); @@ -176,10 +181,9 @@ const SectionContainerComponent = ({ deleteSectionCommentFn(hearingSlug, commentSectionId, commentId, refreshUser); }; - const onPostPluginComment = (text, authorName, pluginData, geojson, label, images) => { - const sectionCommentData = { text, authorName, pluginData, geojson, label, images }; + const onPostPluginComment = (comment) => { const { authCode } = parseQuery(search); - const commentData = { authCode, ...sectionCommentData }; + const commentData = { authCode, ...comment }; postSectionCommentFn(hearingSlug, mainSection.id, commentData); }; @@ -569,7 +573,6 @@ const SectionContainerComponent = ({ )} - ); }; @@ -706,4 +709,4 @@ SectionContainerComponent.propTypes = { onPostReply: PropTypes.func, }; -export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SectionContainerComponent)); \ No newline at end of file +export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SectionContainerComponent)); diff --git a/src/components/Hearing/Section/__tests__/SectionContainer.test.jsx b/src/components/Hearing/Section/__tests__/SectionContainer.test.jsx index 050450502..14f606cd8 100644 --- a/src/components/Hearing/Section/__tests__/SectionContainer.test.jsx +++ b/src/components/Hearing/Section/__tests__/SectionContainer.test.jsx @@ -8,7 +8,7 @@ import { uniqueId } from 'lodash'; import { createMemoryHistory } from 'history'; import SectionContainerComponent from '../SectionContainer'; -import { mockStore as mockData } from '../../../../../test-utils'; +import { mockStore as mockData, mockUser } from '../../../../../test-utils'; import renderWithProviders from '../../../../utils/renderWithProviders'; import * as mockApi from '../../../../api'; @@ -16,13 +16,12 @@ const mockedData = { results: [], }; -jest.spyOn(mockApi, 'get').mockImplementation(() => ( - Promise.resolve( - { - json: () => Promise.resolve(mockedData), - blob: () => Promise.resolve({}), - } - ))); +jest.spyOn(mockApi, 'get').mockImplementation(() => + Promise.resolve({ + json: () => Promise.resolve(mockedData), + blob: () => Promise.resolve({}), + }), +); jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), @@ -51,12 +50,12 @@ jest.mock('../../../../api', () => { }); const renderComponent = (storeOverrides) => { - const { mockHearingWithSections, mockUser, sectionComments } = mockData; + const { mockHearingWithSections, sectionComments } = mockData; const store = mockStore({ hearing: { [mockHearingWithSections.data.id]: { - ...mockHearingWithSections + ...mockHearingWithSections, }, }, accessibility: { @@ -101,16 +100,16 @@ describe('', () => { }); it('should render correctly when user is admin', () => { - const mockUser = { ...mockData.mockUser, adminOrganizations: [mockData.mockHearingWithSections.data.organization] }; + const mockAdminUser = { + ...mockData.mockUser, + adminOrganizations: [mockData.mockHearingWithSections.data.organization], + }; - renderComponent({ user: { data: mockUser } }); + renderComponent({ user: { data: mockAdminUser } }); }); it('should toggle accordions', async () => { - const mockUser = { ...mockData.mockUser, adminOrganizations: [mockData.mockHearingWithSections.data.organization] }; - renderComponent({ - user: { data: mockUser }, hearing: { [mockData.mockHearingWithSections.data.id]: { data: { @@ -136,9 +135,12 @@ describe('', () => { }); it('should handle report download', async () => { - const mockUser = { ...mockData.mockUser, adminOrganizations: [mockData.mockHearingWithSections.data.organization] }; + const mockAdminUser = { + ...mockData.mockUser, + adminOrganizations: [mockData.mockHearingWithSections.data.organization], + }; - renderComponent({ user: { data: mockUser } }); + renderComponent({ user: { data: mockAdminUser } }); const downloadButton = await screen.findByText(/downloadReport/i); fireEvent.click(downloadButton); diff --git a/src/components/SortableCommentList.jsx b/src/components/SortableCommentList.jsx index 398b183ce..e56802e57 100644 --- a/src/components/SortableCommentList.jsx +++ b/src/components/SortableCommentList.jsx @@ -174,29 +174,16 @@ const SortableCommentListComponent = ({ } }; - /** - * Callback function for posting a comment. - * - * @param {string} text - The comment text. - * @param {string} authorName - The name of the comment author. - * @param {object} pluginData - Additional data related to the comment. - * @param {object} geojson - The geojson data associated with the comment. - * @param {string} label - The label of the comment. - * @param {array} images - An array of images attached to the comment. - * @param {boolean} pinned - Indicates whether the comment is pinned. - * @param {string} mapCommentText - The comment text for the map. - * @returns {Promise} - A promise that resolves when the comment is posted. - */ - const onPostComment = async (text, authorName, pluginData, geojson, label, images, pinned, mapCommentText) => { + const onPostComment = async (comment) => { const { answers } = listState; if (user) { setListState({ ...listState, shouldAnimate: true }); } - const commentData = { text, authorName, pluginData, geojson, label, images, answers, pinned, mapCommentText }; + const commentData = { ...comment, answers }; - if (onPostComment) { + if (onPostCommentFn) { await onPostCommentFn(section.id, commentData); setListState({ ...listState, answers: answersInitialState }); @@ -209,7 +196,7 @@ const SortableCommentListComponent = ({ * @param {string} sectionId - The ID of the section. * @param {object} data - The data of the comment. */ - const handlePostReply = (sectionId, data) => onPostComment(sectionId, data); + const handlePostReply = (sectionId, data) => onPostCommentFn(sectionId, data); /** * Handles the change of answers for a specific question. diff --git a/src/components/__tests__/BaseCommentForm.jsx b/src/components/__tests__/BaseCommentForm.jsx index 1b2121040..31cf73327 100644 --- a/src/components/__tests__/BaseCommentForm.jsx +++ b/src/components/__tests__/BaseCommentForm.jsx @@ -79,7 +79,17 @@ describe('', () => { fireEvent.click(submitButton); - expect(onPostComment).toHaveBeenCalledWith('Test comment', 'Test Nickname', undefined, {}, null, [], false, ''); + expect(onPostComment).toHaveBeenCalledWith({ + authorName: 'Test Nickname', + geojson: {}, + images: [], + label: null, + mapCommentText: '', + organization: undefined, + pinned: false, + pluginData: undefined, + text: 'Test comment', + }); }); it('handles nickname change', () => { diff --git a/src/components/plugins/MapQuestionnaire.jsx b/src/components/plugins/MapQuestionnaire.jsx index 5654db8ba..7869bd228 100644 --- a/src/components/plugins/MapQuestionnaire.jsx +++ b/src/components/plugins/MapQuestionnaire.jsx @@ -1,7 +1,7 @@ /* eslint-disable react/forbid-prop-types */ /* eslint-disable jsx-a11y/iframe-has-title */ /* eslint-disable no-case-declarations */ -import React, { useEffect, useRef, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import PropTypes from 'prop-types'; import { injectIntl, FormattedMessage } from 'react-intl'; import { Button, TextArea } from 'hds-react'; @@ -39,6 +39,7 @@ const MapQuestionnaire = ({ pluginInstanceId, pluginPurpose, pluginSource, +// eslint-disable-next-line sonarjs/cognitive-complexity }) => { const { answers, @@ -51,6 +52,15 @@ const MapQuestionnaire = ({ user, } = data; + /** + * Determines whether the logged in user is admin or not. + * The array in users with key adminOrganizations should be of length > 0 + */ + const isUserAdmin = useMemo( + () => loggedIn && user && Array.isArray(user.adminOrganizations) && user.adminOrganizations.length > 0, + [loggedIn, user], + ); + const [formData, setFormData] = useState({ collapsed: true, commentOrAnswerRequiredError: false, @@ -71,6 +81,7 @@ const MapQuestionnaire = ({ submitting: false, showAlert: true, userDataChanged: false, + organization: isUserAdmin ? user.adminOrganizations[0] : undefined, }); const [messageListener, setMessageListener] = useState(null); @@ -122,7 +133,7 @@ const MapQuestionnaire = ({ const pluginComment = getPluginComment(); let pluginData = getPluginData(); - const { nickname, commentText, geojson, images, pinned, mapCommentText, imageTooBig } = formData; + const { nickname, commentText, geojson, images, pinned, mapCommentText, imageTooBig, organization } = formData; const submitData = { nickname: nickname === '' ? nicknamePlaceholder : nickname, @@ -132,6 +143,7 @@ const MapQuestionnaire = ({ pinned, mapCommentText, label: null, + organization, }; // plugin comment will override comment fields, if provided @@ -171,16 +183,17 @@ const MapQuestionnaire = ({ submitData.setCommentText = config.emptyCommentString; } - onPostComment( - submitData.commentText, - submitData.nickname, + onPostComment({ + text: submitData.commentText, + authorName: submitData.nickname, pluginData, - submitData.geojson, - submitData.label, - submitData.images, - submitData.pinned, - submitData.mapCommentText, - ); + geojson: submitData.geojson, + label: submitData.label, + images: submitData.images, + pinned: submitData.pinned, + mapCommentText: submitData.mapCommentText, + organization: submitData.organization ?? undefined, + }); setFormData((prevState) => ({ ...prevState, diff --git a/src/components/plugins/legacy/mapdon-hkr.jsx b/src/components/plugins/legacy/mapdon-hkr.jsx index 1b184668a..5fec59676 100644 --- a/src/components/plugins/legacy/mapdon-hkr.jsx +++ b/src/components/plugins/legacy/mapdon-hkr.jsx @@ -125,7 +125,6 @@ class MapdonHKRPlugin extends BaseCommentForm { } MapdonHKRPlugin.propTypes = { - onPostComment: PropTypes.func, data: PropTypes.string, }; diff --git a/src/components/plugins/legacy/mapdon-ksv.jsx b/src/components/plugins/legacy/mapdon-ksv.jsx index 7cc3b7ed3..3bf1674b5 100644 --- a/src/components/plugins/legacy/mapdon-ksv.jsx +++ b/src/components/plugins/legacy/mapdon-ksv.jsx @@ -170,7 +170,6 @@ class MapdonKSVPlugin extends BaseCommentForm { } MapdonKSVPlugin.propTypes = { - onPostComment: PropTypes.func, data: PropTypes.string, pluginPurpose: PropTypes.string, comments: PropTypes.array, diff --git a/src/utils/section.js b/src/utils/section.js index 361591ad0..5915d51d2 100644 --- a/src/utils/section.js +++ b/src/utils/section.js @@ -41,7 +41,7 @@ export function isCommentRequired(hasQuestions, isReply, userAnsweredAllQuestion * @returns {boolean} true when at least one question is answered and false if not */ export function hasAnyAnswers(answers) { - return answers.some(questionAnswers => questionAnswers.answers && questionAnswers.answers.length > 0); + return answers && answers.some(questionAnswers => questionAnswers.answers && questionAnswers.answers.length > 0); } /** diff --git a/src/views/FullscreenHearing/FullscreenHearingContainer.jsx b/src/views/FullscreenHearing/FullscreenHearingContainer.jsx index 33987ee25..a91b924fa 100644 --- a/src/views/FullscreenHearing/FullscreenHearingContainer.jsx +++ b/src/views/FullscreenHearing/FullscreenHearingContainer.jsx @@ -13,7 +13,12 @@ import { getHearingWithSlug, getMainSection, getMainSectionComments } from '../. import LoadSpinner from '../../components/LoadSpinner'; import getAttr from '../../utils/getAttr'; import { parseQuery } from '../../utils/urlQuery'; -import { fetchHearing as fetchHearingAction, postSectionComment, postVote, fetchAllSectionComments } from '../../actions'; +import { + fetchHearing as fetchHearingAction, + postSectionComment, + postVote, + fetchAllSectionComments, +} from '../../actions'; import Link from '../../components/LinkWithLang'; import Icon from '../../utils/Icon'; import getUser from '../../selectors/user'; @@ -28,8 +33,8 @@ const FullscreenHearingContainerComponent = (ownProps) => { const user = useSelector((state) => getUser(state)); const language = useSelector((state) => state.language); const fetchAllComments = (hearingSlug, sectionId, ordering) => { - dispatch(fetchAllSectionComments(hearingSlug, sectionId, ordering)) - } + dispatch(fetchAllSectionComments(hearingSlug, sectionId, ordering)); + }; useEffect(() => { if (isEmpty(hearing)) { @@ -38,13 +43,12 @@ const FullscreenHearingContainerComponent = (ownProps) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const onPostComment = (text, authorName, pluginData, geojson, label, images) => { - const sectionCommentData = { text, authorName, pluginData, geojson, label, images }; + const onPostComment = (comment) => { // eslint-disable-next-line no-shadow const { mainSection } = ownProps; const { hearingSlug } = params; const { authCode } = parseQuery(location.search); - const commentData = { authCode, ...sectionCommentData }; + const commentData = { authCode, ...comment }; return dispatch(postSectionComment(hearingSlug, mainSection.id, commentData)); }; diff --git a/src/views/Hearing/__tests__/HearingContainer.test.jsx b/src/views/Hearing/__tests__/HearingContainer.test.jsx index 5a10397e1..279e0c6dc 100644 --- a/src/views/Hearing/__tests__/HearingContainer.test.jsx +++ b/src/views/Hearing/__tests__/HearingContainer.test.jsx @@ -89,7 +89,9 @@ describe('', () => { isSaving: false, }, }, - user, + user: { + data: user, + }, sectionComments: [], accessibility: { isHighContrast: false, diff --git a/test-utils.js b/test-utils.js index b8e219ba6..ce87e8fd8 100644 --- a/test-utils.js +++ b/test-utils.js @@ -6,7 +6,7 @@ import createStore from './src/createStore'; import messages from './src/i18n'; -export const mockUser = { id: "fff", displayName: "Mock von User" }; +export const mockUser = { id: "fff", displayName: "Mock von User", adminOrganizations: [] }; export function createTestStore(state) { commonInit(); From b981510c8c08b75446baf2a61c42a6b51467918d Mon Sep 17 00:00:00 2001 From: mikkojamG Date: Tue, 4 Feb 2025 15:13:16 +0200 Subject: [PATCH 03/14] fix: close comment editor from cancel button KER-422 --- src/components/Hearing/Comment/index.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/Hearing/Comment/index.jsx b/src/components/Hearing/Comment/index.jsx index a1801239d..e075c6f77 100644 --- a/src/components/Hearing/Comment/index.jsx +++ b/src/components/Hearing/Comment/index.jsx @@ -317,6 +317,12 @@ const Comment = (props) => { ); }; + const toggleEditor = (event) => { + event.preventDefault(); + + setState({ editorOpen: !state.editorOpen }); + }; + /** * When state is set to true for editor open. Return the form. * When editing, answers may be edited as well. @@ -343,19 +349,13 @@ const Comment = (props) => { + ); - const toggleEditor = (event) => { - event.preventDefault(); - if (state.editorOpen) { - setState({ editorOpen: false }); - } else { - setState({ editorOpen: true }); - } - }; - /** * If a user can edit their comment(s) render hyperlinks * @returns {Component|null} From 1672fd32835b206304d4e086fdad0df877342148 Mon Sep 17 00:00:00 2001 From: mikkojamG Date: Tue, 4 Feb 2025 15:31:14 +0200 Subject: [PATCH 04/14] fix: delete comment KER-422 --- src/components/DeleteModal.jsx | 7 +++- src/components/Hearing/Comment/index.jsx | 1 + .../Hearing/Section/SectionContainer.jsx | 37 +++++++++++-------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/components/DeleteModal.jsx b/src/components/DeleteModal.jsx index f940b6826..907c8bf44 100644 --- a/src/components/DeleteModal.jsx +++ b/src/components/DeleteModal.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import { Button, Dialog } from 'hds-react'; import { FormattedMessage, injectIntl } from 'react-intl'; -const DeleteModal = ({ isOpen, intl, close, onDeleteComment }) => { +const DeleteModal = ({ isOpen, commentSectionId, commentId, refreshUser, intl, close, onDeleteComment }) => { const titleId = 'delete-modal-title'; const descriptionId = 'delete-modal-description'; @@ -30,7 +30,7 @@ const DeleteModal = ({ isOpen, intl, close, onDeleteComment }) => {