1
1
import React , { useEffect } from "react" ;
2
2
import ConsolePageTitle from "../../components/ConsolePageTitle" ;
3
- import Table from '@mui/material/Table' ;
4
- import TableBody from '@mui/material/TableBody' ;
5
- import TableCell from '@mui/material/TableCell' ;
6
- import TableContainer from '@mui/material/TableContainer' ;
7
- import TableHead from '@mui/material/TableHead' ;
8
- import TableRow from '@mui/material/TableRow' ;
9
- import { Grid , Paper , Typography } from "@mui/material" ;
3
+ import Alert from "@mui/material/Alert" ;
4
+ import { Grid , Typography } from "@mui/material" ;
10
5
import Button from "@mui/material/Button" ;
11
6
import Box from "@mui/material/Box/Box" ;
12
7
import { observer } from "mobx-react-lite" ;
@@ -16,11 +11,9 @@ import { makeStyles } from "@material-ui/core";
16
11
import { PageSpinner } from "@postgres.ai/shared/components/PageSpinner" ;
17
12
import { ProductCardWrapper } from "../../components/ProductCard/ProductCardWrapper" ;
18
13
import { Link } from "@postgres.ai/shared/components/Link2" ;
19
- import Permissions from "../../utils/permissions" ;
20
- import { WarningWrapper } from "../../components/Warning/WarningWrapper" ;
21
- import { messages } from "../../assets/messages" ;
22
14
import { ConsoleBreadcrumbsWrapper } from "../../components/ConsoleBreadcrumbs/ConsoleBreadcrumbsWrapper" ;
23
15
import { formatPostgresInterval } from "./utils" ;
16
+ import { TransactionsTable } from "./TransactionsTable/TransactionsTable" ;
24
17
25
18
26
19
@@ -88,16 +81,6 @@ export const Consulting = observer((props: ConsultingWrapperProps) => {
88
81
)
89
82
}
90
83
91
- if ( orgData === null || ! Permissions . isAdmin ( orgData ) ) {
92
- return (
93
- < Box >
94
- { breadcrumbs }
95
- < ConsolePageTitle title = { "Consulting" } />
96
- < WarningWrapper > { messages . noPermissionPage } </ WarningWrapper >
97
- </ Box >
98
- )
99
- }
100
-
101
84
if ( orgData . consulting_type === null ) {
102
85
return (
103
86
< Box >
@@ -132,19 +115,11 @@ export const Consulting = observer((props: ConsultingWrapperProps) => {
132
115
{ breadcrumbs }
133
116
< ConsolePageTitle title = { "Consulting" } />
134
117
< Grid container spacing = { 3 } >
135
- { orgData . consulting_type === 'retainer' && < Grid item xs = { 12 } md = { 8 } >
136
- < Typography variant = "h6" classes = { { root : classes . sectionLabel } } >
137
- Retainer balance:
138
- </ Typography >
139
- < Typography variant = "h5" sx = { { marginTop : 1 } } >
140
- { formatPostgresInterval ( consultingStore . orgBalance ?. [ 0 ] ?. balance || '00' ) || 0 }
141
- </ Typography >
142
- </ Grid > }
143
118
< Grid item xs = { 12 } md = { 8 } >
144
119
< Box >
145
- < Button variant = "contained" component = "a" href = "https://buy.stripe.com/7sI5odeXt3tB0Eg3cm" target = "_blank" >
146
- Replenish consulting hours
147
- </ Button >
120
+ < Typography variant = "body1" sx = { { fontSize : 14 } } >
121
+ Thank you for choosing Postgres.AI as your PostgreSQL consulting partner. Your plan: { orgData . consulting_type . toUpperCase ( ) } .
122
+ </ Typography >
148
123
</ Box >
149
124
</ Grid >
150
125
< Grid item xs = { 12 } md = { 8 } >
@@ -172,6 +147,37 @@ export const Consulting = observer((props: ConsultingWrapperProps) => {
172
147
</ Box >
173
148
</ Grid >
174
149
< Grid item xs = { 12 } md = { 8 } >
150
+ < Box >
151
+ < Typography variant = "h6" classes = { { root : classes . sectionLabel } } >
152
+ Email:
153
+ </ Typography >
154
+ < Typography variant = "body1" sx = { { marginTop : 1 , fontSize : 14 } } >
155
+ < Link to = { `mailto:[email protected] ` } external target = "_blank" >
156
+
157
+ </ Link >
158
+ </ Typography >
159
+ </ Box >
160
+ </ Grid >
161
+ { consultingStore . orgBalance ?. [ 0 ] ?. balance ?. charAt ( 0 ) === '-' && < Grid item xs = { 12 } md = { 8 } >
162
+ < Alert severity = "warning" > Consulting hours overdrawn</ Alert >
163
+ </ Grid > }
164
+ { orgData . consulting_type === 'retainer' && < Grid item xs = { 12 } md = { 8 } >
165
+ < Typography variant = "h6" classes = { { root : classes . sectionLabel } } >
166
+ Retainer balance:
167
+ </ Typography >
168
+ < Typography variant = "h5" sx = { { marginTop : 1 } } >
169
+ { formatPostgresInterval ( consultingStore . orgBalance ?. [ 0 ] ?. balance || '00' ) || 0 }
170
+ </ Typography >
171
+ </ Grid > }
172
+ { orgData . consulting_type === 'retainer' && < Grid item xs = { 12 } md = { 8 } >
173
+ < Box >
174
+ < Button variant = "contained" component = "a" href = "https://buy.stripe.com/7sI5odeXt3tB0Eg3cm" target = "_blank" >
175
+ Replenish consulting hours
176
+ </ Button >
177
+ </ Box >
178
+ </ Grid > }
179
+
180
+ { orgData . consulting_type === 'retainer' && < Grid item xs = { 12 } md = { 8 } >
175
181
< Typography variant = "h6" classes = { { root : classes . sectionLabel } } >
176
182
Activity:
177
183
</ Typography >
@@ -180,44 +186,11 @@ export const Consulting = observer((props: ConsultingWrapperProps) => {
180
186
? < Typography variant = "body1" sx = { { marginTop : 1 } } >
181
187
No activity yet
182
188
</ Typography >
183
- : < TableContainer component = { Paper } sx = { { marginTop : 1 } } >
184
- < Table >
185
- < TableHead >
186
- < TableRow >
187
- < TableCell > Action</ TableCell >
188
- < TableCell > Amount</ TableCell >
189
- < TableCell > Date</ TableCell >
190
- < TableCell > Details</ TableCell >
191
- </ TableRow >
192
- </ TableHead >
193
- < TableBody >
194
- {
195
- consultingStore . transactions . map ( ( transaction , index ) => {
196
- return (
197
- < TableRow key = { index } >
198
- < TableCell sx = { { whiteSpace : 'nowrap' } } > { transaction . amount . charAt ( 0 ) === '-' ? 'Utilize' : 'Replenish' } </ TableCell >
199
- < TableCell sx = { { color : transaction . amount . charAt ( 0 ) === '-' ? 'red' : 'green' , whiteSpace : 'nowrap' } } >
200
- { formatPostgresInterval ( transaction . amount || '00' ) }
201
- </ TableCell >
202
- < TableCell sx = { { whiteSpace : 'nowrap' } } > { new Date ( transaction . created_at ) ?. toISOString ( ) ?. split ( 'T' ) ?. [ 0 ] } </ TableCell >
203
- < TableCell >
204
- { transaction . issue_id
205
- ? < Link external to = { `https://gitlab.com/postgres-ai/postgresql-consulting/support/${ orgData . alias } /-/issues/${ transaction . issue_id } ` } target = "_blank" >
206
- { transaction . description }
207
- </ Link >
208
- : transaction . description
209
- }
210
- </ TableCell >
211
- </ TableRow >
212
- ) ;
213
- } )
214
- }
215
- </ TableBody >
216
- </ Table >
217
- </ TableContainer >
189
+ : < TransactionsTable transactions = { consultingStore . transactions } alias = { orgData . alias } />
218
190
}
219
- </ Grid >
191
+ </ Grid > }
220
192
</ Grid >
221
193
</ div >
222
194
) ;
223
- } ) ;
195
+ } ) ;
196
+
0 commit comments