/*
  # Add social work events to personal_events

  1. Insert social work events
  2. Insert corresponding media for each event
*/

-- Insert social work events
INSERT INTO personal_events (title, slug, description, event_date, location, published, display_order) VALUES
  ('Social Work at Native Village of Kodamdeser', 'social-work-kodamdeser', 'Community service and development work at my native village of Kodamdeser', '2024-01-01', 'Kodamdeser Village', true, 1),
  ('Supporting Girl Child Education at Native Village', 'girl-child-education-support', 'Educational support and empowerment initiatives for girl children in our native village', '2024-02-01', 'Native Village', true, 2),
  ('Marudhar Food Security Programme - 2024', 'food-security-2024', 'Annual food security programme providing essential supplies to those in need', '2024-03-01', 'Various Locations', true, 3),
  ('Marudhar Food Security Programme - 2023', 'food-security-2023', 'Food security programme activities from 2023', '2023-03-01', 'Various Locations', true, 4),
  ('Marudhar Food Security Programme - 2022', 'food-security-2022', 'Food security programme activities from 2022', '2022-03-01', 'Various Locations', true, 5)
ON CONFLICT (slug) DO NOTHING;

-- Insert media for social work events
DO $$
DECLARE
  kodamdeser_event_id uuid;
  girl_education_event_id uuid;
  food_2024_event_id uuid;
  food_2023_event_id uuid;
  food_2022_event_id uuid;
BEGIN
  -- Get event IDs
  SELECT id INTO kodamdeser_event_id FROM personal_events WHERE slug = 'social-work-kodamdeser';
  SELECT id INTO girl_education_event_id FROM personal_events WHERE slug = 'girl-child-education-support';
  SELECT id INTO food_2024_event_id FROM personal_events WHERE slug = 'food-security-2024';
  SELECT id INTO food_2023_event_id FROM personal_events WHERE slug = 'food-security-2023';
  SELECT id INTO food_2022_event_id FROM personal_events WHERE slug = 'food-security-2022';
  
  -- Insert media for Kodamdeser social work
  IF kodamdeser_event_id IS NOT NULL THEN
    INSERT INTO personal_media (event_id, title, media_url, media_type, display_order, tags) VALUES
      (kodamdeser_event_id, 'Community Development Work 1', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpg/2024/12/6/2024-12-6-12-12-32-148448/o.jpg', 'image', 1, ARRAY['social-work', 'community', 'village']),
      (kodamdeser_event_id, 'Community Development Work 2', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpg/2024/12/6/2024-12-6-12-12-1-34456/o.jpg', 'image', 2, ARRAY['social-work', 'community', 'village']);
  END IF;
  
  -- Insert media for girl child education
  IF girl_education_event_id IS NOT NULL THEN
    INSERT INTO personal_media (event_id, title, media_url, media_type, display_order, tags) VALUES
      (girl_education_event_id, 'Educational Support Initiative 1', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpg/2024/12/6/2024-12-6-12-11-8-404270/o.jpg', 'image', 1, ARRAY['education', 'girl-child', 'empowerment']),
      (girl_education_event_id, 'Educational Support Initiative 2', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpg/2024/12/6/2024-12-6-12-10-52-592877/o.jpg', 'image', 2, ARRAY['education', 'girl-child', 'empowerment']),
      (girl_education_event_id, 'Educational Support Initiative 3', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpg/2024/12/6/2024-12-6-12-11-1-832123/o.jpg', 'image', 3, ARRAY['education', 'girl-child', 'empowerment']);
  END IF;
  
  -- Insert media for food security 2024
  IF food_2024_event_id IS NOT NULL THEN
    INSERT INTO personal_media (event_id, title, media_url, media_type, display_order, tags) VALUES
      (food_2024_event_id, 'Food Distribution 2024 - Event 1', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpeg/2024/12/6/2024-12-6-12-7-13-750351/o.jpeg', 'image', 1, ARRAY['food-security', '2024', 'community-service']),
      (food_2024_event_id, 'Food Distribution 2024 - Event 2', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpeg/2024/12/6/2024-12-6-12-7-14-750645/o.jpeg', 'image', 2, ARRAY['food-security', '2024', 'community-service']);
  END IF;
  
  -- Insert media for food security 2023
  IF food_2023_event_id IS NOT NULL THEN
    INSERT INTO personal_media (event_id, title, media_url, media_type, display_order, tags) VALUES
      (food_2023_event_id, 'Food Distribution 2023 - Event 1', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpeg/2024/12/6/2024-12-6-12-1-48-157263/o.jpeg', 'image', 1, ARRAY['food-security', '2023', 'community-service']),
      (food_2023_event_id, 'Food Distribution 2023 - Event 2', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpeg/2024/12/6/2024-12-6-12-1-53-346603/o.jpeg', 'image', 2, ARRAY['food-security', '2023', 'community-service']),
      (food_2023_event_id, 'Food Distribution 2023 - Event 3', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpeg/2024/12/6/2024-12-6-12-1-47-454432/o.jpeg', 'image', 3, ARRAY['food-security', '2023', 'community-service']);
  END IF;
  
  -- Insert media for food security 2022
  IF food_2022_event_id IS NOT NULL THEN
    INSERT INTO personal_media (event_id, title, media_url, media_type, display_order, tags) VALUES
      (food_2022_event_id, 'Food Distribution 2022 - Event 1', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpeg/2024/12/6/2024-12-6-12-5-23-826476/o.jpeg', 'image', 1, ARRAY['food-security', '2022', 'community-service']),
      (food_2022_event_id, 'Food Distribution 2022 - Event 2', 'https://rajendermarudevelop.marucoins.in/uploadsnew/jpeg/2024/12/6/2024-12-6-12-5-22-686052/o.jpeg', 'image', 2, ARRAY['food-security', '2022', 'community-service']);
  END IF;
END $$;