<?= $this->extend('Panel/Layouts/App') ?>
<?= $this->section('content') ?>
<div class="m-2">
  <div class="card-style">
    <div class="d-flex justify-content-between">
      <h3>
        Daftar Soal <?= $kode ?>
      </h3>
      <div style="text-align:right">
        <button @click="confirmPrint(<?= $bank_id ?>)" title="Print" class="btn btn-success rounded-md"><i @click="confirmPrint(<?= $bank_id ?>)" class='lni lni-printer'></i></button>
      </div>
    </div>
    <preview :auto-load="true" bank-id="<?= $bank_id ?>"></preview>
  </div>
</div>
<?= $this->endSection() ?>
<?= $this->section('js') ?>
<script src="<?= base_url() ?>/panel/assets/js/pages/banksoal/preview.js?v=<?= versioningjs() ?>"></script>
<script>
  VAPP.component(VPPreviewBankSoal.name, VPPreviewBankSoal);
  VAPP.mixin({
    data() {
      return {}
    },
    methods: {
      confirmPrint(bi) {
        Swal.fire({
          title: 'Print Soal?',
          showDenyButton: true,
          showCancelButton: true,
          confirmButtonText: 'Print',
          denyButtonText: `Dengan Jawaban`,
        }).then((result) => {
          if (result.isConfirmed || result.isDenied) this.printSoal(bi, result.isDenied);
        })

      },
      printSoal(bi, wk = true) {
        let url = this.$store.state.config.base_url + "/panel/bank-soal/print/" + bi + "?";
        if (wk) url += "wk=true";
        window.open(url);
      }
    }
  });
</script>
<?= $this->endSection() ?>