refactor: clean up
This commit is contained in:
@@ -114,42 +114,6 @@ export function NewWorkspaceForm() {
|
|||||||
weekStartDay: 1,
|
weekStartDay: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
// If in cloud and Pro toggle is enabled, create checkout session for pro
|
|
||||||
if (env("NEXT_PUBLIC_KAN_ENV") === "cloud" && isProToggleEnabled) {
|
|
||||||
try {
|
|
||||||
const response = await fetch(
|
|
||||||
"/api/stripe/create_checkout_session",
|
|
||||||
{
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
slug: slug || undefined,
|
|
||||||
workspacePublicId: values.publicId,
|
|
||||||
cancelUrl: window.location.pathname + window.location.search,
|
|
||||||
successUrl: "/boards",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
const url = (data as { url: string }).url;
|
|
||||||
|
|
||||||
if (url) {
|
|
||||||
window.location.href = url;
|
|
||||||
return; // Don't close modal if redirecting to checkout
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error creating checkout session:", error);
|
|
||||||
showPopup({
|
|
||||||
header: t`Error upgrading to Pro`,
|
|
||||||
message: t`Workspace created successfully. You can upgrade later in settings.`,
|
|
||||||
icon: "warning",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closeModal();
|
closeModal();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ export function InviteMemberForm({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-12 flex items-center justify-end border-t border-light-600 px-5 pb-5 pt-5 dark:border-dark-600">
|
<div className="mt-12 flex items-center justify-end space-x-4 border-t border-light-600 px-5 pb-5 pt-5 dark:border-dark-600">
|
||||||
<Toggle
|
<Toggle
|
||||||
label={
|
label={
|
||||||
isShareInviteLinkEnabled
|
isShareInviteLinkEnabled
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export function UpgradeToProConfirmation({
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
...(entityId && { slug: entityId }),
|
...(entityId && { slug: entityId }),
|
||||||
workspacePublicId: workspacePublicId,
|
workspacePublicId: workspacePublicId,
|
||||||
|
plan: "pro",
|
||||||
|
billing: "monthly",
|
||||||
cancelUrl: "/settings",
|
cancelUrl: "/settings",
|
||||||
successUrl: "/settings",
|
successUrl: "/settings",
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user