Skip to content

Commit

Permalink
Merge pull request #3633 from LiteFarmOrg/LF-4598-After-submitting-th…
Browse files Browse the repository at this point in the history
…e-feedback-form-the-user-is-redirected-to-the-home-page

LF-4598 Removed redirection and made feedback from self-contained
  • Loading branch information
antsgar authored Jan 13, 2025
2 parents 5951cec + 0e6fb61 commit bf73aa0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
33 changes: 25 additions & 8 deletions packages/webapp/src/containers/Help/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import PureHelpRequestPage from '../../components/Help';
import { useDispatch, useSelector } from 'react-redux';
import { supportFileUpload } from './saga';
import { isHelpLoadingSelector, startSendHelp } from '../Home/homeSlice';
import {
isHelpLoadingSelector,
startSendHelp,
dismissHelpRequestModal,
showHelpRequestModalSelector,
} from '../Home/homeSlice';
import { userFarmSelector } from '../userFarmSlice';
import RequestConfirmationComponent from '../../components/Modals/RequestConfirmationModal';

export default function HelpRequest({ closeDrawer }) {
const dispatch = useDispatch();

const showHelpRequestModal = useSelector(showHelpRequestModalSelector);
const showRequestConfirmationModalOnClick = () => dispatch(dismissHelpRequestModal());

const handleSubmit = (file, data, resetForm) => {
dispatch(startSendHelp());
dispatch(
Expand All @@ -27,12 +36,20 @@ export default function HelpRequest({ closeDrawer }) {
const { email, phone_number } = useSelector(userFarmSelector);
const loading = useSelector(isHelpLoadingSelector);
return (
<PureHelpRequestPage
onSubmit={handleSubmit}
onCancel={onCancel}
email={email}
phoneNumber={phone_number}
isLoading={loading}
/>
<>
<PureHelpRequestPage
onSubmit={handleSubmit}
onCancel={onCancel}
email={email}
phoneNumber={phone_number}
isLoading={loading}
/>
{showHelpRequestModal && (
<RequestConfirmationComponent
onClick={showRequestConfirmationModalOnClick}
dismissModal={showRequestConfirmationModalOnClick}
/>
)}
</>
);
}
2 changes: 0 additions & 2 deletions packages/webapp/src/containers/Help/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import { createAction } from '@reduxjs/toolkit';
import { call, put, takeLeading } from 'redux-saga/effects';
import { url } from '../../apiConfig';
import history from '../../history';
import { finishSendHelp, postHelpRequestSuccess } from '../Home/homeSlice';
import i18n from '../../locales/i18n';
import { axios } from '../saga';
Expand All @@ -40,7 +39,6 @@ export function* supportFileUploadSaga({ payload: { file, form, onSuccess } }) {
if (result) {
yield put(postHelpRequestSuccess());
onSuccess();
history.push('/');
} else {
yield put(enqueueErrorSnackbar(i18n.t('message:HELP_REQUEST.ERROR.SEND')));
}
Expand Down
11 changes: 0 additions & 11 deletions packages/webapp/src/containers/Home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import PureHome from '../../components/Home';
import { userFarmSelector } from '../userFarmSlice';
import { useTranslation } from 'react-i18next';
import FarmSwitchOutro from '../FarmSwitchOutro';
import RequestConfirmationComponent from '../../components/Modals/RequestConfirmationModal';
import { dismissHelpRequestModal, showHelpRequestModalSelector } from './homeSlice';
import {
chooseFarmFlowSelector,
endExportModal,
Expand All @@ -28,8 +26,6 @@ export default function Home({ history }) {
const showSwitchFarmModal = useSelector(switchFarmSelector);
const dismissPopup = () => dispatch(endSwitchFarmModal(userFarm.farm_id));
const dismissExportModal = () => dispatch(endExportModal(userFarm.farm_id));
const showHelpRequestModal = useSelector(showHelpRequestModalSelector);
const showRequestConfirmationModalOnClick = () => dispatch(dismissHelpRequestModal());
const { mediaUrl: authenticatedImageUrl, isLoading } = useMediaWithAuthentication({
fileUrls: [userFarm.farm_image_url],
});
Expand All @@ -47,13 +43,6 @@ export default function Home({ history }) {
{userFarm ? <WeatherBoard /> : null}
{showSwitchFarmModal && !showSpotLight && <FarmSwitchOutro onFinish={dismissPopup} />}

{showHelpRequestModal && (
<RequestConfirmationComponent
onClick={showRequestConfirmationModalOnClick}
dismissModal={showRequestConfirmationModalOnClick}
/>
)}

{showExportModal && <PreparingExportModal dismissModal={() => dismissExportModal(false)} />}
</PureHome>
);
Expand Down

0 comments on commit bf73aa0

Please sign in to comment.