File tree 1 file changed +45
-11
lines changed
force-app/main/default/lwc/courseRegistrationForm
1 file changed +45
-11
lines changed Original file line number Diff line number Diff line change @@ -124,19 +124,53 @@ export default class CourseRegistrationForm extends NavigationMixin(LightningEle
124
124
125
125
handleSubmit ( event ) {
126
126
event . preventDefault ( ) ;
127
- if ( this . theRecord . firstName && this . theRecord . lastName && this . theRecord . email && this . theRecord . phone ) {
128
- let output = JSON . stringify ( this . theRecord , null ) ;
129
- createRegistration ( {
130
- fields : output ,
131
- courseId : this . courseId
132
- } ) . then ( ( result ) => {
133
- this . showForm = false ;
134
- this . showConfirmation = true ;
135
- this . message = result ;
136
- } ) ;
137
- } else {
127
+
128
+ // Basis felter som alltid vises
129
+ if ( ! this . theRecord . firstName || ! this . theRecord . lastName || ! this . theRecord . email || ! this . theRecord . phone ) {
130
+ this . showError = true ;
131
+ return ;
132
+ }
133
+
134
+ // Tillegs felter sjekk om de er satt
135
+ if ( this . companyName && ! this . theRecord . companyName ) {
136
+ this . showError = true ;
137
+ return ;
138
+ }
139
+ if ( this . county && ! this . theRecord . county ) {
140
+ this . showError = true ;
141
+ return ;
142
+ }
143
+ if ( this . role && ! this . theRecord . role ) {
138
144
this . showError = true ;
145
+ return ;
139
146
}
147
+ if ( this . allergies && ! this . theRecord . allergies ) {
148
+ this . showError = true ;
149
+ return ;
150
+ }
151
+ if ( this . invoiceAdress && ! this . theRecord . invoiceAdress ) {
152
+ this . showError = true ;
153
+ return ;
154
+ }
155
+ if ( this . invoiceReference && ! this . theRecord . invoiceReference ) {
156
+ this . showError = true ;
157
+ return ;
158
+ }
159
+ if ( this . workplace && ! this . theRecord . workplace ) {
160
+ this . showError = true ;
161
+ return ;
162
+ }
163
+
164
+ // Alle sjekker er passert om vi kommer hit
165
+ let output = JSON . stringify ( this . theRecord , null ) ;
166
+ createRegistration ( {
167
+ fields : output ,
168
+ courseId : this . courseId
169
+ } ) . then ( ( result ) => {
170
+ this . showForm = false ;
171
+ this . showConfirmation = true ;
172
+ this . message = result ;
173
+ } ) ;
140
174
}
141
175
142
176
validateCode ( event ) {
You can’t perform that action at this time.
0 commit comments