@page "/usersettings"
@if (step == 0) {
@*
@if(model.UserImage == null) { img-blur-shadow } else { img-blur-shadow }
@model.FirstName
*@
} @if (step == 1) {
reply
Edit Profile
@*
*@
@*
*@
}
lock
Update Password

Current password

New Password

Confirm New Password

@using SeaHavenIndustries.Data.IRepository; @inject ISettingsRepository _service; @using Microsoft.JSInterop @using global::Data.SeaHavenIndustries @inject IJSRuntime JSRuntime @inject NavigationManager Navigation @inject ChangeStepService StepService @implements IDisposable @code { private int step = 0; private int steptab = 0; private async Task Changestep1(int val) { step = val; await InvokeAsync(StateHasChanged); } private ApplicationUser model = new(); private IEnumerable? modelList { get; set; } private Category category = new(); private List? categories { get; set; } private async Task ChangeStep(int newStep) { steptab = newStep; await InvokeAsync(StateHasChanged); } private IBrowserFile file; private void ProfileUpload(InputFileChangeEventArgs e) { var imageFiles = e.File; file = imageFiles; } protected override void OnInitialized() { StepService.OnStateChange += StateHasChanged; } public void Dispose() { StepService.OnStateChange -= StateHasChanged; } protected override async Task OnParametersSetAsync() { model = await _service.GetCurrentUserInfo(); } protected async Task UpdateData() { var res = await _service.UpdateUser(model, file); if (res == "success") { await ShowSweetAlert("Sucessfully Saved Data", "success"); model = await _service.GetCurrentUserInfo(); } else { await ShowSweetAlert(res, "error"); } } private void FormatPhoneNumber(ChangeEventArgs e) { string input = e.Value?.ToString(); string numericOnly = new string(input?.Where(c => char.IsDigit(c)).ToArray()); if (numericOnly.Length >= 3) { string formattedNumber = $"({numericOnly.Substring(0, 3)}"; if (numericOnly.Length >= 6) { formattedNumber += $") {numericOnly.Substring(3, 3)}"; if (numericOnly.Length >= 10) { formattedNumber += $"-{numericOnly.Substring(6, 4)}"; } } model.Contact = formattedNumber; } else { model.Contact = numericOnly; } } protected ChangePasswords changePasswords = new(); protected async Task updatepassword() { var res = await _service.Changepassword(changePasswords); if (res == "success") { await ShowSweetAlert("Password Updated Sucessfully", "success"); } else if (res == "notmatched") { await ShowSweetAlert("New Password and Confirm Password are not Match", "error"); } else { await ShowSweetAlert(res, "error"); } } private async Task ShowSweetAlert(string title, string icon) { // Display a SweetAlert dialog await JSRuntime.InvokeVoidAsync("Swal.fire", new { toast = true, showConfirmButton = false, timer = 3000, title = title, icon = icon, position = "top-end" }); await JSRuntime.InvokeVoidAsync("closemodal"); } }