Skip to content

Commit a1e4f69

Browse files
Merge pull request #476 from NielsPilgaard/feature/search-result-improvements
Feature/search result improvements
2 parents 1792d05 + ac6bab4 commit a1e4f69

36 files changed

Lines changed: 1499 additions & 1088 deletions

src/shared/Jordnaer.Shared/Extensions/GroupExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public static string DisplayLocation(this GroupSlim groupDto)
1414
return groupDto.ZipCode.ToString()!;
1515
}
1616

17-
return groupDto.City ?? "Område ikke angivet";
17+
return groupDto.City ?? "Ikke angivet";
1818
}
1919
}

src/shared/Jordnaer.Shared/Extensions/UserDtoExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public static string DisplayLocation(this UserDto userDto)
1414
return userDto.ZipCode.ToString()!;
1515
}
1616

17-
return userDto.City ?? "Område ikke angivet";
17+
return userDto.City ?? "Ikke angivet";
1818
}
1919
}

src/shared/Jordnaer.Shared/Groups/GroupSearchFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public record GroupSearchFilter
1111
/// <summary>
1212
/// Only show group results within this many kilometers of the <see cref="Location"/>.
1313
/// </summary>
14-
[Range(1, 50, ErrorMessage = "Afstand skal være mellem 1 og 50 km")]
14+
[Range(1, 500, ErrorMessage = "Afstand skal være mellem 1 og 500 km")]
1515
[LocationRequired]
1616
public int? WithinRadiusKilometers { get; set; }
1717

@@ -31,7 +31,7 @@ public record GroupSearchFilter
3131
public double? Longitude { get; set; }
3232

3333
public int PageNumber { get; set; } = 1;
34-
public int PageSize { get; set; } = 10;
34+
public int PageSize { get; set; } = 11;
3535

3636
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
3737
public override int GetHashCode()

src/shared/Jordnaer.Shared/Profile/DTO/ProfileDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ProfileDto
3636
? $"{ZipCode}, {City}"
3737
: ZipCode is not null
3838
? ZipCode.ToString()!
39-
: City ?? "Område ikke angivet";
39+
: City ?? "Ikke angivet";
4040

4141
public string DisplayName => FirstName is not null
4242
? $"{FirstName} {LastName}"

src/shared/Jordnaer.Shared/UserSearch/UserSearchFilter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Diagnostics.CodeAnalysis;
33

44
namespace Jordnaer.Shared;
5+
56
public record UserSearchFilter
67
{
78
public string? Name { get; set; }
@@ -10,7 +11,7 @@ public record UserSearchFilter
1011
/// <summary>
1112
/// Only show user results within this many kilometers of the <see cref="Location"/>.
1213
/// </summary>
13-
[Range(1, 50, ErrorMessage = "Afstand skal være mellem 1 og 50 km")]
14+
[Range(1, 500, ErrorMessage = "Afstand skal være mellem 1 og 500 km")]
1415
[LocationRequired]
1516
public int? WithinRadiusKilometers { get; set; }
1617

@@ -36,7 +37,7 @@ public record UserSearchFilter
3637
public Gender? ChildGender { get; set; }
3738

3839
public int PageNumber { get; set; } = 1;
39-
public int PageSize { get; set; } = 10;
40+
public int PageSize { get; set; } = 11;
4041

4142
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
4243
public override int GetHashCode()
@@ -107,7 +108,7 @@ protected override ValidationResult IsValid(object? value, ValidationContext val
107108

108109
// Valid if either Location string is set OR lat/long coordinates are set
109110
var hasLocation = !string.IsNullOrEmpty(userSearchFilter.Location) ||
110-
(userSearchFilter.Latitude.HasValue && userSearchFilter.Longitude.HasValue);
111+
(userSearchFilter.Latitude.HasValue && userSearchFilter.Longitude.HasValue);
111112

112113
return !hasLocation
113114
? new ValidationResult("Område skal vælges når en radius er valgt.")

src/web/Jordnaer/Components/App.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373

7474
<script src="@Assets["_content/MudBlazor/MudBlazor.min.js"]"></script>
7575
<script async src="@Assets["js/scroll.js"]"></script>
76+
<script async src="@Assets["js/geolocation.js"]"></script>
7677
<script async src="@Assets["js/utilities.js"]"></script>
7778
<script async src="@Assets["js/quill-loader.js"]"></script>
7879
<script async src="@Assets["_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"]"></script>

src/web/Jordnaer/Components/ScrollToBottom.razor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using MudBlazor.Utilities;
55

66
namespace Jordnaer.Components;
7+
78
public partial class ScrollToBottom : IDisposable
89
{
910
private IScrollListener? _scrollListener;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<MudLink Href="@Link" Target="_blank" Underline="Underline.None"
2+
UserAttributes="@(new Dictionary<string, object> { { "rel", "noopener" } })">
3+
<div class="image-ad-wrapper">
4+
<div class="image-with-label">
5+
<MudImage Src="@ImagePath" Alt="@ImageAlt" Class="ad-image"
6+
Style="width: 100%; height: auto; border-radius: 8px;" loading="lazy" />
7+
<div class="image-ad-label">Annonce</div>
8+
</div>
9+
</div>
10+
</MudLink>
11+
12+
@code {
13+
[Parameter, EditorRequired]
14+
public required string Link { get; set; }
15+
16+
[Parameter, EditorRequired]
17+
public required string ImagePath { get; set; }
18+
19+
[Parameter, EditorRequired]
20+
public required string ImageAlt { get; set; }
21+
22+
protected override void OnAfterRender(bool firstRender)
23+
{
24+
if (firstRender)
25+
{
26+
JordnaerMetrics.AdViewCounter.Add(1, new KeyValuePair<string, object?>("link", Link));
27+
}
28+
}
29+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.image-ad-wrapper {
2+
display: flex;
3+
justify-content: center;
4+
align-items: center;
5+
}
6+
7+
.image-with-label {
8+
position: relative;
9+
}
10+
11+
.image-ad-label {
12+
position: absolute;
13+
top: 8px;
14+
right: 8px;
15+
background-color: rgba(0, 0, 0, 0.05);
16+
color: rgba(0, 0, 0, 0.5);
17+
padding: 4px 8px;
18+
border-radius: 4px;
19+
font-size: 0.65rem;
20+
font-weight: 400;
21+
opacity: 0.7;
22+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
namespace Jordnaer.Features.Ad;
2+
3+
/// <summary>
4+
/// Temporary hardcoded ads until the database-backed ad system is implemented (Task 03).
5+
/// This keeps ad data separate from UI logic.
6+
/// </summary>
7+
public static class HardcodedAds
8+
{
9+
private static readonly List<AdData> _ads =
10+
[
11+
new AdData
12+
{
13+
Title = "Moon Creative",
14+
Description = "Professionel webudvikling og design",
15+
ImagePath = "images/ads/mooncreative_mobile.png",
16+
Link = "https://www.mooncreative.dk/"
17+
}
18+
];
19+
20+
/// <summary>
21+
/// Get ads for user search results.
22+
/// Returns multiple copies if needed to fill the requested count.
23+
/// </summary>
24+
public static List<AdData> GetAdsForSearch(int count)
25+
{
26+
if (count <= 0 || _ads.Count == 0)
27+
{
28+
return [];
29+
}
30+
31+
var result = new List<AdData>();
32+
33+
// Repeat ads to fill the requested count
34+
for (int i = 0; i < count; i++)
35+
{
36+
result.Add(_ads[i % _ads.Count]);
37+
}
38+
39+
return result;
40+
}
41+
}
42+
43+
public record AdData
44+
{
45+
public required string Title { get; init; }
46+
public string? Description { get; init; }
47+
public required string ImagePath { get; init; }
48+
public required string Link { get; init; }
49+
}

0 commit comments

Comments
 (0)