Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 04643b6

Browse files
committedFeb 26, 2021
Avoid mutating redux state, set success and error titles in popup options, coding style fixes
1 parent 1d104aa commit 04643b6

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed
 

‎src/components/EmailPopup/index.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@ function EmailPopup() {
2626
const submitEmail = () => {
2727
setIsLoading(true);
2828

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

31-
postEmail(data)
31+
_.set(postData, popupOptions.textDataField, textVal);
32+
33+
postEmail(postData)
3234
.then(() => {
3335
setIsLoading(false);
3436
closeModal();
35-
toastr.success("Email submitted successfully");
37+
toastr.success(popupOptions.successTitle);
3638
})
3739
.catch((err) => {
3840
setIsLoading(false);
3941

40-
toastr.error("Email failed to send", err.message);
42+
toastr.error(popupOptions.errorTitle, err.message);
4143
});
4244
};
4345

4446
const button = (
4547
<Button
46-
onClick={() => submitEmail()}
48+
onClick={submitEmail}
4749
size="medium"
4850
isSubmit
4951
disabled={textVal.trim().length < 1 || isLoading}

‎src/utils/format.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ export const formatReportPopup = (teamName, memberHandle) => {
137137
}`,
138138
textPlaceholder: "Describe your issue",
139139
textDataField: "data.reportText",
140+
successTitle: "Report submitted successfully",
141+
errorTitle: "Report failed",
140142
};
141143
};
142144

@@ -154,6 +156,8 @@ export const formatExtensionPopup = (teamName, memberHandle) => {
154156
}`,
155157
textPlaceholder: "Add any comments...",
156158
textDataField: "data.text",
159+
successTitle: "Extension request submitted successfully",
160+
errorTitle: "Extension request failed",
157161
};
158162
};
159163

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

177181
if (!!memberHandle) {
178-
_.set(data, "template", "member-issue-report"),
179-
_.set(data, "data.userHandle", memberHandle);
182+
_.set(data, "template", "member-issue-report");
183+
_.set(data, "data.userHandle", memberHandle);
180184
}
181185

182186
return data;

0 commit comments

Comments
 (0)
This repository has been archived.