| 
									
										
										
										
											2021-01-04 04:06:21 +01:00
										 |  |  | import Locale from "../i18n/Locale"; | 
					
						
							|  |  |  | import {UIElement} from "../UIElement"; | 
					
						
							|  |  |  | import State from "../../State"; | 
					
						
							|  |  |  | import Combine from "../Base/Combine"; | 
					
						
							|  |  |  | import LanguagePicker from "../LanguagePicker"; | 
					
						
							|  |  |  | import Translations from "../i18n/Translations"; | 
					
						
							| 
									
										
										
										
											2020-08-17 17:23:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-04 04:06:21 +01:00
										 |  |  | export default class WelcomeMessage extends UIElement { | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |     private languagePicker: UIElement; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private readonly description: UIElement; | 
					
						
							|  |  |  |     private readonly plzLogIn: UIElement; | 
					
						
							|  |  |  |     private readonly welcomeBack: UIElement; | 
					
						
							|  |  |  |     private readonly tail: UIElement; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor() { | 
					
						
							|  |  |  |         super(State.state.osmConnection.userDetails); | 
					
						
							|  |  |  |         this.ListenTo(Locale.language); | 
					
						
							| 
									
										
										
										
											2020-11-11 16:23:49 +01:00
										 |  |  |         this.languagePicker = LanguagePicker.CreateLanguagePicker(State.state.layoutToUse.data.language, Translations.t.general.pickLanguage); | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  |         const layout = State.state.layoutToUse.data; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-11 16:23:49 +01:00
										 |  |  |         this.description = new Combine([ | 
					
						
							|  |  |  |             "<h3>", layout.title, "</h3>", | 
					
						
							|  |  |  |             layout.description | 
					
						
							|  |  |  |         ]) | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  |         this.plzLogIn = | 
					
						
							| 
									
										
										
										
											2020-11-11 16:23:49 +01:00
										 |  |  |             Translations.t.general.loginWithOpenStreetMap | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  |                 .onClick(() => { | 
					
						
							|  |  |  |                     State.state.osmConnection.AttemptLogin() | 
					
						
							|  |  |  |                 }); | 
					
						
							| 
									
										
										
										
											2020-11-11 16:23:49 +01:00
										 |  |  |         this.welcomeBack = Translations.t.general.welcomeBack; | 
					
						
							|  |  |  |         this.tail = layout.descriptionTail; | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |     InnerRender(): string { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |         let loginStatus = undefined; | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |         if (State.state.featureSwitchUserbadge.data) { | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |             loginStatus = (State.state.osmConnection.userDetails.data.loggedIn ? this.welcomeBack :  | 
					
						
							|  |  |  |                 this.plzLogIn); | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |         return new Combine([ | 
					
						
							|  |  |  |             this.description, | 
					
						
							| 
									
										
										
										
											2020-09-05 15:27:35 +02:00
										 |  |  |             "<br/><br/>", | 
					
						
							| 
									
										
										
										
											2020-09-03 16:44:48 +02:00
										 |  |  |             loginStatus, | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |             this.tail, | 
					
						
							|  |  |  |             "<br/>", | 
					
						
							| 
									
										
										
										
											2020-12-14 01:14:22 +01:00
										 |  |  |             this.languagePicker | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |         ]).Render() | 
					
						
							| 
									
										
										
										
											2020-07-31 01:45:54 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-24 14:36:43 +01:00
										 |  |  | } |