@*
 * Copyright 2021 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *@

@import iht.models.RegistrationDetails
@import iht.models.application.tnrb._
@import iht.utils._
@import iht.utils.tnrb.TnrbHelperFixture
@import iht.models.application.tnrb.TnrbEligibiltyModel
@import iht.models.application.tnrb.WidowCheck
@import iht.config.AppConfig

@this(
    implicit val appConfig: AppConfig,
    form: FormWithCSRF,
    ihtMainTemplateApplication: iht_main_template_application,
    errorSummary: ihtHelpers.custom.error_summary,
    inputYesNoRadioGroup: ihtHelpers.standard.input_yes_no_radio_group
)

@(partnerLivingInUkForm:Form[TnrbEligibiltyModel],
tnrbModel: TnrbEligibiltyModel,
widowCheck: WidowCheck,
cancelUrl:Call, registrationDetails: RegistrationDetails)(implicit request:Request[_], messages: Messages)

@deceasedName() = @{CommonHelper.getOrException(registrationDetails.deceasedDetails).name}
@partnerName() = @{TnrbHelperFixture().spouseOrCivilPartnerLabelGenitive(tnrbModel, widowCheck, deceasedName, true)}

@ihtMainTemplateApplication(
    title = "",
    browserTitle = Some(Messages("iht.registration.deceased.locationOfPermanentHome")),
    cancelLabel=Some(Messages("page.iht.application.tnrb.returnToIncreasingThreshold")),
    cancelUrl = Some(cancelUrl)
){
    @errorSummary(partnerLivingInUkForm)

    @form(action = iht.controllers.application.tnrb.routes.PermanentHomeController.onSubmit,'autoComplete -> "off") {

        @inputYesNoRadioGroup(
            partnerLivingInUkForm("isPartnerLivingInUk"),
            '_hintText -> Html(Messages("page.iht.application.tnrb.permanentHome.question.hint")),
            '_divClass -> Some("form-group"),
            '_legend -> Messages("iht.estateReport.tnrb.permanentHome.question",partnerName),
            '_legendClass -> Some("legend-with-heading"),
            '_legendIsHeading -> true,
            '_headingClass -> "heading-large"
        )

        <div id="action-button" class="form-group">
          <button class="button" id="save-continue" name="action" value="save">@Messages("iht.saveAndContinue")</button>
        </div>


     }
}
