<template>
    <form class="content-l" v-if="popup.payload" @submit.prevent="deleteRealm(popup.payload)">
        <UiWarning><p>Are you sure you want to delete realm <span>{{ popup.payload.name }} ({{ popup.payload.key }})</span>?</p></UiWarning>
        <div class="center">
            <UiButton type="submit">Delete</UiButton>
        </div>
    </form>
</template>

<script setup lang="ts">
import {usePopup} from "~/components/ui/popup/Popup";
import type {User} from "~/user/User";
import {useDelete} from "~/utils/HttpUtils";
import UiWarning from "~/components/ui/UiWarning.vue";
import type {Realm} from "~/realm/Realm";
import {useRealmStore} from "~/realm/RealmStore";

const popup = usePopup().require<Realm>();

function deleteRealm(realm: Realm)
{
    useRealmStore().delete(realm);
}
</script>

<style scoped>
span {
    font-weight: bold;
}
</style>