@inherits ViewModelTemplate<ProductViewModel>
@using Dynamicweb.Rendering
@using Dynamicweb.Ecommerce.ProductCatalog

@{ 
	bool hideInventory = GetViewParameter("HideInventory") != null ? GetViewParameterBoolean("HideInventory") : false;

	bool isNeverOutOfStock = Model.NeverOutOfstock;
	bool hasExpectedDelivery = Model.ExpectedDelivery != null && Model.ExpectedDelivery > DateTime.Now;
	string expectedDeliveryDate = Model.ExpectedDelivery?.ToShortDateString() ?? string.Empty;

	string stockLevel = Model.StockLevel > 100 ? "100+" : Model.StockLevel.ToString();
}

@if (!isNeverOutOfStock)
{

	double? currentStockLevel = Model.StockLevel;
	string stockStateLabel = currentStockLevel > 0 ? Translate("In stock") : Translate("Out of stock");
	stockStateLabel = !string.IsNullOrEmpty(Model.StockStatus) ? Model.StockStatus : stockStateLabel;
	string stockStateCss = currentStockLevel > 0 ? "text-success" : "text-danger";

	if (!hideInventory && currentStockLevel > 0)
	{
		<p class="fs-7 m-0 @stockStateCss">@currentStockLevel @stockStateLabel</p>
	}
	else
	{
		<p class="fs-7 m-0 @stockStateCss">@stockStateLabel</p>
	}

	if (hasExpectedDelivery)
	{
		<p>
			<span>@Translate("Expected:")</span>
			<span>@expectedDeliveryDate</span>
		</p>
	}
}
