diff --git a/Wonky.Client/Components/Home.razor b/Wonky.Client/Components/Home.razor
index 7ff9353c..6785ba80 100644
--- a/Wonky.Client/Components/Home.razor
+++ b/Wonky.Client/Components/Home.razor
@@ -18,14 +18,7 @@
Innotec Danmark A/S
-
-
-
@_workDate.ToLongDateString()
-
-
-
-
-
+
Dagens aktivitet
diff --git a/Wonky.Client/Components/Home.razor.cs b/Wonky.Client/Components/Home.razor.cs
index 35e46290..e99b0ac1 100644
--- a/Wonky.Client/Components/Home.razor.cs
+++ b/Wonky.Client/Components/Home.razor.cs
@@ -35,50 +35,25 @@ public partial class Home : IDisposable
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public IActivityHttpRepository ActivityRepo { get; set; }
private Preferences _prefs { get; set; } = new();
- private DateTime _workDate { get; set; } = new();
private List Activities { get; set; }
- //private EditContext _editContext { get; set; }
-
protected override async Task OnInitializedAsync()
{
- //_editContext = new EditContext(_workDate);
- //_editContext.OnFieldChanged += HandleFieldChanged;
-
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
-
- if (string.IsNullOrWhiteSpace(await Storage.GetItemAsStringAsync("_xa").ConfigureAwait(true)))
- Navigator.NavigateTo("/login/home");
-
_prefs = await UserPrefs.GetPreferences();
- _workDate = string.IsNullOrWhiteSpace(_prefs.WorkDate)
- ? DateTime.Now
- : DateTime.Parse(_prefs.WorkDate);
-
- await UserPrefs.SetWorkDate(_workDate);
-
-
- await FetchActivities();
- }
-
- private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
- {
- StateHasChanged();
+ await FetchActivities(_prefs.WorkDate);
}
- private async Task FetchActivities()
+ private async Task FetchActivities(string workDate)
{
Activities = new List();
- await UserPrefs.SetWorkDate(_workDate);
- Activities = await ActivityRepo.GetActivities($"{_workDate:yyyy-MM-dd}");
+ Activities = await ActivityRepo.GetActivities(workDate);
}
public void Dispose()
{
Interceptor.DisposeEvent();
- //_editContext.OnFieldChanged -= HandleFieldChanged;
- //_editContext.OnValidationStateChanged -= ValidationChanged;
}
}
diff --git a/Wonky.Client/Components/WorkDateComponent.razor b/Wonky.Client/Components/WorkDateComponent.razor
new file mode 100644
index 00000000..302470f4
--- /dev/null
+++ b/Wonky.Client/Components/WorkDateComponent.razor
@@ -0,0 +1,13 @@
+@using Blazored.LocalStorage
+@using Wonky.Client.Services
+
+
+
+
@DateTime.Parse(WorkDate).ToLongDateString()
+
+
+
+
+
diff --git a/Wonky.Client/Components/WorkDateComponent.razor.cs b/Wonky.Client/Components/WorkDateComponent.razor.cs
new file mode 100644
index 00000000..14995e24
--- /dev/null
+++ b/Wonky.Client/Components/WorkDateComponent.razor.cs
@@ -0,0 +1,39 @@
+using Blazored.LocalStorage;
+using Microsoft.AspNetCore.Components;
+using Wonky.Client.Services;
+
+namespace Wonky.Client.Components;
+
+public partial class WorkDateComponent : IDisposable
+{
+ [Inject] private ILocalStorageService LocalStorage { get; set; }
+ [Inject] private UserPreferenceService UserPrefs { get; set; }
+ [Parameter] public EventCallback OnChanged { get; set; }
+
+ private Preferences _prefs = new();
+ private string WorkDate { get; set; }
+
+ protected override async Task OnInitializedAsync()
+ {
+ UserPrefs.OnChange += ProfileServiceOnOnChange;
+ _prefs = await UserPrefs.GetPreferences();
+ WorkDate = _prefs.WorkDate;
+ }
+ private async Task OnDateChanged(ChangeEventArgs e)
+ {
+ var val = $"{DateOnly.Parse(e.Value?.ToString()!):yyyy-MM-dd}";
+ await OnChanged.InvokeAsync(val);
+ await UserPrefs.SetWorkDate(DateTime.Parse(val));
+ }
+
+ private void ProfileServiceOnOnChange(Preferences newPreferences)
+ {
+ _prefs = newPreferences;
+ StateHasChanged();
+ }
+
+ public void Dispose()
+ {
+ UserPrefs.OnChange -= ProfileServiceOnOnChange;
+ }
+}
\ No newline at end of file
diff --git a/Wonky.Client/Components/WorkDateComponent.razor.css b/Wonky.Client/Components/WorkDateComponent.razor.css
new file mode 100644
index 00000000..6ab96e32
--- /dev/null
+++ b/Wonky.Client/Components/WorkDateComponent.razor.css
@@ -0,0 +1,3 @@
+h5 {
+ font-variant: small-caps;
+}
\ No newline at end of file
diff --git a/Wonky.Client/Pages/CrmActivityCreate.razor b/Wonky.Client/Pages/CrmActivityCreate.razor
index 27655a55..2e18276f 100644
--- a/Wonky.Client/Pages/CrmActivityCreate.razor
+++ b/Wonky.Client/Pages/CrmActivityCreate.razor
@@ -19,11 +19,11 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Adviser")]
@using Wonky.Client.Components
+
@if (DraftContext != null)
{
-
+
-