<template>
	<CardEmail v-if="isEmail()" :emailURI="resource.uri" />
	<CardPublicReport
		v-if="isPublicReport()"
		:reportURI="resource.uri"
		@viewImage="doViewImage"
	/>
	<CardText v-if="isText()" :textURI="resource.uri" />
</template>
<script setup lang="ts">
import { ResourceStub } from "@/type/api";
import CardEmail from "@/components/CardEmail.vue";
import CardPublicReport from "@/components/CardPublicReport.vue";
import CardText from "@/components/CardText.vue";

interface Props {
	resource: ResourceStub;
}
const props = defineProps<Props>();
function isEmail(): boolean {
	return props.resource.type == "email";
}
function isPublicReport(): boolean {
	return props.resource.type.startsWith("publicreport.");
}
function isText(): boolean {
	return props.resource.type == "text";
}
function doViewImage() {
	console.log("doViewImage");
}
</script>
