@@ -7,6 +7,16 @@ import { Alert, Text, TextInput, TouchableOpacity, View } from 'react-native';
7
7
import defaultStyles from './FeedbackForm.styles' ;
8
8
import type { FeedbackFormProps , FeedbackFormState } from './FeedbackForm.types' ;
9
9
10
+ const defaultFormTitle = 'Feedback Form' ;
11
+ const defaultNamePlaceholder = 'Name' ;
12
+ const defaultEmailPlaceholder = 'Email' ;
13
+ const defaultDescriptionPlaceholder = 'Description (required)' ;
14
+ const defaultSubmitButton = 'Send Feedback' ;
15
+ const defaultCancelButton = 'Cancel' ;
16
+ const defaultErrorTitle = 'Error' ;
17
+ const defaultFormError = 'Please fill out all required fields.' ;
18
+ const defaultEmailError = 'Please enter a valid email address.' ;
19
+
10
20
/**
11
21
* @beta
12
22
* Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback.
@@ -30,14 +40,14 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
30
40
const trimmedDescription = description ?. trim ( ) ;
31
41
32
42
if ( ! trimmedName || ! trimmedEmail || ! trimmedDescription ) {
33
- const errorMessage = text ?. formError || 'Please fill out all required fields.' ;
34
- Alert . alert ( text ?. errorTitle || 'Error' , errorMessage ) ;
43
+ const errorMessage = text ?. formError || defaultFormError ;
44
+ Alert . alert ( text ?. errorTitle || defaultErrorTitle , errorMessage ) ;
35
45
return ;
36
46
}
37
47
38
48
if ( ! this . _isValidEmail ( trimmedEmail ) ) {
39
- const errorMessage = text ?. emailError || 'Please enter a valid email address.' ;
40
- Alert . alert ( text ?. errorTitle || 'Error' , errorMessage ) ;
49
+ const errorMessage = text ?. emailError || defaultEmailError ;
50
+ Alert . alert ( text ?. errorTitle || defaultErrorTitle , errorMessage ) ;
41
51
return ;
42
52
}
43
53
@@ -60,37 +70,37 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
60
70
61
71
return (
62
72
< View style = { styles ?. container || defaultStyles . container } >
63
- < Text style = { styles ?. title || defaultStyles . title } > { text ?. formTitle || 'Feedback Form' } </ Text >
73
+ < Text style = { styles ?. title || defaultStyles . title } > { text ?. formTitle || defaultFormTitle } </ Text >
64
74
65
75
< TextInput
66
76
style = { styles ?. input || defaultStyles . input }
67
- placeholder = { text ?. namePlaceholder || 'Name' }
77
+ placeholder = { text ?. namePlaceholder || defaultNamePlaceholder }
68
78
value = { name }
69
79
onChangeText = { ( value ) => this . setState ( { name : value } ) }
70
80
/>
71
81
72
82
< TextInput
73
83
style = { styles ?. input || defaultStyles . input }
74
- placeholder = { text ?. emailPlaceholder || 'Email' }
84
+ placeholder = { text ?. emailPlaceholder || defaultEmailPlaceholder }
75
85
keyboardType = { 'email-address' as KeyboardTypeOptions }
76
86
value = { email }
77
87
onChangeText = { ( value ) => this . setState ( { email : value } ) }
78
88
/>
79
89
80
90
< TextInput
81
91
style = { [ styles ?. input || defaultStyles . input , styles ?. textArea || defaultStyles . textArea ] }
82
- placeholder = { text ?. descriptionPlaceholder || 'Description (required)' }
92
+ placeholder = { text ?. descriptionPlaceholder || defaultDescriptionPlaceholder }
83
93
value = { description }
84
94
onChangeText = { ( value ) => this . setState ( { description : value } ) }
85
95
multiline
86
96
/>
87
97
88
98
< TouchableOpacity style = { styles ?. submitButton || defaultStyles . submitButton } onPress = { this . handleFeedbackSubmit } >
89
- < Text style = { styles ?. submitText || defaultStyles . submitText } > { text ?. submitButton || 'Send Feedback' } </ Text >
99
+ < Text style = { styles ?. submitText || defaultStyles . submitText } > { text ?. submitButton || defaultSubmitButton } </ Text >
90
100
</ TouchableOpacity >
91
101
92
102
< TouchableOpacity style = { styles ?. cancelButton || defaultStyles . cancelButton } onPress = { closeScreen } >
93
- < Text style = { styles ?. cancelText || defaultStyles . cancelText } > { text ?. cancelButton || 'Cancel' } </ Text >
103
+ < Text style = { styles ?. cancelText || defaultStyles . cancelText } > { text ?. cancelButton || defaultCancelButton } </ Text >
94
104
</ TouchableOpacity >
95
105
</ View >
96
106
) ;
0 commit comments