|
34 | 34 | </MudItem> |
35 | 35 | @* Location Section *@ |
36 | 36 | <MudItem xs="12"> |
37 | | - <MudText Typo="Typo.h6" Class="mb-2">Lokation</MudText> |
38 | | - </MudItem> |
39 | | - |
40 | | - <MudItem xs="12" md="8" lg="6"> |
41 | | - @if (_useZipCodeOnly) |
42 | | - { |
43 | | - <ZipCodeAutoComplete Location="@_zipCodeLocation" LocationChanged="OnZipCodeLocationChanged" |
44 | | - For="() => _zipCodeLocation" DisableSmartCompletion="true" /> |
45 | | - } |
46 | | - else |
47 | | - { |
48 | | - <AddressAutoComplete Address="@_addressLocation" AddressChanged="OnAddressLocationChanged" |
49 | | - For="() => _addressLocation" /> |
50 | | - } |
51 | | - </MudItem> |
52 | | - |
53 | | - <MudItem xs="12" md="4" lg="6" Class="d-flex align-center text-center justify-content-center"> |
54 | | - <MudTooltip Text="Klik for at skifte mellem fuld adresse og kun postnummer."> |
55 | | - <MudChip T="string" Size="Size.Large" Color="@(_useZipCodeOnly? Color.Default: Color.Info)" |
56 | | - Variant="Variant.Outlined" OnClick="@ToggleLocationMode" Style="cursor: pointer;"> |
57 | | - @if (_useZipCodeOnly) |
58 | | - { |
59 | | - <MudIcon Icon="@Icons.Material.Filled.Lock" Size="Size.Small" Class="mr-1" /> |
60 | | - <span>Kun postnummer</span> |
61 | | - } |
62 | | - else |
63 | | - { |
64 | | - <MudIcon Icon="@Icons.Material.Filled.LocationOn" Size="Size.Small" Class="mr-1" /> |
65 | | - <span>Fuld adresse</span> |
66 | | - } |
67 | | - </MudChip> |
68 | | - </MudTooltip> |
69 | | - </MudItem> |
70 | | - |
71 | | - <MudItem xs="12"> |
72 | | - <MudAlert Severity="Severity.Info" Variant="Variant.Text" Dense Class="pa-3"> |
73 | | - Gruppens lokation hjælper andre med at finde grupper i deres område. |
74 | | - </MudAlert> |
| 37 | + <div class="d-flex align-center gap-3 mb-3"> |
| 38 | + <MudText Typo="Typo.h6"> |
| 39 | + Lokation <span style="color: var(--mud-palette-error);">*</span> |
| 40 | + </MudText> |
| 41 | + <MudTooltip Text="Klik for at skifte mellem fuld adresse og kun postnummer."> |
| 42 | + <MudChip T="string" Size="Size.Small" Color="@(_useZipCodeOnly ? Color.Default : Color.Info)" |
| 43 | + Variant="Variant.Outlined" OnClick="@ToggleLocationMode" Style="cursor: pointer;"> |
| 44 | + @if (_useZipCodeOnly) |
| 45 | + { |
| 46 | + <MudIcon Icon="@Icons.Material.Filled.Lock" Size="Size.Small" Class="mr-1" /> |
| 47 | + <span>Kun postnummer</span> |
| 48 | + } |
| 49 | + else |
| 50 | + { |
| 51 | + <MudIcon Icon="@Icons.Material.Filled.LocationOn" Size="Size.Small" Class="mr-1" /> |
| 52 | + <span>Fuld adresse</span> |
| 53 | + } |
| 54 | + </MudChip> |
| 55 | + </MudTooltip> |
| 56 | + </div> |
| 57 | + <div style="max-width: 600px;"> |
| 58 | + @if (_useZipCodeOnly) |
| 59 | + { |
| 60 | + <ZipCodeAutoComplete Location="@_zipCodeLocation" LocationChanged="OnZipCodeLocationChanged" |
| 61 | + For="() => _zipCodeLocation" DisableSmartCompletion="true" /> |
| 62 | + } |
| 63 | + else |
| 64 | + { |
| 65 | + <AddressAutoComplete Address="@_addressLocation" AddressChanged="OnAddressLocationChanged" |
| 66 | + For="() => _addressLocation" /> |
| 67 | + } |
| 68 | + @if (_showLocationError && _group.ZipCode is null) |
| 69 | + { |
| 70 | + <MudText Color="Color.Error" Typo="Typo.caption" Class="mt-1 ml-3">Lokation er påkrævet.</MudText> |
| 71 | + } |
| 72 | + </div> |
75 | 73 | </MudItem> |
76 | 74 | <MudItem xs="12" md="6"> |
77 | 75 | <MudTextField @bind-Value="_group.WebsiteUrl" |
|
116 | 114 | private bool _useZipCodeOnly = true; |
117 | 115 | private string _zipCodeLocation = string.Empty; |
118 | 116 | private string _addressLocation = string.Empty; |
| 117 | + private bool _showLocationError; |
119 | 118 | private string[]? _selectedCategoryNames = Array.Empty<string>(); |
120 | 119 |
|
121 | 120 | protected override async Task OnInitializedAsync() |
|
143 | 142 | if (result is not null) |
144 | 143 | { |
145 | 144 | _group.ApplyAddressLocation(address, result); |
| 145 | + _showLocationError = false; |
146 | 146 | } |
147 | 147 | else |
148 | 148 | { |
|
165 | 165 | if (result is not null) |
166 | 166 | { |
167 | 167 | _group.ApplyZipCodeLocation(result); |
| 168 | + _showLocationError = false; |
168 | 169 | } |
169 | 170 | else |
170 | 171 | { |
|
184 | 185 |
|
185 | 186 | private async Task Create() |
186 | 187 | { |
| 188 | + if (_group.ZipCode is null) |
| 189 | + { |
| 190 | + _showLocationError = true; |
| 191 | + return; |
| 192 | + } |
| 193 | + |
187 | 194 | _isLoading = true; |
188 | 195 |
|
189 | 196 | // Sync selected categories to group |
|
0 commit comments