From d194db39fdfd5b1c19f7652e8fc41e7c9ba8e885 Mon Sep 17 00:00:00 2001 From: Debora Serra Date: Mon, 16 Dec 2024 12:59:49 -0800 Subject: [PATCH 1/2] chore: remove front end validation of urls --- .../src/scenes/banner/CreateBannerPage.jsx | 15 ------------- frontend/src/scenes/popup/CreatePopupPage.jsx | 21 ++----------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/frontend/src/scenes/banner/CreateBannerPage.jsx b/frontend/src/scenes/banner/CreateBannerPage.jsx index 59ad75fd..5758e017 100644 --- a/frontend/src/scenes/banner/CreateBannerPage.jsx +++ b/frontend/src/scenes/banner/CreateBannerPage.jsx @@ -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, diff --git a/frontend/src/scenes/popup/CreatePopupPage.jsx b/frontend/src/scenes/popup/CreatePopupPage.jsx index 5d68f3ac..6c2c3c67 100644 --- a/frontend/src/scenes/popup/CreatePopupPage.jsx +++ b/frontend/src/scenes/popup/CreatePopupPage.jsx @@ -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, @@ -131,7 +117,7 @@ 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"; @@ -139,10 +125,7 @@ const CreatePopupPage = () => { 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); } }; From d1ebf8327b2003b8dffa296840250051c9ce7a09 Mon Sep 17 00:00:00 2001 From: Debora Serra Date: Mon, 16 Dec 2024 13:41:22 -0800 Subject: [PATCH 2/2] test: fix test --- frontend/src/tests/scenes/popup/CreatePopupPage.test.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/tests/scenes/popup/CreatePopupPage.test.jsx b/frontend/src/tests/scenes/popup/CreatePopupPage.test.jsx index 726de2b6..b54c356d 100644 --- a/frontend/src/tests/scenes/popup/CreatePopupPage.test.jsx +++ b/frontend/src/tests/scenes/popup/CreatePopupPage.test.jsx @@ -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') ); });