CREATE OR REPLACE FUNCTION public.fn_admin_list_notify_templates(p_type text DEFAULT ''::text)
 RETURNS TABLE(template_key text, lang text, subject text, body_text text)
 LANGUAGE sql
 STABLE
AS $function$
  SELECT
    template_key::text,
    language::text AS lang,
    subject::text,
    body_text
  FROM public.email_templates
  WHERE active = true
    AND (p_type = '' OR template_key LIKE 'CONTACT_%')
  ORDER BY template_key, language;
$function$
;
