First successfull build
This commit is contained in:
@@ -1,6 +1,81 @@
|
||||
namespace EnvelopeGenerator.ReceiverUI.Client.State
|
||||
namespace EnvelopeGenerator.ReceiverUI.Client.State;
|
||||
|
||||
/// <summary>
|
||||
/// Hält den aktuellen Zustand des geladenen Umschlags.
|
||||
///
|
||||
/// WARUM ein eigenes State-Objekt?
|
||||
/// - Mehrere Komponenten auf einer Seite brauchen die gleichen Daten
|
||||
/// - Ohne State müsste jede Komponente die Daten selbst laden → doppelte API-Calls
|
||||
/// - StateHasChanged() informiert automatisch alle Subscriber
|
||||
///
|
||||
/// PATTERN: "Observable State" — Services setzen den State, Komponenten reagieren darauf.
|
||||
/// </summary>
|
||||
public class EnvelopeState
|
||||
{
|
||||
public class EnvelopeState
|
||||
private EnvelopePageStatus _status = EnvelopePageStatus.Loading;
|
||||
private string? _errorMessage;
|
||||
|
||||
/// <summary>Aktueller Seitenstatus</summary>
|
||||
public EnvelopePageStatus Status
|
||||
{
|
||||
get => _status;
|
||||
private set
|
||||
{
|
||||
_status = value;
|
||||
NotifyStateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Fehlermeldung (falls vorhanden)</summary>
|
||||
public string? ErrorMessage
|
||||
{
|
||||
get => _errorMessage;
|
||||
private set
|
||||
{
|
||||
_errorMessage = value;
|
||||
NotifyStateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// --- Zustandsübergänge (öffentliche Methoden) ---
|
||||
|
||||
public void SetLoading() => Status = EnvelopePageStatus.Loading;
|
||||
|
||||
public void SetAccessCodeRequired()
|
||||
{
|
||||
ErrorMessage = null;
|
||||
Status = EnvelopePageStatus.RequiresAccessCode;
|
||||
}
|
||||
|
||||
public void SetTwoFactorRequired() => Status = EnvelopePageStatus.RequiresTwoFactor;
|
||||
|
||||
public void SetDocument() => Status = EnvelopePageStatus.ShowDocument;
|
||||
|
||||
public void SetError(string message)
|
||||
{
|
||||
ErrorMessage = message;
|
||||
Status = EnvelopePageStatus.Error;
|
||||
}
|
||||
|
||||
public void SetAlreadySigned() => Status = EnvelopePageStatus.AlreadySigned;
|
||||
public void SetRejected() => Status = EnvelopePageStatus.Rejected;
|
||||
public void SetNotFound() => Status = EnvelopePageStatus.NotFound;
|
||||
|
||||
// --- Event: Benachrichtigt Komponenten über Änderungen ---
|
||||
public event Action? OnChange;
|
||||
private void NotifyStateChanged() => OnChange?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>Alle möglichen Zustände der Umschlag-Seite</summary>
|
||||
public enum EnvelopePageStatus
|
||||
{
|
||||
Loading,
|
||||
RequiresAccessCode,
|
||||
RequiresTwoFactor,
|
||||
ShowDocument,
|
||||
AlreadySigned,
|
||||
Rejected,
|
||||
NotFound,
|
||||
Expired,
|
||||
Error
|
||||
}
|
||||
Reference in New Issue
Block a user