fix: cloud fixes

This commit is contained in:
sriram veeraghanta 2023-10-30 16:50:15 +05:30
parent 912851659c
commit 1a0f912ab4
2 changed files with 15 additions and 9 deletions

View File

@ -23,16 +23,16 @@ export const UpgradeWorkspaceModal: FC<IUpgradeWorkspaceModal> = observer((props
// fetching products
const { data: products } = useSWR("UPGRADE_PRODUCTS", () => licenseService.getProducts());
console.log("products", products);
const handleUpgrade = (product: any) => {
if (currentUser && workspaceMembers && workspaceMembers?.length >= 1 && currentWorkspace) {
// licenseService.createSubscription(currentUser, product?.default_price?.id).then((response) => {
// console.log("subscription", response);
// });
licenseService
.createCheckoutSession(product?.default_price?.id, workspaceMembers?.length, currentWorkspace, currentUser)
.createCheckoutSession(
product?.default_price?.id,
workspaceMembers?.length,
currentWorkspace,
currentUser,
product?.metadata
)
.then((response) => {
console.log("subscription", response);
window.open(response.url, "_blank");

View File

@ -23,8 +23,14 @@ export class LicenseService extends APIService {
});
}
async createCheckoutSession(priceId: string, seats: number, workspace: IWorkspace, user: IUser): Promise<any> {
return this.post(`/api/checkout/create-session/`, { priceId, seats, workspace, user })
async createCheckoutSession(
priceId: string,
seats: number,
workspace: IWorkspace,
user: IUser,
metadata: any
): Promise<any> {
return this.post(`/api/checkout/create-session/`, { priceId, seats, workspace, user, metadata })
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;