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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user