<template>
    <section class="flex flex-col gap-6 w-96">
        <ul class="flex flex-col gap-5">
            <li class="flex items-center justify-between">
                <strong>{{ $t('کد تخفیف') }}</strong>
                <div class="flex items-center gap-2 w-max">
                    <!-- <i v-if="user.confirmNumber" class="pi pi-verified text-green-600"></i> -->
                    <span>{{ coupon.coupon.code }}</span>
                </div>
            </li>
     
        <li class="flex items-center justify-between">
                <strong>{{ $t('id') }}</strong>
                <span>{{ coupon.coupon.id }}</span>
            </li>
        
        
            <li class="flex items-center justify-between">
                <strong>{{ $t('createdAt') }}</strong>
                <span>{{ jDate(coupon.coupon.createdAt) }}</span>
            </li>
            <li class="flex items-center justify-between">
                <strong>{{ $t('تاریخ شروع') }}</strong>
                <span>{{ jDate(coupon.coupon.startDate) }}</span>
            </li>
            <li class="flex items-center justify-between">
                <strong>{{ $t('تاریخ انقضا') }}</strong>
                <span>{{ jDate(coupon.coupon.endDate) }}</span>
            </li>
            <li class="flex items-center justify-between">
                <strong>{{ $t('نوع تخفیف') }}</strong>
                <span>{{ coupon.coupon.status === "Active" ? 'فعال' : 'غیرفعال' }}</span>
            </li>
            <li class="flex items-center justify-between">
                <strong>{{ $t('ایجاد شده توسط') }}</strong>
                <span>{{ coupon.coupon.admin.name }}</span>
            </li>
            <li class="flex items-center justify-between">
                <strong>{{ $t('تغییر وضعیت') }}</strong>
                <ToggleButton @change="changeStatus" v-model="checked" onLabel="فعال" offLabel="غیرفعال" />
            </li>
        </ul>
    </section>

</template>

<script setup>
import { inject, reactive } from 'vue';
import { jDate } from '@/utils/jDate';
import { numberFormat } from '@/utils/numberFormat';
import {useDiscountStore} from '../stores/discounts'
const store = useDiscountStore()
import { ref } from 'vue';
const checked = ref(false);
const changeStatus = async() => {
   const change = await store.changeStatus({
        id: coupon.coupon.id,
        status: 'Active'
    })
    console.log(change);
    
};
    const tabs = ref([
        { title: 'Tab 1', content: 'Tab 1 Content', value: '0' },
        { title: 'Tab 2', content: 'Tab 2 Content', value: '1' },
        { title: 'Tab 3', content: 'Tab 3 Content', value: '2' }
    ]);
const dialog = inject('dialogRef')

const coupon = reactive(Object.assign({}, dialog.value.data))
console.log('der', coupon.coupon);
const confirmToSales = (value) => {
    dialog.value.data.confirm(user, value)
}
</script>

<style lang="scss" scoped></style>