<template>
  <ModalDialog
    v-if="reward"
    title="Grant Reward"
    :subtitle="reward.name"
    :imageUrl="reward.image_url"
    @backdrop-click="$emit('cancel')"
  >
    <div class="modal-message">
      Redeem this reward for <span class="child-name">{{ childName }}</span
      >?
    </div>
    <div class="modal-actions">
      <button class="btn btn-primary" @click="$emit('confirm')">Yes</button>
      <button v-if="reward.redeeming" class="btn btn-secondary" @click="$emit('deny')">
        Reject
      </button>
      <button v-else class="btn btn-secondary" @click="$emit('cancel')">No</button>
    </div>
  </ModalDialog>
</template>

<script setup lang="ts">
import ModalDialog from '../shared/ModalDialog.vue'
import type { RewardStatus } from '@/common/models'

defineProps<{
  reward: RewardStatus | null
  childName?: string
}>()

defineEmits<{
  confirm: []
  deny: []
  cancel: []
}>()
</script>

<style scoped>
.modal-message {
  margin-bottom: 1.2rem;
  font-size: 1rem;
  color: var(--modal-message-color, #333);
}

.child-name {
  font-weight: 600;
  color: var(--text-primary, #333);
}
</style>
