@@ -12,20 +12,26 @@ import { createToken, getTokenConfig } from "api/api"
12
12
import { CreateTokenForm } from "./CreateTokenForm"
13
13
import { NANO_HOUR , CreateTokenData } from "./utils"
14
14
import { AlertBanner } from "components/AlertBanner/AlertBanner"
15
+ import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog"
16
+ import { CodeExample } from "components/CodeExample/CodeExample"
17
+ import { makeStyles } from "@material-ui/core/styles"
15
18
16
19
const initialValues : CreateTokenData = {
17
20
name : "" ,
18
21
lifetime : 30 ,
19
22
}
20
23
21
- const CreateTokenPage : FC = ( ) => {
24
+ export const CreateTokenPage : FC = ( ) => {
22
25
const { t } = useTranslation ( "tokensPage" )
26
+ const styles = useStyles ( )
23
27
const navigate = useNavigate ( )
24
28
25
29
const {
26
30
mutate : saveToken ,
27
31
isLoading : isCreating ,
28
32
isError : creationFailed ,
33
+ isSuccess : creationSuccessful ,
34
+ data : newToken ,
29
35
} = useMutation ( createToken )
30
36
const {
31
37
data : tokenConfig ,
@@ -60,12 +66,18 @@ const CreateTokenPage: FC = () => {
60
66
} ,
61
67
{
62
68
onError : onCreateError ,
63
- onSuccess : onCreateSuccess ,
64
69
} ,
65
70
)
66
71
} ,
67
72
} )
68
73
74
+ const tokenDescription = (
75
+ < >
76
+ < p > { t ( "createToken.successModal.description" ) } </ p >
77
+ < CodeExample code = { newToken ?. key ?? "" } className = { styles . codeExample } />
78
+ </ >
79
+ )
80
+
69
81
if ( fetchingTokenConfig ) {
70
82
return < Loader />
71
83
}
@@ -90,9 +102,29 @@ const CreateTokenPage: FC = () => {
90
102
isCreating = { isCreating }
91
103
creationFailed = { creationFailed }
92
104
/>
105
+
106
+ < ConfirmDialog
107
+ type = "info"
108
+ hideCancel
109
+ title = { t ( "createToken.successModal.title" ) }
110
+ description = { tokenDescription }
111
+ open = { creationSuccessful && Boolean ( newToken . key ) }
112
+ confirmLoading = { isCreating }
113
+ onConfirm = { onCreateSuccess }
114
+ onClose = { onCreateSuccess }
115
+ />
93
116
</ FullPageHorizontalForm >
94
117
</ >
95
118
)
96
119
}
97
120
121
+ const useStyles = makeStyles ( ( theme ) => ( {
122
+ codeExample : {
123
+ minHeight : "auto" ,
124
+ userSelect : "all" ,
125
+ width : "100%" ,
126
+ marginTop : theme . spacing ( 3 ) ,
127
+ } ,
128
+ } ) )
129
+
98
130
export default CreateTokenPage
0 commit comments