Skip to content

chore: remove front end validation of urls #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading