Skip to content

Commit b6e19ee

Browse files
author
FalkWolsky
committed
Update for Subscription Handling
1 parent d4a2a2c commit b6e19ee

File tree

4 files changed

+265
-86
lines changed

4 files changed

+265
-86
lines changed

client/packages/lowcoder/src/api/subscriptionApi.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface CustomerAddress {
1010
postalCode: string;
1111
}
1212

13-
export interface Customer {
13+
export interface LowcoderCustomer {
1414
hostname: string;
1515
email: string;
1616
orgId: string;
@@ -21,6 +21,37 @@ export interface Customer {
2121
address?: CustomerAddress;
2222
}
2323

24+
interface LowcoderMetadata {
25+
lowcoder_host: string;
26+
lowcoder_orgId: string;
27+
lowcoder_type: string;
28+
lowcoder_userId: string;
29+
}
30+
31+
export interface StripeCustomer {
32+
id: string;
33+
object: string;
34+
address?: object | null;
35+
balance: number;
36+
created: number;
37+
currency: string | null;
38+
default_source: string | null;
39+
delinquent: boolean;
40+
description: string | null;
41+
discount: string | null;
42+
email: string;
43+
invoice_prefix: string;
44+
invoice_settings: object | null;
45+
livemode: boolean;
46+
metadata: LowcoderMetadata;
47+
name: string;
48+
phone: string | null;
49+
preferred_locales: string[];
50+
shipping: string | null;
51+
tax_exempt: string;
52+
test_clock: string | null;
53+
}
54+
2455
export type ResponseType = {
2556
response: any;
2657
};

client/packages/lowcoder/src/pages/setting/subscriptions/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export const Subscription = () => {
88

99
const location = useLocation();
1010

11-
console.log("Current location:", location.pathname);
12-
1311
return (
1412
<Switch>
1513
<Route path={SUBSCRIPTION_SETTING} component={SubscriptionSetting} exact />

client/packages/lowcoder/src/pages/setting/subscriptions/productCard.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// productCard.tsx
21
import React from 'react';
32
import styled from 'styled-components';
43
import { GreyTextColor } from 'constants/style';
54
import { Card } from 'antd';
6-
import { SettingOutlined, CheckCircleOutlined, PlusSquareOutlined } from '@ant-design/icons';
5+
import { SettingOutlined, CheckCircleOutlined, PlusSquareOutlined, LoadingOutlined, InfoCircleOutlined } from '@ant-design/icons';
76
import { buildSubscriptionId } from "constants/routesURL";
87
import history from "util/history";
98

@@ -53,7 +52,9 @@ interface ProductCardProps {
5352
pricingType: string;
5453
pricing: Pricing[];
5554
activeSubscription: boolean;
56-
accessLink: string;
55+
checkoutLink: string;
56+
checkoutLinkDataLoaded?: boolean;
57+
subscriptionId: string;
5758
}
5859

5960
export const ProductCard: React.FC<ProductCardProps> = ({
@@ -63,23 +64,43 @@ export const ProductCard: React.FC<ProductCardProps> = ({
6364
pricingType,
6465
pricing,
6566
activeSubscription,
66-
accessLink
67+
checkoutLink,
68+
checkoutLinkDataLoaded,
69+
subscriptionId
6770
}) => {
6871

69-
const handleClick = () => {
70-
history.push(buildSubscriptionId(accessLink));
72+
const goToCheckout = () => {
73+
if (checkoutLink) {
74+
window.open(checkoutLink, '_blank');
75+
}
76+
};
77+
78+
const goToSubscriptionSettings = () => {
79+
history.push(buildSubscriptionId(subscriptionId));
80+
};
81+
82+
const goToSubscriptionInformation = () => {
83+
// history.push(buildSubscriptionId(subscriptionId));
7184
};
7285

7386
return (
7487
<ProductCardContainer
7588
hoverable
7689
cover={<img alt={title} src={image} />}
7790
actions={[
78-
<SettingOutlined key="setting" onClick={handleClick} />,
91+
activeSubscription ? (
92+
<SettingOutlined key="setting" onClick={goToSubscriptionSettings} />
93+
) : (
94+
<InfoCircleOutlined key="setting" onClick={goToSubscriptionInformation} />
95+
),
7996
activeSubscription ? (
8097
<CheckCircleOutlined key="check" style={{ color: 'green' }} />
8198
) : (
82-
<PlusSquareOutlined key="add" style={{ color: 'blue' }} />
99+
checkoutLinkDataLoaded ? (
100+
<PlusSquareOutlined key="add" style={{ color: 'blue'}} onClick={goToCheckout}/>
101+
) : (
102+
<LoadingOutlined key="wait" />
103+
)
83104
)
84105
]}
85106
>

0 commit comments

Comments
 (0)