# All files / js/pages/administration/email-templates Index.vue

0% Statements 0/22
0% Branches 0/18
0% Functions 0/8
0% Lines 0/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115

     <script setup lang="ts">
    import ListTableActionLabel from '@/components/ListTableActionLabel.vue';
    import AppLayout from '@/layouts/AppLayout.vue';
    import { Head, Link, router } from '@inertiajs/vue3';
    import { Edit, Trash2 } from 'lucide-vue-next';

    interface EmailTemplate {
        id: number;
        name: string;
        subject: string;
        is_active: boolean;
        is_default: boolean;
        created_at: string;
        updated_at: string;
    }

    defineProps<{
        templates: EmailTemplate[];
        variableGroups: Record<string, string[]>;
    }>();

    const deleteTemplate = (template: EmailTemplate) => {
        if (!confirm(`Delete email template "${template.name}"?`)) {
            return;
        }

        router.delete(`/administration/email-templates/${template.id}`);
    };
    </script>

    <template>
        <Head title="Email Templates" />

        <AppLayout :breadcrumbs="[
            { title: 'Administration', href: '/administration' },
            { title: 'Email Templates', href: '#' },
        ]">
            <div class="space-y-6 p-4">
                <div class="flex items-center justify-between">
                    <div>
                        <h1 class="text-2xl font-bold text-gray-900">Email Templates</h1>
                        <p class="text-sm text-gray-600">Manage templates for customer and contact emails using the visual email editor.</p>
                    </div>
                    <Link
                        href="/administration/email-templates/create"
                        class="rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700"
                    >
                        New Template
                    </Link>
                </div>

                <div class="rounded-lg border bg-white shadow-sm">
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Name</th>
                                    <th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Subject</th>
                                    <th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Status</th>
                                    <th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">Actions</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200 bg-white">
                                <tr v-for="template in templates" :key="template.id">
                                    <td class="px-4 py-3 text-sm font-medium text-gray-900">
                                        {{ template.name }}
                                        <span v-if="template.is_default" class="ml-2 inline-flex rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-700">
                                            Default
                                        </span>
                                    </td>
                                    <td class="px-4 py-3 text-sm text-gray-700">{{ template.subject }}</td>
                                    <td class="px-4 py-3 text-sm">
                                        <span
                                            :class="template.is_active ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-700'"
                                            class="inline-flex rounded-full px-2 py-0.5 text-xs"
                                        >
                                            {{ template.is_active ? 'Active' : 'Inactive' }}
                                        </span>
                                    </td>
                                    <td class="px-4 py-3 text-sm">
                                        <div class="flex items-center gap-2">
                                            <Link
                                                :href="`/administration/email-templates/${template.id}/edit`"
                                                class="inline-flex items-center justify-center rounded border border-gray-300 px-2 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-50 md:px-3 md:py-1"
                                            >
                                                <ListTableActionLabel label="Edit">
                                                    <Edit class="h-4 w-4" />
                                                </ListTableActionLabel>
                                            </Link>
                                            <button
                                                type="button"
                                                @click="deleteTemplate(template)"
                                                class="inline-flex items-center justify-center rounded border border-red-300 px-2 py-1.5 text-xs font-medium text-red-700 hover:bg-red-50 md:px-3 md:py-1"
                                            >
                                                <ListTableActionLabel label="Delete">
                                                    <Trash2 class="h-4 w-4" />
                                                </ListTableActionLabel>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr v-if="templates.length === 0">
                                    <td colspan="4" class="px-4 py-8 text-center text-sm text-gray-500">
                                        No email templates found.
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </AppLayout>
    </template>