Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

fix: issue #124 #129

Merged
merged 2 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Avoid mutating redux state, set success and error titles in popup opt…
…ions, coding style fixes
  • Loading branch information
mbaghel committed Feb 26, 2021
commit 04643b658537dd0b417ea77aabecd1d67be653fc
12 changes: 7 additions & 5 deletions src/components/EmailPopup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,26 @@ function EmailPopup() {
const submitEmail = () => {
setIsLoading(true);

_.set(data, popupOptions.textDataField, textVal);
const postData = _.merge({}, data);

postEmail(data)
_.set(postData, popupOptions.textDataField, textVal);

postEmail(postData)
.then(() => {
setIsLoading(false);
closeModal();
toastr.success("Email submitted successfully");
toastr.success(popupOptions.successTitle);
})
.catch((err) => {
setIsLoading(false);

toastr.error("Email failed to send", err.message);
toastr.error(popupOptions.errorTitle, err.message);
});
};

const button = (
<Button
onClick={() => submitEmail()}
onClick={submitEmail}
size="medium"
isSubmit
disabled={textVal.trim().length < 1 || isLoading}
Expand Down
8 changes: 6 additions & 2 deletions src/utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export const formatReportPopup = (teamName, memberHandle) => {
}`,
textPlaceholder: "Describe your issue",
textDataField: "data.reportText",
successTitle: "Report submitted successfully",
errorTitle: "Report failed",
};
};

Expand All @@ -154,6 +156,8 @@ export const formatExtensionPopup = (teamName, memberHandle) => {
}`,
textPlaceholder: "Add any comments...",
textDataField: "data.text",
successTitle: "Extension request submitted successfully",
errorTitle: "Extension request failed",
};
};

Expand All @@ -175,8 +179,8 @@ export const formatReportData = (teamName, teamId, memberHandle) => {
};

if (!!memberHandle) {
_.set(data, "template", "member-issue-report"),
_.set(data, "data.userHandle", memberHandle);
_.set(data, "template", "member-issue-report");
_.set(data, "data.userHandle", memberHandle);
}

return data;
Expand Down