Skip to content

Commit

Permalink
Merge pull request #395 from bluewave-labs/386-fix-toast-messages-in-…
Browse files Browse the repository at this point in the history
…create-banner-and-create-popup-pages

chore: remove front end validation of urls
  • Loading branch information
erenfn authored Dec 17, 2024
2 parents 7a310eb + d1ebf83 commit 223e02f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
15 changes: 0 additions & 15 deletions frontend/src/scenes/banner/CreateBannerPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,6 @@ const BannerPage = () => {
};

const onSave = async () => {
if (actionUrl && actionUrl !== "https://") {
const urlError = validateUrl(actionUrl);
if (urlError) {
emitToastError(urlError);
return;
}
}
if (url && url !== "https://") {
const urlError = validateUrl(url);
if (urlError) {
emitToastError(urlError);
return;
}
}

const bannerData = {
backgroundColor,
fontColor,
Expand Down
21 changes: 2 additions & 19 deletions frontend/src/scenes/popup/CreatePopupPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,6 @@ const CreatePopupPage = () => {
};

const onSave = async () => {
if (actionButtonUrl && actionButtonUrl !== "https://") {
const urlError = validateUrl(actionButtonUrl);
if (urlError) {
emitToastError(urlError);
return;
}
}
if (url && url !== "https://") {
const urlError = validateUrl(url);
if (urlError) {
emitToastError(urlError);
return;
}
}
const popupData = {
popupSize: popupSize.toLowerCase(),
url,
Expand All @@ -131,18 +117,15 @@ const CreatePopupPage = () => {
const response = location.state?.isEdit
? await editPopup(location.state?.id, popupData)
: await addPopup(popupData);

console.log(response)
const toastMessage = location.state?.isEdit
? "You edited this popup"
: "New popup Saved";

toastEmitter.emit(TOAST_EMITTER_KEY, toastMessage);
navigate("/popup");
} catch (error) {
const errorMessage = error.response?.data?.message
? `Error: ${error.response.data.message}`
: "An unexpected error occurred. Please try again.";
toastEmitter.emit(TOAST_EMITTER_KEY, errorMessage);
emitToastError(error);
}
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/scenes/popup/CreatePopupPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('CreatePopupPage component', () => {
await waitFor(() => {
expect(emitSpy).toHaveBeenCalledWith(
expect.anything(), // The first argument is the key, which can be anything
expect.stringContaining('An unexpected error occurred')
expect.stringContaining('An error occurred')
);
});

Expand Down

0 comments on commit 223e02f

Please sign in to comment.