-- =============================================================================
-- nsp_contact_details.sql - wensp.org (NSP Foundation): general contact email becomes info@wensp.org and the
-- phone number becomes 202 207 6775, both in the site settings and in the home page's Get Involved block.
-- Only values that still hold the previous text are changed, so later edits in ABOS > Website are left alone.
-- (The partnerships email and where form submissions are emailed are not changed here.) Idempotent.
-- =============================================================================
SET @nsp_site := (SELECT id FROM dim_web_sites WHERE public_site_key = 'PTfrDRwhx2h3GYBlfJrrjMxgJPMpI2LrNsObjNvA5AZufmJS' AND is_deleted = 0 LIMIT 1);

UPDATE dim_web_sites SET contact_email = 'info@wensp.org'
WHERE id = @nsp_site AND contact_email COLLATE utf8mb4_bin = 'contact@nspfoundation.org' COLLATE utf8mb4_bin;

UPDATE dim_web_sites SET contact_phone = '202 207 6775'
WHERE id = @nsp_site AND contact_phone COLLATE utf8mb4_bin = '(804) 479-4784' COLLATE utf8mb4_bin;

UPDATE dim_web_pages SET layout_json = JSON_SET(layout_json, '$.blocks[6].props.contactEmail', 'info@wensp.org')
WHERE site_id = @nsp_site AND slug = 'home'
  AND JSON_UNQUOTE(JSON_EXTRACT(layout_json, '$.blocks[6].props.contactEmail')) COLLATE utf8mb4_bin = 'contact@nspfoundation.org' COLLATE utf8mb4_bin;

UPDATE dim_web_pages SET layout_json = JSON_SET(layout_json, '$.blocks[6].props.phone', '202 207 6775')
WHERE site_id = @nsp_site AND slug = 'home'
  AND JSON_UNQUOTE(JSON_EXTRACT(layout_json, '$.blocks[6].props.phone')) COLLATE utf8mb4_bin = '(804) 479-4784' COLLATE utf8mb4_bin;
