| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   import UserDetails, { OsmConnection } from "../../Logic/Osm/OsmConnection" | 
					
						
							|  |  |  |   import { UIEventSource } from "../../Logic/UIEventSource" | 
					
						
							|  |  |  |   import { PencilAltIcon, UserCircleIcon } from "@rgossiaux/svelte-heroicons/solid" | 
					
						
							|  |  |  |   import { onDestroy } from "svelte" | 
					
						
							|  |  |  |   import Showdown from "showdown" | 
					
						
							|  |  |  |   import FromHtml from "../Base/FromHtml.svelte" | 
					
						
							|  |  |  |   import Tr from "../Base/Tr.svelte" | 
					
						
							|  |  |  |   import Translations from "../i18n/Translations.js" | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * This panel shows information about the logged-in user, showing account name, profile pick, description and an edit-button | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |   export let osmConnection: OsmConnection | 
					
						
							|  |  |  |   let userdetails: UIEventSource<UserDetails> = osmConnection.userDetails | 
					
						
							|  |  |  |   let description: string | 
					
						
							|  |  |  |   onDestroy( | 
					
						
							|  |  |  |     userdetails.addCallbackAndRunD((userdetails) => { | 
					
						
							|  |  |  |       description = new Showdown.Converter() | 
					
						
							|  |  |  |         .makeHtml(userdetails.description) | 
					
						
							|  |  |  |         ?.replace(/>/g, ">") | 
					
						
							|  |  |  |         ?.replace(/</g, "<") | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |   ) | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 20:44:01 +02:00
										 |  |  | <div class="link-underline m-1 flex rounded-md border border-dashed border-gray-600 p-1"> | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  |   {#if $userdetails.img} | 
					
						
							| 
									
										
										
										
											2023-06-14 20:44:01 +02:00
										 |  |  |     <img src={$userdetails.img} class="m-4 h-12 w-12 rounded-full" /> | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  |   {:else} | 
					
						
							| 
									
										
										
										
											2023-06-14 20:44:01 +02:00
										 |  |  |     <UserCircleIcon class="h-12 w-12" /> | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  |   {/if} | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |   <div class="flex flex-col"> | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  |     <h3>{$userdetails.name}</h3> | 
					
						
							|  |  |  |     {#if description} | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |       <FromHtml src={description} /> | 
					
						
							|  |  |  |       <a | 
					
						
							|  |  |  |         href={osmConnection.Backend() + "/profile/edit"} | 
					
						
							|  |  |  |         target="_blank" | 
					
						
							|  |  |  |         class="link-no-underline flex items-center self-end" | 
					
						
							|  |  |  |       > | 
					
						
							| 
									
										
										
										
											2023-06-14 20:44:01 +02:00
										 |  |  |         <PencilAltIcon slot="image" class="h-8 w-8 p-2" /> | 
					
						
							| 
									
										
										
										
											2023-05-07 23:19:30 +02:00
										 |  |  |         <Tr slot="message" t={Translations.t.userinfo.editDescription} /> | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  |       </a> | 
					
						
							|  |  |  |     {:else} | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  |       <Tr t={Translations.t.userinfo.noDescription} /> | 
					
						
							| 
									
										
										
										
											2023-05-14 03:24:13 +02:00
										 |  |  |       <a href={osmConnection.Backend() + "/profile/edit"} target="_blank" class="flex items-center"> | 
					
						
							| 
									
										
										
										
											2023-06-14 20:44:01 +02:00
										 |  |  |         <PencilAltIcon slot="image" class="h-8 w-8 p-2" /> | 
					
						
							| 
									
										
										
										
											2023-04-07 02:13:57 +02:00
										 |  |  |         <Tr slot="message" t={Translations.t.userinfo.noDescriptionCallToAction} /> | 
					
						
							|  |  |  |       </a> | 
					
						
							|  |  |  |     {/if} | 
					
						
							|  |  |  |   </div> | 
					
						
							|  |  |  | </div> |