Skip to content

Commit 9e0fdeb

Browse files
committed
enforce adding group location
1 parent 9bb49a3 commit 9e0fdeb

1 file changed

Lines changed: 45 additions & 38 deletions

File tree

src/web/Jordnaer/Pages/Groups/CreateGroup.razor

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,42 @@
3434
</MudItem>
3535
@* Location Section *@
3636
<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>
7573
</MudItem>
7674
<MudItem xs="12" md="6">
7775
<MudTextField @bind-Value="_group.WebsiteUrl"
@@ -116,6 +114,7 @@
116114
private bool _useZipCodeOnly = true;
117115
private string _zipCodeLocation = string.Empty;
118116
private string _addressLocation = string.Empty;
117+
private bool _showLocationError;
119118
private string[]? _selectedCategoryNames = Array.Empty<string>();
120119

121120
protected override async Task OnInitializedAsync()
@@ -143,6 +142,7 @@
143142
if (result is not null)
144143
{
145144
_group.ApplyAddressLocation(address, result);
145+
_showLocationError = false;
146146
}
147147
else
148148
{
@@ -165,6 +165,7 @@
165165
if (result is not null)
166166
{
167167
_group.ApplyZipCodeLocation(result);
168+
_showLocationError = false;
168169
}
169170
else
170171
{
@@ -184,6 +185,12 @@
184185

185186
private async Task Create()
186187
{
188+
if (_group.ZipCode is null)
189+
{
190+
_showLocationError = true;
191+
return;
192+
}
193+
187194
_isLoading = true;
188195

189196
// Sync selected categories to group

0 commit comments

Comments
 (0)