@namespace timetracker.Client.Components.Pages
@inject ISnackbar Snackbar

<MudDialog>
    <DialogContent>
        <MudText Class="mb-4">Geben Sie das neue Passwort für den Benutzer <strong>@Username</strong> ein.</MudText>
        <MudTextField @bind-Value="_newPassword" 
                      Label="Neues Passwort" 
                      InputType="InputType.Password" 
                      Variant="Variant.Outlined" 
                      AutoFocus="true"
                      Required="true"
                      HelperText="Mindestens 6 Zeichen" />
    </DialogContent>
    <DialogActions>
        <MudButton OnClick="Cancel">Abbrechen</MudButton>
        <MudButton Color="Color.Warning" Variant="Variant.Filled" OnClick="Submit" Disabled="@(string.IsNullOrEmpty(_newPassword) || _newPassword.Length < 6)">Passwort zurücksetzen</MudButton>
    </DialogActions>
</MudDialog>

@code {
    [CascadingParameter] IMudDialogInstance MudDialog { get; set; } = default!;
    [Parameter] public string Username { get; set; } = "";

    private string _newPassword = "";

    private void Submit() => MudDialog.Close(DialogResult.Ok(_newPassword));
    private void Cancel() => MudDialog.Cancel();
}
