@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
@using Dynamicweb.Core
@using System
@using System.Web
@using System.Collections.Generic
@using Dynamicweb.Rapido.Blocks
@using Dynamicweb.Rapido.Blocks.Components.General

@functions { 
    BlocksPage productDescriptionPage = BlocksPage.GetBlockPage("Product");
}

@{ 
    string fullDesctiptionLayout = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductPage").GetString("FullDescriptionLayout")) ? Pageview.AreaSettings.GetItem("ProductPage").GetList("FullDescriptionLayout").SelectedValue : "Section";
    fullDesctiptionLayout = fullDesctiptionLayout == "Ribbon" ? "Section" : fullDesctiptionLayout;

    if (!string.IsNullOrEmpty(GetString("Ecom:Product.LongDescription")) && fullDesctiptionLayout != "hide")
    {
        Block detailsDescription = new Block()
        {
            Name = fullDesctiptionLayout != "MainInformation" ? Translate("Description") : "",
            Id = "FullDescription",
            SortId = 30,
            Template = RenderProductDescription(fullDesctiptionLayout),
            Design = new Design
            {
                Size = "12",
                RenderType = RenderType.Column,
                HidePadding = true
            }
        };
        productDescriptionPage.Add(fullDesctiptionLayout, detailsDescription);
    }
}

@helper RenderProductDescription(string layout)
{
    string ribbonClasses = Pageview.AreaSettings.GetItem("ProductPage").GetList("FullDescriptionLayout").SelectedValue == "Ribbon" ? "product__section--ribbon paragraph-container paragraph-container--full-width" : "";
    ribbonClasses = layout == "Tabs" ? "" : ribbonClasses;
    string ribbonSubClasses = Pageview.AreaSettings.GetItem("ProductPage").GetList("FullDescriptionLayout").SelectedValue == "Ribbon" ? "center-container--ribbon" : "";

    <div class="product__section @ribbonClasses dw-mod">
        <div class="product__description center-container @ribbonSubClasses dw-mod">
            @if (layout == "Section") {
               @Render(new Heading { Title = Translate("Description"), Level = 2 })
            }
            @Render(new Text { Content = GetString("Ecom:Product.LongDescription") })
        </div>
    </div>
}