-- ===========================================================
-- User Panel Test Data Seeder
-- Run with:  mysql -u root -p your_db_name < seed_panel.sql
-- ===========================================================
-- This script assumes the following already exist:
--   1. At least one client (id = 1) in `clients` table
--   2. At least one property (id = 1) in `properties` table  
--   3. At least one city (id = 1) in `cities` table
--   4. At least one package (id = 1) in `packages` table
-- If not, uncomment the SAFETY INSERTs below first.
-- ===========================================================

-- ===================== NOTIFICATIONS =====================
INSERT INTO `notifications` (`id`, `type`, `notifiable_type`, `notifiable_id`, `data`, `read_at`, `created_at`, `updated_at`) VALUES
(UUID(), 'App\\Notifications\\GeneralNotification', 'App\\Models\\Client', 1, '{"title":"تمت إضافة ميزات جديدة","message":"اكتشف الميزات الجديدة المحسّنة في التطبيق."}', NULL, NOW(), NOW()),
(UUID(), 'App\\Notifications\\GeneralNotification', 'App\\Models\\Client', 1, '{"title":"تحديث أمني مهم","message":"قم بتحديث التطبيق للحصول على أحدث تحسينات الأمان."}', NULL, NOW() - INTERVAL 1 DAY, NOW() - INTERVAL 1 DAY),
(UUID(), 'App\\Notifications\\GeneralNotification', 'App\\Models\\Client', 1, '{"title":"عرض خاص","message":"استفد من العرض الخاص لفترة محدودة داخل التطبيق."}', NOW(), NOW() - INTERVAL 2 DAY, NOW() - INTERVAL 2 DAY);

-- ===================== FAVORITES =====================
-- Favorite a property (assumes properties with id 1 and 2 exist)
INSERT INTO `favorites` (`client_id`, `property_id`, `created_at`, `updated_at`) VALUES
(1, 1, NOW(), NOW()),
(1, 2, NOW() - INTERVAL 1 DAY, NOW() - INTERVAL 1 DAY)
ON DUPLICATE KEY UPDATE `updated_at` = NOW();

-- ===================== INTERESTS =====================
INSERT INTO `interests` (`client_id`, `city_ids`, `governorate_ids`, `district_ids`, `created_at`, `updated_at`) VALUES
(1, '[1,2]', '[]', '[]', NOW(), NOW())
ON DUPLICATE KEY UPDATE `city_ids` = '[1,2]', `updated_at` = NOW();

-- ===================== TAWTHEEQ CONTRACTS =====================
INSERT INTO `tawtheeq_contracts` (`client_id`, `type`, `property_type`, `rent_amount`, `payment_cycle`, `contract_duration`, `status`, `lessor_id_number`, `created_at`, `updated_at`) VALUES
(1, 'residential', 'apartment', 3500.00, 'monthly', 12, 'paid', '1234567890', NOW(), NOW()),
(1, 'commercial', 'office', 8000.00, 'quarterly', 24, 'pending_review', '0987654321', NOW() - INTERVAL 3 DAY, NOW() - INTERVAL 3 DAY),
(1, 'residential', 'villa', 5000.00, 'monthly', 12, 'draft', '1122334455', NOW() - INTERVAL 5 DAY, NOW() - INTERVAL 5 DAY);

-- ===================== CLIENT FINANCE REQUESTS =====================
INSERT INTO `client_finance_requests` (`client_id`, `name`, `job`, `salary`, `bank`, `property_price`, `status`, `created_at`, `updated_at`) VALUES
(1, 'محمد أحمد', 'مهندس برمجيات', 15000.00, 'البنك الأهلي', 500000.00, 'completed', NOW(), NOW()),
(1, 'محمد أحمد', 'مهندس برمجيات', 15000.00, 'بنك الراجحي', 750000.00, 'reviewing', NOW() - INTERVAL 2 DAY, NOW() - INTERVAL 2 DAY);

-- ===================== PACKAGES (if empty) =====================
-- Uncomment if packages table is empty:
-- INSERT INTO `packages` (`ar_title`, `en_title`, `type`, `ar_description`, `en_description`, `tenant_type`, `price`, `created_at`, `updated_at`) VALUES
-- ('باقة الزائر', 'Visitor', 'monthly', 'باقة مجانية للمستخدمين الجدد', 'Free package for new users', 'normal', 0, NOW(), NOW()),
-- ('Premium', 'Premium', 'monthly', 'باقة مميزة مع ميزات إضافية', 'Premium package with extra features', 'premium', 199, NOW(), NOW()),
-- ('VIP', 'VIP', 'monthly', 'باقة VIP مع جميع المزايا', 'VIP package with all features', 'vip', 299, NOW(), NOW());

-- ===================== CLIENT PACKAGES (subscription) =====================
-- Uncomment the line below if a package with id=2 exists in your packages table:
-- INSERT INTO `client_packages` (`client_id`, `active_package_id`, `start_date`, `end_date`, `created_at`, `updated_at`) VALUES
-- (1, 2, CURDATE(), CURDATE() + INTERVAL 30 DAY, NOW(), NOW());

SELECT 'Seed completed successfully!' AS status;
