chore: Refactor CloseComSetup form submission logic (#16062)

The commit refactors the form submission logic in the CloseComSetup component to use the URLSearchParams API for constructing the URL and removes unnecessary code.
This commit is contained in:
Imamuzzaki Abu Salam
2024-08-06 13:43:17 +02:00
committed by GitHub
parent 8fa39f2ae5
commit 3c6e9aaa63
@@ -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) {