Skip to content

Scheduling infrastructure for absolutely everyone.

chore: Refactor CloseComSetup form submission logic (#16062)

Imamuzzaki Abu Salam3c6e9aaa6393
diff --git a/packages/app-store/closecom/pages/setup/index.tsx b/packages/app-store/closecom/pages/setup/index.tsx
index 789fdd24562..d5711484bd9 100644
--- a/packages/app-store/closecom/pages/setup/index.tsx
+++ b/packages/app-store/closecom/pages/setup/index.tsx
@@ -66,16 +66,15 @@ export default function CloseComSetup() {
form={form}
handleSubmit={async (values) => {
const { returnTo } = query;
- const res = await fetch(
- `/api/integrations/closecom/add${returnTo ? `?returnTo=${returnTo}` : ""}`,
- {
- method: "POST",
- body: JSON.stringify(values),
- headers: {
- "Content-Type": "application/json",
- },
- }
- );
+ const url = new URL("/api/integrations/closecom/add");
+ if (returnTo) url.searchParams.append("returnTo", `${returnTo}`);
+ const res = await fetch(url.href, {
+ method: "POST",
+ body: JSON.stringify(values),
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
const json = await res.json();
if (res.ok) {