@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>

@{
	string pageTitle = Pageview.Page.GetDisplayName();
	string pageId = GetGlobalValue("Global:Page.ID");
	int signInPageId = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Pageview.Area.ID, "SignInPage").ID;
	string singInPageUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(signInPageId);
	string invalidName = !string.IsNullOrEmpty(GetString("UserManagement:User.Name.Input.Error")) ? "is-invalid" : "";
	string invalidEmail = !string.IsNullOrEmpty(GetString("UserManagement:User.Email.Input.Error")) ? "is-invalid" : "";
	string invalidPassword = !string.IsNullOrEmpty(GetString("UserManagement:User.NewPassword.Input.Error")) ? "is-invalid" : "";
	string invalidConfirmPassword = !string.IsNullOrEmpty(GetString("UserManagement:User.NewPasswordConfirm.Input.Error")) ? "is-invalid" : "";
}

<div>
	
	@foreach (var error in GetLoop("FormValidationErrors"))
	{
		<div class="alert alert-danger mb-3" role="alert">
			@error.GetString("UserManagement:User.FormValidationError.Message")
		</div>
	}

	@if (!String.IsNullOrEmpty(GetString("error"))) {
		<div class="alert alert-danger mb-5" role="alert">
			@GetString("error")
		</div>
	}

	<div class="card border-0 mx-auto" style="max-width: 30rem;">

		<div class="card-header text-center p-4 border-bottom">
			<h4 class="display-6 m-0">@pageTitle</h4>
			@if (!string.IsNullOrEmpty(singInPageUrl))
			{
				<p class="card-text mt-2">@Translate("Already have an account?") <a href="@singInPageUrl" id="SignInLink">@Translate("Sign in here")</a></p>
			}
		</div>

		<div class="card-body p-4">

			@GetString("UserManagement:User.FormStart")
				<input type="hidden" name="UserManagementForm" value="1">
				<div class="grid grid-1 gap-4">

					<div>
						<label class="form-label fs-7 mb-0 opacity-75" for="UserManagement_Form_Name">@Translate("Your name")</label>
						<div class="form-floating">
							<input type="text" class="form-control @invalidName" placeholder="@Translate("Name")" name="UserManagement_Form_Name" id="UserManagement_Form_Name" value="@GetString("UserManagement:User.Name")" required />
							<div class="invalid-feedback">@GetString("UserManagement:User.Name.Input.Error")</div>
							<label for="UserManagement_Form_Name" class="form-label">@Translate("Name")</label>
						</div>
					</div>
					<div>
						<label class="form-label fs-7 mb-0 opacity-75" for="UserManagement_Form_Email">@Translate("Your email")</label>
						<div class="form-floating">
							<input type="email" class="form-control @invalidEmail" placeholder="@Translate("Email")" name="UserManagement_Form_Email" id="UserManagement_Form_Email" value="@GetString("UserManagement:User.Email")" required />
							<div class="invalid-feedback">@GetString("UserManagement:User.Email.Input.Error")</div>
							<label for="UserManagement_Form_Email" class="form-label">@Translate("Email")</label>
						</div>
					</div>
					<div>
						<label class="form-label fs-7 mb-0 opacity-75" for="UserManagement_Form_NewPassword">@Translate("Password")</label>
						<div class="form-floating">
							<input class="form-control @invalidPassword" placeholder="@Translate("Password")" type="password" id="UserManagement_Form_NewPassword" name="UserManagement_Form_NewPassword" value="" autocomplete="off">
							<div class="invalid-feedback">@GetString("UserManagement:User.NewPassword.Input.Error")</div>
							<label for="UserManagement_Form_NewPassword" class="form-label">@Translate("Password")</label>
						</div>
					</div>
					<div>
						<label class="form-label fs-7 mb-0 opacity-75" for="UserManagement_Form_NewPasswordConfirm">@Translate("Confirm password")</label>
						<div class="form-floating">
							<input class="form-control @invalidConfirmPassword" placeholder="@Translate("Confirm password")" type="password" id="UserManagement_Form_NewPasswordConfirm" name="UserManagement_Form_NewPasswordConfirm" value="" autocomplete="off">
							<div class="invalid-feedback">@GetString("UserManagement:User.NewPasswordConfirm.Input.Error")</div>
							<label for="UserManagement_Form_NewPasswordConfirm" class="form-label">@Translate("Confirm password")</label>
						</div>
					</div>

					<button type="submit" class="btn btn-primary btn-lg" data-dw-button="primary" id="CreateNewAccountButton">@Translate("Create your new account")</button>
				</div>
			@GetString("UserManagement:User.FormEnd")

		</div>
		
	</div>
	
</div>




