| | 1 | | @using MUNity.BlazorServer.Components.User.Profile |
| | 2 | | @using MUNity.Database.Models.User |
| | 3 | |
|
| | 4 | | @page "/profile/{UserName}" |
| | 5 | | @page "/profile/{UserName}/{Tab}" |
| | 6 | |
|
| | 7 | | @inject NavigationManager navManager |
| | 8 | | @inject UserManager<MunityUser> userManager; |
| | 9 | |
|
| 0 | 10 | | @if (user != null) |
| 0 | 11 | | { |
| | 12 | | <div class="profile"> |
| | 13 | | <div class="profile-header"> |
| | 14 | | <!-- BEGIN profile-header-cover --> |
| | 15 | | <div class="profile-header-cover"></div> |
| | 16 | | <!-- END profile-header-cover --> |
| | 17 | | <!-- BEGIN profile-header-content --> |
| | 18 | | <div class="profile-header-content"> |
| | 19 | | <!-- BEGIN profile-header-img --> |
| | 20 | | <div class="profile-header-img"> |
| | 21 | | <img src="/img/user/user-13.jpg" alt=""> |
| | 22 | | </div> |
| | 23 | | <!-- END profile-header-img --> |
| | 24 | | <!-- BEGIN profile-header-info --> |
| | 25 | | <div class="profile-header-info"> |
| 0 | 26 | | <h4 class="mt-0 mb-1">@((isMe) ? $"{user.Forename} {user.Lastname}" : user.GetDisplayNamePublic)</h4> |
| 0 | 27 | | <p class="mb-2">@@@user.UserName</p> |
| | 28 | | @*@if (isMe) |
| | 29 | | { |
| | 30 | | <a href="#" class="btn btn-xs btn-yellow">Edit Profile</a> |
| | 31 | | }*@ |
| | 32 | | </div> |
| | 33 | | <!-- END profile-header-info --> |
| | 34 | | </div> |
| | 35 | | <!-- END profile-header-content --> |
| | 36 | | <!-- BEGIN profile-header-tab --> |
| | 37 | | <ul class="profile-header-tab nav nav-tabs"> |
| 0 | 38 | | <li class="nav-item"><a class="nav-link cursor-pointer @((tab == Tabs.Posts) ? "active" : null)" @onclick="() => |
| 0 | 39 | | <li class="nav-item"><a class="nav-link cursor-pointer @((tab == Tabs.About) ? "active" : null)" @onclick="() => |
| | 40 | | @*<li class="nav-item"><a href="#profile-photos" class="nav-link" data-bs-toggle="tab">PHOTOS</a></li> |
| | 41 | | <li class="nav-item"><a href="#profile-videos" class="nav-link" data-bs-toggle="tab">VIDEOS</a></li> |
| | 42 | | <li class="nav-item"><a href="#profile-friends" class="nav-link" data-bs-toggle="tab">FRIENDS</a></li>*@ |
| | 43 | | </ul> |
| | 44 | | <!-- END profile-header-tab --> |
| | 45 | | </div> |
| | 46 | |
|
| | 47 | | <div class="profile-content"> |
| 0 | 48 | | @if (tab == Tabs.Posts) |
| 0 | 49 | | { |
| | 50 | | <PostHistoryComponent /> |
| 0 | 51 | | } |
| 0 | 52 | | else if (tab == Tabs.About) |
| 0 | 53 | | { |
| | 54 | | <AboutComponent UserName=@UserName IsMe=@isMe /> |
| 0 | 55 | | } |
| | 56 | | </div> |
| | 57 | | </div> |
| 0 | 58 | | } |
| | 59 | | else |
| 0 | 60 | | { |
| | 61 | | <p>Hoppla! Benutzer wurde nicht gefunden.</p> |
| 0 | 62 | | } |
| | 63 | |
|
| | 64 | | @code { |
| 0 | 65 | | [Parameter] public string UserName { get; set; } |
| | 66 | |
|
| 0 | 67 | | [Parameter] public string Tab { get; set; } |
| | 68 | |
|
| 0 | 69 | | [CascadingParameter] public Task<AuthenticationState> AuthStateTask { get; set; } |
| | 70 | |
|
| | 71 | | private enum Tabs |
| | 72 | | { |
| | 73 | | Posts, |
| | 74 | | About |
| | 75 | | } |
| | 76 | |
|
| 0 | 77 | | private Tabs tab = Tabs.Posts; |
| | 78 | |
|
| | 79 | | private MunityUser user; |
| | 80 | |
|
| | 81 | | private bool isMe; |
| | 82 | |
|
| | 83 | | protected override async Task OnParametersSetAsync() |
| 0 | 84 | | { |
| 0 | 85 | | await base.OnParametersSetAsync(); |
| 0 | 86 | | user = await userManager.FindByNameAsync(UserName); |
| 0 | 87 | | var claim = (await AuthStateTask)?.User; |
| 0 | 88 | | if (claim != null) |
| 0 | 89 | | { |
| 0 | 90 | | var signedInUser = await userManager.GetUserAsync(claim); |
| 0 | 91 | | if (signedInUser != null) |
| 0 | 92 | | isMe = signedInUser.Id == user.Id; |
| | 93 | | else |
| 0 | 94 | | isMe = false; |
| 0 | 95 | | } |
| | 96 | |
|
| | 97 | |
|
| 0 | 98 | | OpenTabByNameIfGiven(); |
| 0 | 99 | | } |
| | 100 | |
|
| | 101 | | private void OpenTabByNameIfGiven() |
| 0 | 102 | | { |
| 0 | 103 | | if (Tab != null) |
| 0 | 104 | | { |
| 0 | 105 | | var tabText = Tab.ToLower(); |
| 0 | 106 | | if (tabText == "posts") |
| 0 | 107 | | tab = Tabs.Posts; |
| 0 | 108 | | else if (tabText == "about") |
| 0 | 109 | | tab = Tabs.About; |
| | 110 | |
|
| 0 | 111 | | } |
| 0 | 112 | | } |
| | 113 | | } |