@using HardwareShopContracts.ViewModels

@model List<ComponentViewModel>

@{
    ViewData["Title"] = "Комплектующие";
	Layout = "~/Views/Shared/_LayoutStorekeeper.cshtml";
}

<div class="text-center">
	<h1 class="display-4">Комплектующие</h1>
</div>


<div class="text-center">
	@{
		<p>
			<a asp-action="CreateComponent" class="btn btn-primary mx-2">Создать комплектующее</a>
			<button type="button" class="btn btn-primary mx-2" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить комплектующее</button>
			<button type="button" class="btn btn-primary mx-2">Удалить комплектующее</button>
			<a asp-action="LinkBuilds" class="btn btn-primary mx-2">Привязка сборок</a>
		</p>
		<table class="table">
			<thead>
				<tr>
					<th>
						Название
					</th>
					<th>
						Цена
					</th>
					<th>
						Дата приобретения
					</th>
				</tr>
			</thead>
			<tbody>
				@foreach (var item in Model)
				{
					<tr>
						<td>
							@Html.DisplayFor(modelItem => item.ComponentName)
						</td>
						<td>
							@Html.DisplayFor(modelItem => item.Cost)
						</td>
						<td>
							@Html.DisplayFor(modelItem => item.DateCreate)
						</td>
					</tr>
				}
			</tbody>
		</table>
	}
</div>

<form method="post" class="d-flex flex-column align-items-center">
	<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title" id="exampleModalLabel">Изменение комплектующего</h5>
					<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
				</div>
				<div class="modal-body">
					<div class="col">
						<label class="form-label">Название</label>
						<input type="text" class="form-control" name="email">
					</div>
					<div class="col">
						<label class="form-label">Стоимость</label>
						<input type="number" step="0.01" class="form-control" name="cost" min="0.01">
					</div>
					<div class="col">
						<label class="form-label">Дата приобретения</label>
						<input type="date" class="form-control" name="date">
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
					<button type="submit" class="btn btn-primary">Сохранить</button>
				</div>
			</div>
		</div>
	</div>
</form>