Skip to content

Commit 55cf651

Browse files
committed
Merge branch 'billing-cta-button-for-invoice' into 'master'
feat(ui): add invoices button, format snapshot error (platform#242) See merge request postgres-ai/database-lab!774
2 parents 0fed6f9 + e03a99a commit 55cf651

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

ui/packages/platform/src/components/StripeForm/index.tsx

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ const useStyles = makeStyles(
7676
flex: 'auto',
7777
},
7878
},
79+
flexColumnContainer: {
80+
display: 'flex',
81+
flexDirection: 'column',
82+
flex: '1.75 1 0',
83+
gap: 20,
84+
85+
[theme.breakpoints.down('sm')]: {
86+
width: '100%',
87+
flex: 'auto',
88+
},
89+
},
7990
cardContainerTitle: {
8091
fontSize: 14,
8192
fontWeight: 'bold',
@@ -104,6 +115,11 @@ const useStyles = makeStyles(
104115
fontSize: 13,
105116
flex: '1 1 0',
106117
},
118+
button: {
119+
'&:hover': {
120+
color: '#0F879D',
121+
},
122+
},
107123
columnContainer: {
108124
display: 'flex',
109125
alignItems: 'center',
@@ -342,7 +358,7 @@ function StripeForm(props: {
342358
<div>
343359
{stripeStyles}
344360
<div className={classes.paperContainer}>
345-
<Box className={classes.subscriptionContainer}>
361+
<Box className={classes.flexColumnContainer}>
346362
<p className={classes?.cardContainerTitle}>Subscriptions</p>
347363
{state.billingInfo.length > 0 ? (
348364
state.billingInfo.map(
@@ -406,13 +422,14 @@ function StripeForm(props: {
406422
)}
407423
</Box>
408424
<Box className={classes.subscriptionContainer}>
409-
<p className={classes?.cardContainerTitle}>Payment methods</p>
425+
<p className={classes?.cardContainerTitle}>Payments</p>
410426
<Paper className={classes?.cardContainer}>
411427
<Box
412428
sx={{
413429
display: 'flex',
414-
justifyContent: 'flex-end',
430+
justifyContent: 'flex-start',
415431
alignItems: 'center',
432+
gap: '1rem',
416433
}}
417434
>
418435
<Button
@@ -426,9 +443,23 @@ function StripeForm(props: {
426443
<Spinner size="sm" className={classes.spinner} />
427444
)}
428445
</Button>
446+
{state.cards.length > 0 && (
447+
<Button
448+
variant="outlined"
449+
color="secondary"
450+
className={classes.button}
451+
disabled={props.disabled || state.isLoading}
452+
onClick={handleSubmit}
453+
>
454+
Invoices
455+
{state.isLoading && (
456+
<Spinner size="sm" className={classes.spinner} />
457+
)}
458+
</Button>
459+
)}
429460
</Box>
430461
{state.cards.length === 0 && !state.isFetching ? (
431-
<p className={classes.emptyMethod}>No payment method available</p>
462+
<p className={classes.emptyMethod}>No payment methods available</p>
432463
) : (
433464
<>
434465
{state.cards.map(

ui/packages/shared/pages/CreateClone/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const CreateClone = observer((props: Props) => {
115115

116116
// Snapshots getting error.
117117
if (stores.main.snapshots.error)
118-
return <ErrorStub {...stores.main.snapshots.error} />
118+
return <ErrorStub message={stores.main.snapshots.error} />
119119

120120
const isCloneUnstable = Boolean(
121121
stores.main.clone && !stores.main.isCloneStable,

ui/packages/shared/pages/Instance/Info/Snapshots/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const Snapshots = observer(() => {
4545
!snapshots.data && !snapshots.error && <Spinner size="sm" />
4646
}
4747
>
48-
{snapshots.error && <ErrorStub {...snapshots.error} size="normal" />}
48+
{snapshots.error && <ErrorStub message={snapshots.error} size="normal" />}
4949

5050
{snapshots.data && !snapshots.error && (
5151
<>

ui/packages/shared/stores/Snapshots.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@
88
import { makeAutoObservable } from 'mobx'
99

1010
import { Snapshot } from '@postgres.ai/shared/types/api/entities/snapshot'
11-
import { getTextFromUnknownApiError } from '@postgres.ai/shared/utils/api'
1211
import { GetSnapshots } from '@postgres.ai/shared/types/api/endpoints/getSnapshots'
1312

1413
export type SnapshotsApi = {
1514
getSnapshots: GetSnapshots
1615
}
17-
18-
type Error = {
19-
title?: string
20-
message: string
21-
}
2216
export class SnapshotsStore {
2317
data: Snapshot[] | null = null
24-
error: Error | null = null
18+
error: string | null = null
2519
isLoading = false
2620

2721
private readonly api: SnapshotsApi
@@ -49,7 +43,11 @@ export class SnapshotsStore {
4943

5044
if (response) this.data = response
5145

52-
if (error) this.error = { message: await getTextFromUnknownApiError(error) }
46+
if (error) {
47+
this.error = await error
48+
.json()
49+
.then((error) => error.details?.split('"message": "')[1]?.split('"')[0])
50+
}
5351

5452
return !!response
5553
}

0 commit comments

Comments
 (0)