feat(postit): include google calendar and bank details in profile
This commit is contained in:
parent
af1e572f32
commit
137665bfe0
7 changed files with 51 additions and 5 deletions
|
|
@ -61,6 +61,8 @@ public class HomePageProviderFlowTests
|
||||||
|
|
||||||
Assert.Equal("—", vm.FullName);
|
Assert.Equal("—", vm.FullName);
|
||||||
Assert.Equal("—", vm.Address);
|
Assert.Equal("—", vm.Address);
|
||||||
|
Assert.Equal("Non configuré", vm.DedicatedGoogleCalendar);
|
||||||
|
Assert.Equal("Aucune information bancaire", vm.BankInfoSummary);
|
||||||
Assert.NotNull(vm.RefreshCommand);
|
Assert.NotNull(vm.RefreshCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,7 +72,9 @@ public class HomePageProviderFlowTests
|
||||||
var vm = new UserProfilePageViewModel
|
var vm = new UserProfilePageViewModel
|
||||||
{
|
{
|
||||||
FullName = "Alice Example",
|
FullName = "Alice Example",
|
||||||
Address = "14 rue de l’Érable"
|
Address = "14 rue de l’Érable",
|
||||||
|
DedicatedGoogleCalendar = "calendar-123",
|
||||||
|
BankInfoSummary = "FR14 2004 1010 0505 0001 3M02 606"
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.NotNull(vm.SaveProfileCommand);
|
Assert.NotNull(vm.SaveProfileCommand);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ public partial class UserProfilePageViewModel : ViewModelBase
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string DedicatedGoogleCalendar { get; set; } = "Non configuré";
|
public partial string DedicatedGoogleCalendar { get; set; } = "Non configuré";
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
public partial string BankInfoSummary { get; set; } = "Aucune information bancaire";
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string StatusMessage { get; set; } = "Prêt.";
|
public partial string StatusMessage { get; set; } = "Prêt.";
|
||||||
|
|
||||||
|
|
@ -71,6 +74,7 @@ public partial class UserProfilePageViewModel : ViewModelBase
|
||||||
Avatar = string.IsNullOrWhiteSpace(me?.Avatar) ? "Aucun avatar" : me.Avatar;
|
Avatar = string.IsNullOrWhiteSpace(me?.Avatar) ? "Aucun avatar" : me.Avatar;
|
||||||
Roles = me?.Roles is { Length: > 0 } ? string.Join(", ", me.Roles) : "Aucun rôle";
|
Roles = me?.Roles is { Length: > 0 } ? string.Join(", ", me.Roles) : "Aucun rôle";
|
||||||
DedicatedGoogleCalendar = string.IsNullOrWhiteSpace(me?.DedicatedGoogleCalendar) ? "Non configuré" : me.DedicatedGoogleCalendar;
|
DedicatedGoogleCalendar = string.IsNullOrWhiteSpace(me?.DedicatedGoogleCalendar) ? "Non configuré" : me.DedicatedGoogleCalendar;
|
||||||
|
BankInfoSummary = string.IsNullOrWhiteSpace(me?.BankInfoSummary) ? "Aucune information bancaire" : me.BankInfoSummary;
|
||||||
StatusMessage = "Profil chargé.";
|
StatusMessage = "Profil chargé.";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -82,6 +86,7 @@ public partial class UserProfilePageViewModel : ViewModelBase
|
||||||
Avatar = "—";
|
Avatar = "—";
|
||||||
Roles = "—";
|
Roles = "—";
|
||||||
DedicatedGoogleCalendar = "Non configuré";
|
DedicatedGoogleCalendar = "Non configuré";
|
||||||
|
BankInfoSummary = "Aucune information bancaire";
|
||||||
StatusMessage = $"Impossible de charger le profil : {ex.Message}";
|
StatusMessage = $"Impossible de charger le profil : {ex.Message}";
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
@ -105,7 +110,9 @@ public partial class UserProfilePageViewModel : ViewModelBase
|
||||||
var payload = new ProfileUpdateRequest
|
var payload = new ProfileUpdateRequest
|
||||||
{
|
{
|
||||||
FullName = FullName,
|
FullName = FullName,
|
||||||
Address = Address
|
Address = Address,
|
||||||
|
GoogleCalendarId = DedicatedGoogleCalendar == "Non configuré" ? string.Empty : DedicatedGoogleCalendar,
|
||||||
|
BankInfoSummary = BankInfoSummary == "Aucune information bancaire" ? string.Empty : BankInfoSummary
|
||||||
};
|
};
|
||||||
|
|
||||||
var endpoint = new Uri(new Uri(_api.Settings.ApiUrl.TrimEnd('/') + "/", UriKind.Absolute), "account/me").ToString();
|
var endpoint = new Uri(new Uri(_api.Settings.ApiUrl.TrimEnd('/') + "/", UriKind.Absolute), "account/me").ToString();
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,19 @@
|
||||||
IsIndeterminate="True"
|
IsIndeterminate="True"
|
||||||
Height="8"/>
|
Height="8"/>
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto" ColumnDefinitions="*" RowSpacing="8">
|
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto" ColumnDefinitions="*" RowSpacing="8">
|
||||||
<TextBox Watermark="Nom complet" Text="{Binding FullName}"/>
|
<TextBox Watermark="Nom complet" Text="{Binding FullName}"/>
|
||||||
<TextBox Grid.Row="1" Watermark="Adresse" Text="{Binding Address}" AcceptsReturn="True" TextWrapping="Wrap"/>
|
<TextBox Grid.Row="1" Watermark="Adresse" Text="{Binding Address}" AcceptsReturn="True" TextWrapping="Wrap"/>
|
||||||
<Button Grid.Row="2" Content="Enregistrer" Command="{Binding SaveProfileCommand}" IsEnabled="{Binding !IsBusy}"/>
|
<TextBox Grid.Row="2" Watermark="Calendrier Google" Text="{Binding DedicatedGoogleCalendar}"/>
|
||||||
|
<TextBox Grid.Row="3" Watermark="Détails bancaires" Text="{Binding BankInfoSummary}" AcceptsReturn="True" TextWrapping="Wrap"/>
|
||||||
|
<Button Grid.Row="4" Content="Enregistrer" Command="{Binding SaveProfileCommand}" IsEnabled="{Binding !IsBusy}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<TextBlock Text="{Binding UserName, StringFormat='Nom d’utilisateur : {0}'}"/>
|
<TextBlock Text="{Binding UserName, StringFormat='Nom d’utilisateur : {0}'}"/>
|
||||||
<TextBlock Text="{Binding Email, StringFormat='Email : {0}'}"/>
|
<TextBlock Text="{Binding Email, StringFormat='Email : {0}'}"/>
|
||||||
<TextBlock Text="{Binding Roles, StringFormat='Rôles : {0}'}"/>
|
<TextBlock Text="{Binding Roles, StringFormat='Rôles : {0}'}"/>
|
||||||
<TextBlock Text="{Binding DedicatedGoogleCalendar, StringFormat='Calendrier dédié : {0}'}"/>
|
<TextBlock Text="{Binding DedicatedGoogleCalendar, StringFormat='Calendrier dédié : {0}'}"/>
|
||||||
|
<TextBlock Text="{Binding BankInfoSummary, StringFormat='Informations bancaires : {0}'}" TextWrapping="Wrap"/>
|
||||||
<TextBlock Text="{Binding Avatar, StringFormat='Avatar : {0}'}" TextWrapping="Wrap"/>
|
<TextBlock Text="{Binding Avatar, StringFormat='Avatar : {0}'}" TextWrapping="Wrap"/>
|
||||||
<TextBlock Text="{Binding StatusMessage}" Foreground="#4B5563" TextWrapping="Wrap"/>
|
<TextBlock Text="{Binding StatusMessage}" Foreground="#4B5563" TextWrapping="Wrap"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,6 @@ public class ProfileUpdateRequest
|
||||||
{
|
{
|
||||||
public string? FullName { get; set; }
|
public string? FullName { get; set; }
|
||||||
public string? Address { get; set; }
|
public string? Address { get; set; }
|
||||||
|
public string? GoogleCalendarId { get; set; }
|
||||||
|
public string? BankInfoSummary { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,6 @@ namespace Yavsc.Abstract.Identity
|
||||||
public string? Avatar { get; set; }
|
public string? Avatar { get; set; }
|
||||||
public string[] Roles { get; set; } = [];
|
public string[] Roles { get; set; } = [];
|
||||||
public string? DedicatedGoogleCalendar { get; set; }
|
public string? DedicatedGoogleCalendar { get; set; }
|
||||||
|
public string? BankInfoSummary { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@ namespace Yavsc.WebApi.Controllers
|
||||||
userData.Avatar,
|
userData.Avatar,
|
||||||
userData.PostalAddress, userData.DedicatedGoogleCalendar, userData.FullName);
|
userData.PostalAddress, userData.DedicatedGoogleCalendar, userData.FullName);
|
||||||
user.Address = userData.PostalAddress?.Address ?? string.Empty;
|
user.Address = userData.PostalAddress?.Address ?? string.Empty;
|
||||||
|
user.BankInfoSummary = userData.BankInfo is { Count: > 0 }
|
||||||
|
? string.Join(" | ", userData.BankInfo.Select(b => string.IsNullOrWhiteSpace(b.IBAN) ? b.BIC : $"{b.IBAN} / {b.BIC}"))
|
||||||
|
: string.Empty;
|
||||||
|
|
||||||
var userRoles = _dbContext.UserRoles.Where(u => u.UserId == uid).Select(r => r.RoleId).ToArray();
|
var userRoles = _dbContext.UserRoles.Where(u => u.UserId == uid).Select(r => r.RoleId).ToArray();
|
||||||
|
|
||||||
|
|
@ -92,6 +95,7 @@ namespace Yavsc.WebApi.Controllers
|
||||||
|
|
||||||
var user = await _dbContext.Users
|
var user = await _dbContext.Users
|
||||||
.Include(u => u.PostalAddress)
|
.Include(u => u.PostalAddress)
|
||||||
|
.Include(u => u.BankInfo)
|
||||||
.FirstOrDefaultAsync(u => u.Id == uid);
|
.FirstOrDefaultAsync(u => u.Id == uid);
|
||||||
|
|
||||||
if (user is null)
|
if (user is null)
|
||||||
|
|
@ -116,8 +120,31 @@ namespace Yavsc.WebApi.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.GoogleCalendarId))
|
||||||
|
{
|
||||||
|
user.DedicatedGoogleCalendar = request.GoogleCalendarId.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.BankInfoSummary) && (user.BankInfo is null || user.BankInfo.Count == 0))
|
||||||
|
{
|
||||||
|
var bank = new Yavsc.Models.Bank.BankIdentity
|
||||||
|
{
|
||||||
|
UserId = uid,
|
||||||
|
User = user,
|
||||||
|
IBAN = request.BankInfoSummary,
|
||||||
|
BIC = string.Empty,
|
||||||
|
AccountNumber = string.Empty,
|
||||||
|
BankCode = string.Empty,
|
||||||
|
WicketCode = string.Empty,
|
||||||
|
BankedKey = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
user.BankInfo ??= [];
|
||||||
|
user.BankInfo.Add(bank);
|
||||||
|
}
|
||||||
|
|
||||||
await _dbContext.SaveChangesAsync(uid);
|
await _dbContext.SaveChangesAsync(uid);
|
||||||
return Ok(new { status = "saved", fullName = user.FullName, address = user.PostalAddress?.Address });
|
return Ok(new { status = "saved", fullName = user.FullName, address = user.PostalAddress?.Address, googleCalendarId = user.DedicatedGoogleCalendar });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("performer-profile")]
|
[HttpGet("performer-profile")]
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,14 @@ namespace Yavsc.Models.Auth
|
||||||
DedicatedGoogleCalendar = gCalId;
|
DedicatedGoogleCalendar = gCalId;
|
||||||
FullName = fullName ?? string.Empty;
|
FullName = fullName ?? string.Empty;
|
||||||
Address = address?.Address ?? string.Empty;
|
Address = address?.Address ?? string.Empty;
|
||||||
|
BankInfoSummary = string.Empty;
|
||||||
}
|
}
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
public string EMail { get; set; }
|
public string EMail { get; set; }
|
||||||
public string Address { get; set; }
|
public string Address { get; set; }
|
||||||
|
public string? BankInfoSummary { get; set; }
|
||||||
public string[] Roles { get; set; }
|
public string[] Roles { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Known as profile, could point to an avatar
|
/// Known as profile, could point to an avatar
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue