<script setup lang="ts">

import { onMounted, ref } from "vue";
import { fetchClient, type Schemas } from "@/plugins/client.ts";
import { useRoute } from "vue-router";

const route = useRoute();
const certificate = ref<Schemas["Certificate"] | null>(null);

async function getCertificate() {
  const fingerprint = route.params.fingerprint as string;
  const response = await fetchClient.GET("/api/certificates/{fingerprint}", {
    params: {
      path: {
        fingerprint,
      }
    }
  });
  certificate.value = response.data ?? null;
}

onMounted(() => {
  getCertificate()
});

</script>

<template>
  <main>
    <form v-if="certificate">
      <h2>Details des Zertifikats: {{ certificate.fingerprint }}</h2>
    </form>
  </main>
</template>
