-- إضافة Routes لنظام تسجيل الأنشطة (User Activity Logs)
-- يتم تنفيذ هذه الأوامر في SQL Server Management Studio

-- 1. صفحة عرض جميع السجلات (الرئيسية)
INSERT INTO [system_routes] (
    [is_active],
    [prefix],
    [name],
    [url],
    [method],
    [type],
    [controller],
    [view_name],
    [middleware],
    [constraints],
    [route_properties],
    [auth],
    [main_group],
    [parent_id],
    [order],
    [created_at],
    [updated_at]
) VALUES (
    1,
    NULL,
    'admin.logs.index',
    '/admin/logs',
    'GET',
    'volt',
    NULL,
    'livewire.backend.system.logs-index',
    '["auth"]',
    NULL,
    '{"display_name":{"en":"Activity Logs","ar":"سجلات الأنشطة"},"description":{"en":"View all system activity logs","ar":"عرض جميع سجلات الأنشطة في النظام"},"display_icon":"clipboard-list"}',
    1,
    'system',
    NULL,
    1,
    GETDATE(),
    GETDATE()
);

-- 2. صفحة عرض تفاصيل سجل محدد
INSERT INTO [system_routes] (
    [is_active],
    [prefix],
    [name],
    [url],
    [method],
    [type],
    [controller],
    [view_name],
    [middleware],
    [constraints],
    [route_properties],
    [auth],
    [main_group],
    [parent_id],
    [order],
    [created_at],
    [updated_at]
) VALUES (
    1,
    NULL,
    'admin.logs.show',
    '/admin/logs/{id}',
    'GET',
    'volt',
    NULL,
    'livewire.backend.system.logs-show',
    '["auth"]',
    '{"id":"[0-9]+"}',
    '{"display_name":{"en":"Log Details","ar":"تفاصيل السجل"},"description":{"en":"View activity log details","ar":"عرض تفاصيل سجل النشاط"},"display_icon":"eye"}',
    1,
    'system',
    NULL,
    2,
    GETDATE(),
    GETDATE()
);

-- 3. صفحة عرض سجلات مستخدم محدد
INSERT INTO [system_routes] (
    [is_active],
    [prefix],
    [name],
    [url],
    [method],
    [type],
    [controller],
    [view_name],
    [middleware],
    [constraints],
    [route_properties],
    [auth],
    [main_group],
    [parent_id],
    [order],
    [created_at],
    [updated_at]
) VALUES (
    1,
    NULL,
    'admin.logs.user',
    '/admin/logs/user/{userId}',
    'GET',
    'volt',
    NULL,
    'livewire.backend.system.logs-user',
    '["auth"]',
    '{"userId":"[0-9]+"}',
    '{"display_name":{"en":"User Logs","ar":"سجلات المستخدم"},"description":{"en":"View user activity logs","ar":"عرض سجلات نشاط المستخدم"},"display_icon":"user-circle"}',
    1,
    'system',
    NULL,
    3,
    GETDATE(),
    GETDATE()
);

GO

-- التحقق من إضافة الـ Routes بنجاح
SELECT
    [id],
    [name],
    [url],
    [method],
    [view_name],
    [auth],
    JSON_VALUE([route_properties], '$.display_name.ar') AS display_name_ar,
    [created_at]
FROM [system_routes]
WHERE [name] LIKE 'admin.logs%'
ORDER BY [order];

GO
