Allow amateur performer profiles
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
f1c23965b2
commit
0728d2a3f7
20 changed files with 217 additions and 29 deletions
|
|
@ -156,6 +156,21 @@ public class ProviderOngoingRequestsPageViewModelTests
|
|||
Assert.False(vm.CreateEstimateForSelectedCommand.CanExecute(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateEstimateForSelectedCommand_is_disabled_for_an_amateur_profile()
|
||||
{
|
||||
var api = new StubProviderApi();
|
||||
var client = new BillingApiClient(api, "https://business.example/api/v1/");
|
||||
var estimateClient = new EstimateApiClient(api, "https://business.example/api/v1/");
|
||||
var vm = new ProviderOngoingRequestsPageViewModel(
|
||||
client, estimateClient: estimateClient, canIssueEstimates: false);
|
||||
|
||||
await vm.InitializeAsync();
|
||||
vm.SelectedQuery = vm.Queries[0];
|
||||
|
||||
Assert.False(vm.CreateEstimateForSelectedCommand.CanExecute(null));
|
||||
}
|
||||
|
||||
private sealed class StubProviderApi : IYavscApiClient
|
||||
{
|
||||
public HttpClient Http { get; } = new();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public partial class ProviderOngoingRequestsPageViewModel : ViewModelBase, IActi
|
|||
private readonly EstimateApiClient? _estimateClient;
|
||||
private readonly Settings? _settings;
|
||||
private List<BillingQuerySummaryDto> _allQueries = new();
|
||||
public bool CanIssueEstimates { get; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial ObservableCollection<BillingQuerySummaryDto> Queries { get; set; } = new();
|
||||
|
|
@ -75,11 +76,13 @@ public partial class ProviderOngoingRequestsPageViewModel : ViewModelBase, IActi
|
|||
public ProviderOngoingRequestsPageViewModel(
|
||||
BillingApiClient billingClient,
|
||||
Settings? settings = null,
|
||||
EstimateApiClient? estimateClient = null)
|
||||
EstimateApiClient? estimateClient = null,
|
||||
bool canIssueEstimates = true)
|
||||
{
|
||||
_billingClient = billingClient ?? throw new ArgumentNullException(nameof(billingClient));
|
||||
_estimateClient = estimateClient;
|
||||
_settings = settings;
|
||||
CanIssueEstimates = canIssueEstimates;
|
||||
|
||||
if (_settings is not null)
|
||||
{
|
||||
|
|
@ -225,7 +228,8 @@ public partial class ProviderOngoingRequestsPageViewModel : ViewModelBase, IActi
|
|||
}
|
||||
}
|
||||
|
||||
private bool CanCreateEstimateForSelected() => SelectedQuery is not null && _estimateClient is not null;
|
||||
private bool CanCreateEstimateForSelected()
|
||||
=> SelectedQuery is not null && _estimateClient is not null && CanIssueEstimates;
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanCreateEstimateForSelected))]
|
||||
public async Task CreateEstimateForSelectedAsync()
|
||||
|
|
@ -242,6 +246,12 @@ public partial class ProviderOngoingRequestsPageViewModel : ViewModelBase, IActi
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CanIssueEstimates)
|
||||
{
|
||||
this.SetWarningStatus("Un identifiant d'entreprise est nécessaire pour émettre un devis.");
|
||||
return;
|
||||
}
|
||||
|
||||
var app = (App?)Application.Current;
|
||||
if (app is null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Threading;
|
||||
|
|
@ -9,6 +10,7 @@ using CommunityToolkit.Mvvm.Input;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels.Chat;
|
||||
using Yavsc.Abstract.Workflow;
|
||||
using Yavsc.Abstract.Models.Messaging;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
|
|
@ -218,7 +220,11 @@ public class HomePageViewModel : ViewModelBase
|
|||
|
||||
var estimateClient = app.ServiceProvider?.GetRequiredService<EstimateApiClient>();
|
||||
|
||||
var vm = new ProviderOngoingRequestsPageViewModel(billingClient, Settings, estimateClient);
|
||||
var profileEndpoint = new Uri(new Uri(Api.Settings.ApiUrl.TrimEnd('/') + "/", UriKind.Absolute), "account/performer-profile").ToString();
|
||||
var profile = await Api.CallAsync<PerformerProfileSettings>(HttpMethod.Get, profileEndpoint).ConfigureAwait(true);
|
||||
var vm = new ProviderOngoingRequestsPageViewModel(
|
||||
billingClient, Settings, estimateClient,
|
||||
canIssueEstimates: profile?.CanIssueEstimates == true);
|
||||
await vm.InitializeAsync();
|
||||
await app.PushPageAsync(vm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,9 +44,11 @@ public partial class PerformerConfigurationPageViewModel : ViewModelBase
|
|||
[ObservableProperty]
|
||||
public partial string ExerciseCountryCode { get; set; } = "fr";
|
||||
|
||||
[ObservableProperty]
|
||||
[ObservableProperty, NotifyPropertyChangedFor(nameof(IsAmateur))]
|
||||
public partial string SIREN { get; set; } = string.Empty;
|
||||
|
||||
public bool IsAmateur => string.IsNullOrWhiteSpace(SIREN);
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string Website { get; set; } = string.Empty;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,14 @@
|
|||
Opacity="0.7" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="2"
|
||||
Text="Astuce: sélectionnez une ligne puis ouvrez le détail ou l'édition directe."
|
||||
Opacity="0.65"
|
||||
FontSize="11"
|
||||
Margin="0,0,0,8" />
|
||||
<StackPanel Grid.Row="2" Spacing="3" Margin="0,0,0,8">
|
||||
<TextBlock Text="Astuce: sélectionnez une ligne puis ouvrez le détail ou l'édition directe."
|
||||
Opacity="0.65"
|
||||
FontSize="11" />
|
||||
<TextBlock Text="Profil amateur : l’émission de devis et la facturation sont désactivées tant qu’un identifiant d’entreprise n’est pas renseigné."
|
||||
IsVisible="{Binding !CanIssueEstimates}"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="3" RowDefinitions="*,Auto">
|
||||
<ListBox Grid.Row="0"
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@
|
|||
<TextBox Text="{Binding ExerciseCountryCode, Mode=TwoWay}"
|
||||
PlaceholderText="Code pays (fr, en...)"/>
|
||||
<TextBox Text="{Binding SIREN, Mode=TwoWay}"
|
||||
PlaceholderText="SIREN"/>
|
||||
PlaceholderText="SIREN / SIRET (facultatif)"/>
|
||||
<TextBlock Text="Sans identifiant d’entreprise, votre profil reste utilisable comme amateur. L’émission de devis et la facturation sont alors désactivées."
|
||||
IsVisible="{Binding IsAmateur}"
|
||||
TextWrapping="Wrap"/>
|
||||
<TextBox Text="{Binding Website, Mode=TwoWay}"
|
||||
PlaceholderText="Site web"/>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue