@@ -22,6 +22,37 @@ import { RadioGroupProvider } from "../../radio-group-provider";
22
22
23
23
export type FormValues = z . infer < typeof addProviderFormSchema > ;
24
24
25
+ // Helper function for labels and placeholders
26
+ const getProviderFieldDetails = ( providerType ?: string ) => {
27
+ switch ( providerType ) {
28
+ case "aws" :
29
+ return {
30
+ label : "Account ID" ,
31
+ placeholder : "123456..." ,
32
+ } ;
33
+ case "gcp" :
34
+ return {
35
+ label : "Project ID" ,
36
+ placeholder : "project_id..." ,
37
+ } ;
38
+ case "azure" :
39
+ return {
40
+ label : "Subscription ID" ,
41
+ placeholder : "fc94207a-d396-4a14-a7fd-12a..." ,
42
+ } ;
43
+ case "kubernetes" :
44
+ return {
45
+ label : "Kubernetes Context" ,
46
+ placeholder : "context_name...." ,
47
+ } ;
48
+ default :
49
+ return {
50
+ label : "Provider UID" ,
51
+ placeholder : "Enter the provider UID" ,
52
+ } ;
53
+ }
54
+ } ;
55
+
25
56
export const ConnectAccountForm = ( ) => {
26
57
const { toast } = useToast ( ) ;
27
58
const [ prevStep , setPrevStep ] = useState ( 1 ) ;
@@ -39,6 +70,8 @@ export const ConnectAccountForm = () => {
39
70
} ) ;
40
71
41
72
const providerType = form . watch ( "providerType" ) ;
73
+ const providerFieldDetails = getProviderFieldDetails ( providerType ) ;
74
+
42
75
const isLoading = form . formState . isSubmitting ;
43
76
44
77
const onSubmitClient = async ( values : FormValues ) => {
@@ -107,7 +140,12 @@ export const ConnectAccountForm = () => {
107
140
}
108
141
} ;
109
142
110
- const handleBackStep = ( ) => setPrevStep ( ( prev ) => prev - 1 ) ;
143
+ const handleBackStep = ( ) => {
144
+ setPrevStep ( ( prev ) => prev - 1 ) ;
145
+ // Reset the providerUid and providerAlias fields when going back
146
+ form . setValue ( "providerUid" , "" ) ;
147
+ form . setValue ( "providerAlias" , "" ) ;
148
+ } ;
111
149
112
150
useEffect ( ( ) => {
113
151
if ( providerType ) {
@@ -144,9 +182,9 @@ export const ConnectAccountForm = () => {
144
182
control = { form . control }
145
183
name = "providerUid"
146
184
type = "text"
147
- label = "Provider UID"
185
+ label = { providerFieldDetails . label }
148
186
labelPlacement = "inside"
149
- placeholder = "Enter the provider UID"
187
+ placeholder = { providerFieldDetails . placeholder }
150
188
variant = "bordered"
151
189
isRequired
152
190
isInvalid = { ! ! form . formState . errors . providerUid }
0 commit comments