Skip to content

Commit

Permalink
fix: comment report form, broken error toast KER-346
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkojamG committed Oct 31, 2024
1 parent a5789ba commit 42e4357
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/CommentReportModal/CommentReportForm.jsx
Original file line number Diff line number Diff line change
@@ -3,13 +3,14 @@ import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Button, Select } from 'hds-react';
import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { connect, useDispatch } from 'react-redux';

import getAttr from '../../utils/getAttr';
import Icon from '../../utils/Icon';
import { FILE_FORMATS } from './constants';
import { getApiTokenFromStorage, getApiURL } from '../../api';
import { localizedNotifyError } from '../../utils/notify';
import { createNotificationPayload, NOTIFICATION_TYPES } from '../../utils/notify';
import { addToast } from '../../actions/toast';

/**
* Renders a form for reporting comments.
@@ -23,6 +24,8 @@ import { localizedNotifyError } from '../../utils/notify';
const CommentReportForm = ({ hearing, id, language }) => {
const [fileFormat, setFileFormat] = useState(FILE_FORMATS.EXCEL.id);

const dispatch = useDispatch();

/**
* Handles the change event of the file format input.
*
@@ -73,7 +76,7 @@ const CommentReportForm = ({ hearing, id, language }) => {

link.parentNode.removeChild(link);
} catch (error) {
localizedNotifyError(error.message);
dispatch(addToast(createNotificationPayload(NOTIFICATION_TYPES.error, error.message)));
}
};

0 comments on commit 42e4357

Please sign in to comment.