<?php

namespace App\Enums;

use App\Traits\ProvidesEnumOptions;

enum Permission: string
{
    use ProvidesEnumOptions;

    case DASHBOARD_VIEW = 'dashboard.view';
    case DASHBOARD_ATTENDANCE = 'dashboard.attendance';
    case DASHBOARD_CASH = 'dashboard.cash';
    case DASHBOARD_REVENUE = 'dashboard.revenue';
    case DASHBOARD_EXPENSE = 'dashboard.expense';
    case DASHBOARD_ORDERS_CHANNEL = 'dashboard.orders_channel';
    case DASHBOARD_ORDERS_PAYMENT = 'dashboard.orders_payment';
    case DASHBOARD_ORDERS_MARKETING = 'dashboard.orders_marketing';
    case DASHBOARD_ORDERS_STATUS = 'dashboard.orders_status';

    case ANALYSIS_VIEW = 'analysis.view';
    case ANALYSIS_ATTENDANCE = 'analysis.attendance';
    case ANALYSIS_CASH = 'analysis.cash';
    case ANALYSIS_RAW_MATERIALS = 'analysis.raw_materials';
    case ANALYSIS_PRODUCT_STOCK = 'analysis.product_stock';
    case ANALYSIS_REVENUE = 'analysis.revenue';
    case ANALYSIS_EXPENSE = 'analysis.expense';
    case ANALYSIS_BUSY_HOURS = 'analysis.busy_hours';
    case ANALYSIS_PROFIT_ORDERS = 'analysis.profit_orders';
    case ANALYSIS_PROFIT_HPP = 'analysis.profit_hpp';
    case ANALYSIS_PROFIT_GROSS = 'analysis.profit_gross';
    case ANALYSIS_PROFIT_MARGIN = 'analysis.profit_margin';
    case ANALYSIS_TOP_SUPPLIERS = 'analysis.top_suppliers';
    case ANALYSIS_TOP_CUSTOMERS = 'analysis.top_customers';
    case ANALYSIS_TOP_PRODUCTS = 'analysis.top_products';

    case EMPLOYEES_VIEW = 'employees.view';
    case EMPLOYEES_CREATE = 'employees.create';
    case EMPLOYEES_UPDATE = 'employees.update';
    case EMPLOYEES_DELETE = 'employees.delete';
    case EMPLOYEES_RESET_PASSWORD = 'employees.reset_password';
    case EMPLOYEES_TOGGLE_STATUS = 'employees.toggle_status';

    case ATTENDANCES_VIEW = 'attendances.view';
    case ATTENDANCES_CREATE = 'attendances.create';
    case ATTENDANCES_DELETE = 'attendances.delete';
    case ATTENDANCES_MANAGE = 'attendances.manage';

    case LEAVE_REQUESTS_VIEW = 'leave_requests.view';
    case LEAVE_REQUESTS_CREATE = 'leave_requests.create';
    case LEAVE_REQUESTS_UPDATE = 'leave_requests.update';
    case LEAVE_REQUESTS_DELETE = 'leave_requests.delete';
    case LEAVE_REQUESTS_VERIFY = 'leave_requests.verify';

    case CATEGORIES_VIEW = 'categories.view';
    case CATEGORIES_CREATE = 'categories.create';
    case CATEGORIES_UPDATE = 'categories.update';
    case CATEGORIES_DELETE = 'categories.delete';

    case SUPPLIERS_VIEW = 'suppliers.view';
    case SUPPLIERS_CREATE = 'suppliers.create';
    case SUPPLIERS_UPDATE = 'suppliers.update';
    case SUPPLIERS_DELETE = 'suppliers.delete';

    case CUSTOMERS_VIEW = 'customers.view';
    case CUSTOMERS_CREATE = 'customers.create';
    case CUSTOMERS_UPDATE = 'customers.update';
    case CUSTOMERS_DELETE = 'customers.delete';

    case PRODUCTS_VIEW = 'products.view';
    case PRODUCTS_CREATE = 'products.create';
    case PRODUCTS_UPDATE = 'products.update';
    case PRODUCTS_DELETE = 'products.delete';
    case PRODUCTS_TOGGLE_STATUS = 'products.toggle_status';

    case RAW_MATERIALS_VIEW = 'raw_materials.view';
    case RAW_MATERIALS_CREATE = 'raw_materials.create';
    case RAW_MATERIALS_UPDATE = 'raw_materials.update';
    case RAW_MATERIALS_DELETE = 'raw_materials.delete';
    case RAW_MATERIALS_TOGGLE_STATUS = 'raw_materials.toggle_status';

    case PURCHASES_VIEW = 'purchases.view';
    case PURCHASES_CREATE = 'purchases.create';
    case PURCHASES_UPDATE = 'purchases.update';
    case PURCHASES_DELETE = 'purchases.delete';

    case ORDERS_VIEW = 'orders.view';
    case ORDERS_CREATE = 'orders.create';
    case ORDERS_UPDATE = 'orders.update';
    case ORDERS_DELETE = 'orders.delete';
    case ORDERS_SEND = 'orders.send';
    case ORDERS_COMPLETE = 'orders.complete';
    case ORDERS_CANCEL = 'orders.cancel';

    case CUTTINGS_VIEW = 'cuttings.view';
    case CUTTINGS_CREATE = 'cuttings.create';
    case CUTTINGS_UPDATE = 'cuttings.update';
    case CUTTINGS_DELETE = 'cuttings.delete';
    case CUTTINGS_COMPLETE = 'cuttings.complete';
    case CUTTINGS_VERIFY = 'cuttings.verify';
    case CUTTINGS_REJECT = 'cuttings.reject';

    case OWNER_VERIFICATIONS_VIEW = 'owner_verifications.view';
    case OWNER_VERIFICATIONS_VERIFY = 'owner_verifications.verify';
    case OWNER_VERIFICATIONS_REJECT = 'owner_verifications.reject';

    case STOCKS_VIEW = 'stocks.view';

    case STOK_OPNAMES_VIEW = 'stok_opnames.view';
    case STOK_OPNAMES_CREATE = 'stok_opnames.create';
    case STOK_OPNAMES_UPDATE = 'stok_opnames.update';
    case STOK_OPNAMES_DELETE = 'stok_opnames.delete';
    case STOK_OPNAMES_SUBMIT = 'stok_opnames.submit';
    case STOK_OPNAMES_VERIFY = 'stok_opnames.verify';

    case CASH_VIEW = 'cash.view';
    case CASH_DEPOSIT = 'cash.deposit';
    case CASH_WITHDRAW = 'cash.withdraw';
    case CASH_UPDATE = 'cash.update';
    case CASH_DELETE = 'cash.delete';

    case EXPENSES_VIEW = 'expenses.view';
    case EXPENSES_CREATE = 'expenses.create';
    case EXPENSES_UPDATE = 'expenses.update';
    case EXPENSES_DELETE = 'expenses.delete';

    case EMPLOYEE_ADVANCES_VIEW = 'employee_advances.view';
    case EMPLOYEE_ADVANCES_CREATE = 'employee_advances.create';
    case EMPLOYEE_ADVANCES_UPDATE = 'employee_advances.update';
    case EMPLOYEE_ADVANCES_DELETE = 'employee_advances.delete';
    case EMPLOYEE_ADVANCES_VERIFY = 'employee_advances.verify';
    case EMPLOYEE_ADVANCES_PAY = 'employee_advances.pay';

    case PAYROLL_VIEW = 'payroll.view';
    case PAYROLL_ADJUST = 'payroll.adjust';

    case SETTINGS_VIEW = 'settings.view';
    case SETTINGS_UPDATE = 'settings.update';

    case ACTIVITY_LOGS_VIEW = 'activity_logs.view';

    case ROLES_VIEW = 'roles.view';
    case ROLES_CREATE = 'roles.create';
    case ROLES_UPDATE = 'roles.update';
    case ROLES_DELETE = 'roles.delete';

    public function label(): string
    {
        return match ($this) {
            self::DASHBOARD_VIEW => 'Lihat Dashboard',
            self::DASHBOARD_ATTENDANCE => 'Lihat Kartu Kehadiran',
            self::DASHBOARD_CASH => 'Lihat Kartu Kas Toko',
            self::DASHBOARD_REVENUE => 'Lihat Kartu Pendapatan',
            self::DASHBOARD_EXPENSE => 'Lihat Kartu Pengeluaran',
            self::DASHBOARD_ORDERS_CHANNEL => 'Lihat Kartu Pesanan per Channel',
            self::DASHBOARD_ORDERS_PAYMENT => 'Lihat Kartu Pesanan per Pembayaran',
            self::DASHBOARD_ORDERS_MARKETING => 'Lihat Kartu Pesanan per Marketing',
            self::DASHBOARD_ORDERS_STATUS => 'Lihat Kartu Pesanan per Status',

            self::ANALYSIS_VIEW => 'Lihat Analisa',
            self::ANALYSIS_ATTENDANCE => 'Lihat Analisa Kehadiran',
            self::ANALYSIS_CASH => 'Lihat Analisa Kas Toko',
            self::ANALYSIS_RAW_MATERIALS => 'Lihat Analisa Bahan Baku',
            self::ANALYSIS_PRODUCT_STOCK => 'Lihat Analisa Stok Produk',
            self::ANALYSIS_REVENUE => 'Lihat Analisa Pendapatan',
            self::ANALYSIS_EXPENSE => 'Lihat Analisa Pengeluaran',
            self::ANALYSIS_BUSY_HOURS => 'Lihat Analisa Jam Sibuk',
            self::ANALYSIS_PROFIT_ORDERS => 'Lihat Analisa Total Order',
            self::ANALYSIS_PROFIT_HPP => 'Lihat Analisa HPP',
            self::ANALYSIS_PROFIT_GROSS => 'Lihat Analisa Laba Kotor',
            self::ANALYSIS_PROFIT_MARGIN => 'Lihat Analisa Profit Margin',
            self::ANALYSIS_TOP_SUPPLIERS => 'Lihat Top 5 Supplier',
            self::ANALYSIS_TOP_CUSTOMERS => 'Lihat Top 5 Pelanggan',
            self::ANALYSIS_TOP_PRODUCTS => 'Lihat Top 5 Produk',

            self::EMPLOYEES_VIEW => 'Lihat Pegawai',
            self::EMPLOYEES_CREATE => 'Tambah Pegawai',
            self::EMPLOYEES_UPDATE => 'Ubah Pegawai',
            self::EMPLOYEES_DELETE => 'Hapus Pegawai',
            self::EMPLOYEES_RESET_PASSWORD => 'Reset Kata Sandi Pegawai',
            self::EMPLOYEES_TOGGLE_STATUS => 'Ubah Status Pegawai',

            self::ATTENDANCES_VIEW => 'Lihat Presensi',
            self::ATTENDANCES_CREATE => 'Presensi Masuk/Pulang',
            self::ATTENDANCES_DELETE => 'Hapus Presensi',
            self::ATTENDANCES_MANAGE => 'Kelola Semua Presensi',

            self::LEAVE_REQUESTS_VIEW => 'Lihat Cuti',
            self::LEAVE_REQUESTS_CREATE => 'Ajukan Cuti',
            self::LEAVE_REQUESTS_UPDATE => 'Ubah Pengajuan Cuti',
            self::LEAVE_REQUESTS_DELETE => 'Hapus Pengajuan Cuti',
            self::LEAVE_REQUESTS_VERIFY => 'Setujui/Tolak Cuti',

            self::CATEGORIES_VIEW => 'Lihat Kategori',
            self::CATEGORIES_CREATE => 'Tambah Kategori',
            self::CATEGORIES_UPDATE => 'Ubah Kategori',
            self::CATEGORIES_DELETE => 'Hapus Kategori',

            self::SUPPLIERS_VIEW => 'Lihat Supplier',
            self::SUPPLIERS_CREATE => 'Tambah Supplier',
            self::SUPPLIERS_UPDATE => 'Ubah Supplier',
            self::SUPPLIERS_DELETE => 'Hapus Supplier',

            self::CUSTOMERS_VIEW => 'Lihat Pelanggan',
            self::CUSTOMERS_CREATE => 'Tambah Pelanggan',
            self::CUSTOMERS_UPDATE => 'Ubah Pelanggan',
            self::CUSTOMERS_DELETE => 'Hapus Pelanggan',

            self::PRODUCTS_VIEW => 'Lihat Produk',
            self::PRODUCTS_CREATE => 'Tambah Produk',
            self::PRODUCTS_UPDATE => 'Ubah Produk',
            self::PRODUCTS_DELETE => 'Hapus Produk',
            self::PRODUCTS_TOGGLE_STATUS => 'Ubah Status Produk',

            self::RAW_MATERIALS_VIEW => 'Lihat Bahan Baku',
            self::RAW_MATERIALS_CREATE => 'Tambah Bahan Baku',
            self::RAW_MATERIALS_UPDATE => 'Ubah Bahan Baku',
            self::RAW_MATERIALS_DELETE => 'Hapus Bahan Baku',
            self::RAW_MATERIALS_TOGGLE_STATUS => 'Ubah Status Bahan Baku',

            self::PURCHASES_VIEW => 'Lihat Belanja',
            self::PURCHASES_CREATE => 'Catat Belanja',
            self::PURCHASES_UPDATE => 'Ubah Belanja',
            self::PURCHASES_DELETE => 'Hapus Belanja',

            self::ORDERS_VIEW => 'Lihat Pesanan',
            self::ORDERS_CREATE => 'Tambah Pesanan',
            self::ORDERS_UPDATE => 'Ubah Pesanan',
            self::ORDERS_DELETE => 'Hapus Pesanan',
            self::ORDERS_SEND => 'Kirim Pesanan',
            self::ORDERS_COMPLETE => 'Selesaikan Pesanan',
            self::ORDERS_CANCEL => 'Batalkan Pesanan',

            self::CUTTINGS_VIEW => 'Lihat Cutting',
            self::CUTTINGS_CREATE => 'Tambah Cutting',
            self::CUTTINGS_UPDATE => 'Ubah Cutting',
            self::CUTTINGS_DELETE => 'Hapus Cutting',
            self::CUTTINGS_COMPLETE => 'Selesaikan Cutting',
            self::CUTTINGS_VERIFY => 'Verifikasi Cutting',
            self::CUTTINGS_REJECT => 'Tolak Cutting',

            self::OWNER_VERIFICATIONS_VIEW => 'Lihat Verifikasi Owner',
            self::OWNER_VERIFICATIONS_VERIFY => 'Setujui Verifikasi Owner',
            self::OWNER_VERIFICATIONS_REJECT => 'Tolak Verifikasi Owner',

            self::STOCKS_VIEW => 'Lihat Stok',

            self::STOK_OPNAMES_VIEW => 'Lihat Stok Opname',
            self::STOK_OPNAMES_CREATE => 'Tambah Stok Opname',
            self::STOK_OPNAMES_UPDATE => 'Ubah Stok Opname',
            self::STOK_OPNAMES_DELETE => 'Hapus Stok Opname',
            self::STOK_OPNAMES_SUBMIT => 'Ajukan Verifikasi Stok Opname',
            self::STOK_OPNAMES_VERIFY => 'Verifikasi Stok Opname',

            self::CASH_VIEW => 'Lihat Kas',
            self::CASH_DEPOSIT => 'Setor Kas',
            self::CASH_WITHDRAW => 'Tarik Kas',
            self::CASH_UPDATE => 'Ubah Setor Kas',
            self::CASH_DELETE => 'Hapus Setor Kas',

            self::EXPENSES_VIEW => 'Lihat Pengeluaran',
            self::EXPENSES_CREATE => 'Tambah Pengeluaran',
            self::EXPENSES_UPDATE => 'Ubah Pengeluaran',
            self::EXPENSES_DELETE => 'Hapus Pengeluaran',

            self::EMPLOYEE_ADVANCES_VIEW => 'Lihat Kasbon',
            self::EMPLOYEE_ADVANCES_CREATE => 'Ajukan Kasbon',
            self::EMPLOYEE_ADVANCES_UPDATE => 'Ubah Kasbon',
            self::EMPLOYEE_ADVANCES_DELETE => 'Hapus Kasbon',
            self::EMPLOYEE_ADVANCES_VERIFY => 'Setujui/Tolak Kasbon',
            self::EMPLOYEE_ADVANCES_PAY => 'Pelunasi Kasbon',

            self::PAYROLL_VIEW => 'Lihat Gaji',
            self::PAYROLL_ADJUST => 'Sesuaikan Gaji',

            self::SETTINGS_VIEW => 'Lihat Pengaturan Aplikasi',
            self::SETTINGS_UPDATE => 'Ubah Pengaturan Aplikasi',

            self::ACTIVITY_LOGS_VIEW => 'Lihat Log Aktivitas',

            self::ROLES_VIEW => 'Lihat Role',
            self::ROLES_CREATE => 'Tambah Role',
            self::ROLES_UPDATE => 'Ubah Role',
            self::ROLES_DELETE => 'Hapus Role',
        };
    }

    public function group(): string
    {
        return match ($this) {
            self::DASHBOARD_VIEW, self::DASHBOARD_ATTENDANCE, self::DASHBOARD_CASH,
            self::DASHBOARD_REVENUE, self::DASHBOARD_EXPENSE, self::DASHBOARD_ORDERS_CHANNEL,
            self::DASHBOARD_ORDERS_PAYMENT, self::DASHBOARD_ORDERS_MARKETING, self::DASHBOARD_ORDERS_STATUS => 'Umum',
            self::ANALYSIS_VIEW, self::ANALYSIS_ATTENDANCE, self::ANALYSIS_CASH,
            self::ANALYSIS_RAW_MATERIALS, self::ANALYSIS_PRODUCT_STOCK, self::ANALYSIS_REVENUE,
            self::ANALYSIS_EXPENSE, self::ANALYSIS_BUSY_HOURS, self::ANALYSIS_PROFIT_ORDERS,
            self::ANALYSIS_PROFIT_HPP, self::ANALYSIS_PROFIT_GROSS, self::ANALYSIS_PROFIT_MARGIN,
            self::ANALYSIS_TOP_SUPPLIERS, self::ANALYSIS_TOP_CUSTOMERS, self::ANALYSIS_TOP_PRODUCTS => 'Umum',
            self::EMPLOYEES_VIEW, self::EMPLOYEES_CREATE, self::EMPLOYEES_UPDATE,
            self::EMPLOYEES_DELETE, self::EMPLOYEES_RESET_PASSWORD, self::EMPLOYEES_TOGGLE_STATUS => 'Pegawai',
            self::ATTENDANCES_VIEW, self::ATTENDANCES_CREATE, self::ATTENDANCES_DELETE,
            self::ATTENDANCES_MANAGE => 'Presensi',
            self::LEAVE_REQUESTS_VIEW, self::LEAVE_REQUESTS_CREATE, self::LEAVE_REQUESTS_UPDATE,
            self::LEAVE_REQUESTS_DELETE, self::LEAVE_REQUESTS_VERIFY => 'Cuti',
            self::CATEGORIES_VIEW, self::CATEGORIES_CREATE, self::CATEGORIES_UPDATE,
            self::CATEGORIES_DELETE => 'Kategori',
            self::SUPPLIERS_VIEW, self::SUPPLIERS_CREATE, self::SUPPLIERS_UPDATE,
            self::SUPPLIERS_DELETE => 'Supplier',
            self::CUSTOMERS_VIEW, self::CUSTOMERS_CREATE, self::CUSTOMERS_UPDATE,
            self::CUSTOMERS_DELETE => 'Pelanggan',
            self::PRODUCTS_VIEW, self::PRODUCTS_CREATE, self::PRODUCTS_UPDATE,
            self::PRODUCTS_DELETE, self::PRODUCTS_TOGGLE_STATUS => 'Produk',
            self::RAW_MATERIALS_VIEW, self::RAW_MATERIALS_CREATE, self::RAW_MATERIALS_UPDATE,
            self::RAW_MATERIALS_DELETE, self::RAW_MATERIALS_TOGGLE_STATUS => 'Bahan Baku',
            self::PURCHASES_VIEW, self::PURCHASES_CREATE, self::PURCHASES_UPDATE,
            self::PURCHASES_DELETE => 'Belanja',
            self::ORDERS_VIEW, self::ORDERS_CREATE, self::ORDERS_UPDATE,
            self::ORDERS_DELETE, self::ORDERS_SEND, self::ORDERS_COMPLETE,
            self::ORDERS_CANCEL => 'Pesanan',
            self::CUTTINGS_VIEW, self::CUTTINGS_CREATE, self::CUTTINGS_UPDATE,
            self::CUTTINGS_DELETE, self::CUTTINGS_COMPLETE, self::CUTTINGS_VERIFY,
            self::CUTTINGS_REJECT => 'Cutting',
            self::OWNER_VERIFICATIONS_VIEW, self::OWNER_VERIFICATIONS_VERIFY,
            self::OWNER_VERIFICATIONS_REJECT => 'Verifikasi Owner',
            self::STOCKS_VIEW,
            self::STOK_OPNAMES_VIEW, self::STOK_OPNAMES_CREATE, self::STOK_OPNAMES_UPDATE,
            self::STOK_OPNAMES_DELETE, self::STOK_OPNAMES_SUBMIT, self::STOK_OPNAMES_VERIFY => 'Stok',
            self::CASH_VIEW, self::CASH_DEPOSIT, self::CASH_WITHDRAW, self::CASH_UPDATE, self::CASH_DELETE => 'Kas',
            self::EXPENSES_VIEW, self::EXPENSES_CREATE, self::EXPENSES_UPDATE,
            self::EXPENSES_DELETE => 'Pengeluaran',
            self::EMPLOYEE_ADVANCES_VIEW, self::EMPLOYEE_ADVANCES_CREATE, self::EMPLOYEE_ADVANCES_UPDATE,
            self::EMPLOYEE_ADVANCES_DELETE, self::EMPLOYEE_ADVANCES_VERIFY,
            self::EMPLOYEE_ADVANCES_PAY => 'Kasbon',
            self::PAYROLL_VIEW, self::PAYROLL_ADJUST => 'Gaji',
            self::SETTINGS_VIEW, self::SETTINGS_UPDATE => 'Pengaturan Aplikasi',
            self::ACTIVITY_LOGS_VIEW => 'Log Aktivitas',
            self::ROLES_VIEW, self::ROLES_CREATE, self::ROLES_UPDATE,
            self::ROLES_DELETE => 'Role & Permission',
        };
    }

    /**
     * @return list<string>
     */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }
}
