PageSourceSearch

https://gentlebirth.com/assets/AdminProviderProfileQuestions-CwiR4_BM.js

js gentlebirth.com collected 2026-09-24 12:46:01 UTC 13,921 bytes, 3 lines download raw bytes

1import{x as m,at as Q,j as e,B as C,h as T,a6 as E,a7 as M,a8 as A,aQ as B,_ as x,i as O,z as F,Q as S,bg as L,bh as V,bi as z,bj as D,bk as I,aG as $,aF as R,Z as i,a0 as N,$ as H,bl as K,y as b,J as k}from"./index-DI1iMexg.js";import{S as _,a as y,b as v,c as f,d as c}from"./select-BwHsxmBJ.js";import{S as J}from"./square-check-big-F3854qCK.js";import{P as W}from"./plus-B4lgIxsv.js";import{P as Y}from"./pencil-DK693UFz.js";import"./chevron-up-n28B7Z5v.js";const G={id:"",attribute_key:"",category:"experience",question_text:"",helper_text:"",explanation_text:"",answer_type:"single_select",answer_options:[],matching_impact:50,priority_weight:1,stability:"stable",expires_after_days:null,contexts:["dashboard","profile"],trigger_terms:[],service_slugs:[],sensitive_data_class:"standard",is_active:!0,display_order:100},U=n=>n.map(o=>`${o.label} | ${o.value}`).join(`
2`),P=n=>n.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),Z=n=>n.split(`
3`).map(o=>o.trim()).filter(Boolean).map(o=>{const[d,t]=o.split("|").map(r=>r.trim());return{label:d,value:t||P(d)}}),q=n=>n.split(",").map(o=>o.trim()).filter(Boolean),X=({question:n,onClose:o})=>{const d=$(),[t,r]=m.useState(n),[h,l]=m.useState(U(n.answer_options)),g=["single_select","multi_select","boolean"].includes(t.answer_type),u=R({mutationFn:async()=>{const s=g?Z(h):[];if(!t.attribute_key||!t.question_text||!t.helper_text||!t.explanation_text)throw new Error("Key, question, helper text, and explanation are required.");if(g&&s.length===0)throw new Error("Add at least one answer option.");if(t.contexts.length===0)throw new Error("Choose at least one display context.");const a={attribute_key:P(t.attribute_key),category:t.category,question_text:t.question_text.trim(),helper_text:t.helper_text.trim(),explanation_text:t.explanation_text.trim(),answer_type:t.answer_type,answer_options:s,matching_impact:t.matching_impact,priority_weight:t.priority_weight,stability:t.stability,expires_after_days:t.expires_after_days,contexts:t.contexts,trigger_terms:t.trigger_terms,service_slugs:t.service_slugs,sensitive_data_class:t.sensitive_data_class,is_active:t.is_active,display_order:t.display_order},j=t.id?b.from("provider_profile_questions").update(a).eq("id",t.id):b.from("provider_profile_questions").insert(a),{error:w}=await j;if(w)throw w},onSuccess:async()=>{await d.invalidateQueries({queryKey:["admin-provider-profile-questions"]}),k.success(t.id?"Matching question updated.":"Matching question created."),o()},onError:s=>k.error(s.message)}),p=(s,a)=>{r(j=>({...j,contexts:a?[...new Set([...j.contexts,s])]:j.contexts.filter(w=>w!==s)}))};return e.jsxs("div",{className:"mt-6 space-y-5 pb-8",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"question_text",children:"Question"}),e.jsx(N,{id:"question_text",value:t.question_text,onChange:s=>r({...t,question_text:s.target.value}),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"attribute_key",children:"Attribute key"}),e.jsx(x,{id:"attribute_key",value:t.attribute_key,disabled:!!t.id,onChange:s=>r({...t,attribute_key:s.target.value}),placeholder:"vbac_experience"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Category"}),e.jsxs(_,{value:t.category,onValueChange:s=>r({...t,category:s}),children:[e.jsx(y,{children:e.jsx(v,{})}),e.jsx(f,{children:["eligibility","experience","preferences","trust","operations"].map(s=>e.jsx(c,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"helper_text",children:"Why the provider is seeing this"}),e.jsx(N,{id:"helper_text",value:t.helper_text,onChange:s=>r({...t,helper_text:s.target.value}),rows:2})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"explanation_text",children:"How the answer improves matching"}),e.jsx(N,{id:"explanation_text",value:t.explanation_text,onChange:s=>r({...t,explanation_text:s.target.value}),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Answer type"}),e.jsxs(_,{value:t.answer_type,onValueChange:s=>r({...t,answer_type:s}),children:[e.jsx(y,{children:e.jsx(v,{})}),e.jsxs(f,{children:[e.jsx(c,{value:"single_select",children:"One choice"}),e.jsx(c,{value:"multi_select",children:"Multiple choices"}),e.jsx(c,{value:"boolean",children:"Yes / no"}),e.jsx(c,{value:"number",children:"Number"}),e.jsx(c,{value:"text",children:"Short text"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Stability"}),e.jsxs(_,{value:t.stability,onValueChange:s=>r({...t,stability:s}),children:[e.jsx(y,{children:e.jsx(v,{})}),e.jsxs(f,{children:[e.jsx(c,{value:"stable",children:"Stable"}),e.jsx(c,{value:"slow",children:"Changes occasionally"}),e.jsx(c,{value:"dynamic",children:"Changes often"})]})]})]}),g&&e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"answer_options",children:"Answer options"}),e.jsx(N,{id:"answer_options",value:h,onChange:s=>l(s.target.value),rows:6,placeholder:"This is my specialty | specialty"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"One per line: provider-facing label | stored_value"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"matching_impact",children:"Matching impact (0-100)"}),e.jsx(x,{id:"matching_impact",type:"number",min:0,max:100,value:t.matching_impact,onChange:s=>r({...t,matching_impact:Number(s.target.value)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"priority_weight",children:"Priority weight"}),e.jsx(x,{id:"priority_weight",type:"number",min:.01,max:100,step:.
305,value:t.priority_weight,onChange:s=>r({...t,priority_weight:Number(s.target.value)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"expires_after_days",children:"Refresh after days"}),e.jsx(x,{id:"expires_after_days",type:"number",min:1,max:3650,value:t.expires_after_days??"",onChange:s=>r({...t,expires_after_days:s.target.value?Number(s.target.value):null}),placeholder:"Never"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"display_order",children:"Display order"}),e.jsx(x,{id:"display_order",type:"number",value:t.display_order,onChange:s=>r({...t,display_order:Number(s.target.value)})})]}),e.jsxs("fieldset",{className:"space-y-3 sm:col-span-2",children:[e.jsx("legend",{className:"text-sm font-medium",children:"Where this can appear"}),e.jsx("div",{className:"flex flex-wrap gap-4",children:["dashboard","profile","match"].map(s=>e.jsxs(i,{className:"flex min-h-11 items-center gap-2 font-normal capitalize",children:[e.jsx(H,{checked:t.contexts.includes(s),onCheckedChange:a=>p(s,a===!0)})," ",s]},s))})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"trigger_terms",children:"Match trigger terms"}),e.jsx(x,{id:"trigger_terms",value:t.trigger_terms.join(", "),onChange:s=>r({...t,trigger_terms:q(s.target.value)}),placeholder:"vbac, vaginal birth after cesarean"})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(i,{htmlFor:"service_slugs",children:"Limit to service slugs (optional)"}),e.jsx(x,{id:"service_slugs",value:t.service_slugs.join(", "),onChange:s=>r({...t,service_slugs:q(s.target.value)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Data sensitivity"}),e.jsxs(_,{value:t.sensitive_data_class,onValueChange:s=>r({...t,sensitive_data_class:s}),children:[e.jsx(y,{children:e.jsx(v,{})}),e.jsxs(f,{children:[e.jsx(c,{value:"standard",children:"Standard"}),e.jsx(c,{value:"sensitive",children:"Sensitive"})]})]})]}),e.jsxs(i,{className:"flex min-h-11 items-center justify-between gap-4 rounded-xl border px-4 font-normal",children:["Active for providers",e.jsx(K,{checked:t.is_active,onCheckedChange:s=>r({...t,is_active:s})})]})]}),e.jsxs(C,{className:"min-h-11 w-full",disabled:u.isPending,onClick:()=>u.mutate(),children:[u.isPending&&e.jsx(F,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":"true"}),t.id?"Save question":"Create question"]})]})};function ne(){const[n,o]=m.useState(""),[d,t]=m.useState("all"),[r,h]=m.useState(null),{data:l,isLoading:g}=Q({queryKey:["admin-provider-profile-questions"],queryFn:async()=>{const[s,a]=await Promise.all([b.from("provider_profile_questions").select("*").order("display_order"),b.rpc("get_provider_profile_question_admin_stats")]);if(s.error)throw s.error;if(a.error)throw a.error;return{questions:s.data??[],stats:a.data??[]}}}),u=m.useMemo(()=>new Map(((l==null?void 0:l.stats)??[]).map(s=>[s.question_id,s])),[l==null?void 0:l.stats]),p=m.useMemo(()=>{const s=n.trim().toLowerCase();return((l==null?void 0:l.questions)??[]).filter(a=>d!=="all"&&a.category!==d?!1:s?[a.question_text,a.attribute_key,a.category,...a.trigger_terms].join(" ").toLowerCase().includes(s):!0)},[d,l==null?void 0:l.questions,n]);return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("header",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h1",{className:"flex items-center gap-2 text-3xl font-bold tracking-tight",children:[e.jsx(J,{className:"h-7 w-7 text-primary","aria-hidden":"true"})," Matching Questions"]}),e.jsx("p",{className:"max-w-3xl text-muted-foreground",children:"Collect useful details gradually, then use provider-confirmed answers to improve future eligibility and ranking. Questions never block provider access or send an offer."})]}),e.jsxs(C,{className:"min-h-11 gap-2",onClick:()=>h({...G}),children:[e.jsx(W,{className:"h-4 w-4","aria-hidden":"true"})," New question"]})]}),e.jsxs(T,{children:[e.jsxs(E,{className:"gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{children:[e.jsx(M,{children:"Question catalog"}),e.jsxs(A,{children:[p.length," question",p.length===1?"":"s"," shown. Only one eligible question is surfaced to a provider at a time."]})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative",children:[e.jsx(B,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),e.jsx(x,{value:n,onChange:s=>o(s.target.value),placeholder:"Search questions or triggers",className:"min-h-11 w-full pl-9 sm:w-72"})]}),e.jsxs(_,{value:d,onValueChange:t,children:[e.jsx(y,{className:"min-h-11 w-full sm:w-44",children:e.jsx(v,{})}),e.jsxs(f,{children:[e.jsx(c,{value:"all",children:"All categories"}),["eligibility","experience","preferences","trust","operations"].map(s=>e.jsx(c,{value:s,children:s},s))]})]})]})]}),e.jsx(O,{children:g?e.jsxs("div",{className:"flex items-center gap-3 py-12 text-muted-foreground",children:[e.jsx(F,{className:"h-4 w-4 animate-spin","aria-hidden":"true"})," Loading question catalog..."]}):p.length===0?e.jsx("p",{className:"py-12 text-muted-foreground",children:"No matching questions foun
3d."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs("table",{className:"w-full min-w-[900px] text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-xs uppercase tracking-wide text-muted-foreground",children:[e.jsx("th",{className:"py-3 pr-4",children:"Question"}),e.jsx("th",{className:"py-3 pr-4",children:"Category"}),e.jsx("th",{className:"py-3 pr-4",children:"Impact"}),e.jsx("th",{className:"py-3 pr-4",children:"Contexts"}),e.jsx("th",{className:"py-3 pr-4",children:"Answered"}),e.jsx("th",{className:"py-3 pr-4",children:"Skipped"}),e.jsx("th",{className:"py-3 pr-4",children:"Status"}),e.jsx("th",{className:"py-3"})]})}),e.jsx("tbody",{children:p.map(s=>{const a=u.get(s.id);return e.jsxs("tr",{className:"border-b align-top",children:[e.jsxs("td",{className:"max-w-md py-4 pr-4",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s.question_text}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.attribute_key})]}),e.jsx("td",{className:"py-4 pr-4 capitalize",children:s.category}),e.jsx("td",{className:"py-4 pr-4 font-semibold",children:s.matching_impact}),e.jsx("td",{className:"py-4 pr-4 capitalize",children:s.contexts.join(", ")}),e.jsx("td",{className:"py-4 pr-4",children:(a==null?void 0:a.answered_count)??0}),e.jsx("td",{className:"py-4 pr-4",children:(a==null?void 0:a.skipped_count)??0}),e.jsx("td",{className:"py-4 pr-4",children:e.jsx(S,{variant:s.is_active?"default":"secondary",children:s.is_active?"Active":"Paused"})}),e.jsx("td",{className:"py-3",children:e.jsx(C,{variant:"ghost",size:"icon",className:"min-h-11 min-w-11",onClick:()=>h(s),"aria-label":`Edit ${s.question_text}`,children:e.jsx(Y,{className:"h-4 w-4","aria-hidden":"true"})})})]},s.id)})})]})}),e.jsx("div",{className:"grid gap-3 md:hidden",children:p.map(s=>{const a=u.get(s.id);return e.jsxs("button",{type:"button",className:"min-h-11 rounded-xl border p-4 text-left",onClick:()=>h(s),children:[e.jsxs("span",{className:"flex items-start justify-between gap-3",children:[e.jsx("span",{className:"font-semibold text-foreground",children:s.question_text}),e.jsx(S,{variant:s.is_active?"default":"secondary",children:s.is_active?"Active":"Paused"})]}),e.jsxs("span",{className:"mt-3 block text-sm text-muted-foreground",children:["Impact ",s.matching_impact," · ",(a==null?void 0:a.answered_count)??0," answered · ",(a==null?void 0:a.skipped_count)??0," skipped"]})]},s.id)})})]})})]}),e.jsx(L,{open:!!r,onOpenChange:s=>!s&&h(null),children:e.jsxs(V,{className:"w-full overflow-y-auto sm:max-w-2xl",children:[e.jsxs(z,{children:[e.jsx(D,{children:r!=null&&r.id?"Edit matching question":"Create matching question"}),e.jsx(I,{children:"Provider-facing copy and deterministic matching settings. Changes affect future prompts and matches."})]}),r&&e.jsx(X,{question:r,onClose:()=>h(null)},r.id||"new")]})})]})}export{ne as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.