@model MyWebsite.Models.BadgeModel
@{
	ViewData["Title"] = "Create badge";
}

<header>
	&#xE760; <a asp-action="Index">Back to the list</a>
	<h1>Create project badge</h1>
</header>

<article>
	<form asp-action="Create" oninput="UpdatePreview();">
		<div asp-validation-summary="All" class="text-danger"></div>
		<div>
			<label asp-for="Name"></label>
			<input asp-for="Name" type="text" placeholder="Enter unique badge name" required />
			<span asp-validation-for="Name" class="text-danger"></span>
		</div>
		<div>
			<label asp-for="EnglishDescription"></label>
			<input asp-for="EnglishDescription" type="text" required />
			<span asp-validation-for="EnglishDescription" class="text-danger"></span>
		</div>
		<div>
			<label asp-for="RussianDescription"></label>
			<input asp-for="RussianDescription" type="text" />
			<span asp-validation-for="RussianDescription" class="text-danger"></span>
		</div>
		<div>
			<label asp-for="Image"></label>
			<div class="image-selector">
				<select asp-for="Image" onchange="UpdatePreview();" required>
					@foreach (string path in System.IO.Directory.GetFiles(System.IO.Directory.GetCurrentDirectory() + "/wwwroot/images/Badges"))
					{
						string file = System.IO.Path.GetFileNameWithoutExtension(path);
						<option value="@file">@file</option>
					}
				</select>
				<span>.png</span>
			</div>
			<span asp-validation-for="Image" class="text-danger"></span>
		</div>
		<partial name="Preview.cshtml" />

		<input type="submit" value="Create" />
	</form>
</article>