<template>
  <ion-content padding>
    <h1>Document Consent</h1>
    <p>Modal for accepting user contracts such as Privacy Policy and Terms & Conditions</a></p>
    <h1>Demo</h1>
    <ion-button @click="openDocumentConsentModal">Document Consent Modal</ion-button>
  </ion-content>
</template>

<script>
import RecoDocumentConsent from '@/components/complex/RecoDocumentConsent.vue';
import documents from '@/dummydb/documents'

export default {
  data() {
    return {
      RecoDocumentConsent: null,
    }
  },
  methods: {
    openDocumentConsentModal() {
      let comp = this;
      return this.$ionic.modalController
        .create({
          component: RecoDocumentConsent,
          componentProps: {
            propsData: {
              documentHTML: documents[0],
              hasToAccept: true
            },
            methods: {
              acceptButtonClicked() {
                comp.RecoDocumentConsent.dismiss();
                console.log('User accepted document.');
              },
              backButtonClicked() {
                comp.RecoDocumentConsent.dismiss();
              }
            }
          },
        })
        .then(m => {
          this.RecoDocumentConsent = m;
          this.RecoDocumentConsent.present();
        })
    }
  }
}
</script>