11import { createStyles , Grid , makeStyles } from '@material-ui/core' ;
2+ import { Alert } from '@material-ui/lab' ;
23import { Button , LoadingPage , theme } from '@weaveworks/weave-gitops' ;
34import React , { FC } from 'react' ;
45import { validateFormData } from '../../../../utils/form' ;
56
67const CostEstimation : FC < {
78 costEstimate : string ;
89 isCostEstimationLoading : boolean ;
10+ costEstimateMessage : string ;
911 handleCostEstimation : ( ) => Promise < void > ;
10- } > = ( { handleCostEstimation, costEstimate, isCostEstimationLoading } ) => {
12+ } > = ( {
13+ handleCostEstimation,
14+ costEstimate,
15+ isCostEstimationLoading,
16+ costEstimateMessage,
17+ } ) => {
1118 const useStyles = makeStyles ( ( ) =>
1219 createStyles ( {
1320 getEstimationButton : {
@@ -20,54 +27,66 @@ const CostEstimation: FC<{
2027 previewLoading : {
2128 padding : theme . spacing . base ,
2229 } ,
30+ errorMessage : {
31+ marginTop : theme . spacing . xs ,
32+ marginRight : theme . spacing . medium ,
33+ borderRadius : theme . spacing . xxs ,
34+ } ,
2335 } ) ,
2436 ) ;
2537 const classes = useStyles ( ) ;
26- return isCostEstimationLoading ? (
27- < LoadingPage className = { classes . previewLoading } />
28- ) : (
29- < div >
38+ return (
39+ < >
3040 < h2 > Cost Estimation</ h2 >
31- < Grid container >
32- < Grid item xs = { 6 } sm = { 6 } md = { 6 } lg = { 6 } >
33- < Grid container >
34- < Grid
35- item
36- xs = { 6 }
37- justifyContent = "flex-start"
38- alignItems = "center"
39- container
40- >
41- < div > Monthly Cost:</ div >
42- </ Grid >
43- < Grid
44- item
45- xs = { 6 }
46- justifyContent = "flex-end"
47- alignItems = "center"
48- container
49- >
50- < div className = { classes . costWrapper } > { costEstimate } </ div >
41+ { isCostEstimationLoading ? (
42+ < LoadingPage className = { classes . previewLoading } />
43+ ) : (
44+ < Grid alignItems = "center" container >
45+ < Grid item xs = { 6 } sm = { 6 } md = { 6 } lg = { 6 } >
46+ < Grid container >
47+ < Grid
48+ item
49+ xs = { 6 }
50+ justifyContent = "flex-start"
51+ alignItems = "center"
52+ container
53+ >
54+ < div > Monthly Cost:</ div >
55+ </ Grid >
56+ < Grid
57+ item
58+ xs = { 6 }
59+ justifyContent = "flex-end"
60+ alignItems = "center"
61+ container
62+ >
63+ < div className = { classes . costWrapper } > { costEstimate } </ div >
64+ </ Grid >
5165 </ Grid >
5266 </ Grid >
53- </ Grid >
54- < Grid
55- item
56- xs = { 6 }
57- justifyContent = "flex-end"
58- alignItems = "center"
59- container
60- >
61- < Button
62- id = "get-estimation"
63- className = { classes . getEstimationButton }
64- onClick = { event => validateFormData ( event , handleCostEstimation ) }
67+ < Grid
68+ item
69+ xs = { 6 }
70+ justifyContent = "flex-end"
71+ alignItems = "center"
72+ container
6573 >
66- GET ESTIMATION
67- </ Button >
74+ < Button
75+ id = "get-estimation"
76+ className = { classes . getEstimationButton }
77+ onClick = { event => validateFormData ( event , handleCostEstimation ) }
78+ >
79+ GET ESTIMATION
80+ </ Button >
81+ </ Grid >
82+ { costEstimateMessage && (
83+ < Alert className = { classes . errorMessage } severity = "warning" >
84+ { costEstimateMessage }
85+ </ Alert >
86+ ) }
6887 </ Grid >
69- </ Grid >
70- </ div >
88+ ) }
89+ </ >
7190 ) ;
7291} ;
7392
0 commit comments