PageSourceSearch

https://dentalatlas.ai/assets/index-C8oP7tHi.js

js dentalatlas.ai collected 2026-10-05 12:14:42 UTC 7,131 bytes, 1 lines download raw bytes

1import{aR as $,aS as U,f as B,i1 as Q,r as a,hJ as G,aU as J,aC as A,b5 as C,c5 as Z,j as e,bL as W,bM as X,bN as Y,a8 as D,I as n,ab as f,S as ee,bk as se,bl as ae,bm as ie,bn as te,bo as le,bp as ce,bq as ne,br as re,bd as oe,be as de,bf as ue,bg as pe,aa as b,bi as me,E as R,bx as ge,by as he,bz as xe,bA as z}from"./main-Bt1WcCx3.js";import{u as je,D as ye,a as ve}from"./data-table-CkTwfjB4.js";import{p as Ce,a as M,b as T}from"./price-policies-BAxhjCGz.js";import{u as be}from"./use-debounce-DUlHXjWB.js";import{C as fe}from"./clinic-filter-combobox-aiFEwYbU.js";import{A as k}from"./clinic-picker-format-Blg8EnUh.js";import"./manual-list-pagination-DAo6sLgP.js";import"./clinic-picker-option-DDXyfjGb.js";function De(){const t=$(),d=U(),m=B(),l=Q({pricePolicy:["edit"]}),g=Q({pricePolicy:["delete"]}),[r,u]=a.useState(1),[o,x]=a.useState(G),[j,p]=a.useState(""),[y,P]=a.useState(""),[v,h]=a.useState(""),[S,i]=a.useState(!1),[O,N]=a.useState(!1),[I,w]=a.useState(null),_=be(s=>{u(1),p(s)},300),{data:E,isLoading:H}=J(Ce.list(t,{page:r,pageSize:o,search:j||void 0,status:v||void 0})),L=A(M.create.options(t,{onSuccess:(s,c)=>{d.invalidateQueries({queryKey:T.all}),i(!1),C.success(c.templateClinicId?"Price policy created from clinic prices":"Price policy created"),m({to:"/crm/price-policy/$policyId",params:{policyId:String(s.id)}})},onError:s=>{C.error(Z(s))}})),V=A(M.updateStatus.options(t,{onSuccess:()=>{d.invalidateQueries({queryKey:T.all}),C.success("Policy status updated")}})),K=A(M.delete.options(t,{onSuccess:()=>{d.invalidateQueries({queryKey:T.all}),N(!1),w(null),C.success("Price policy deleted")}})),q=[{accessorKey:"name",header:"Name",cell:({row:s})=>e.jsx("button",{className:"text-primary text-left font-medium hover:underline",onClick:()=>m({to:"/crm/price-policy/$policyId",params:{policyId:String(s.original.id)}}),children:s.original.name})},{accessorKey:"discount",header:"Discount",cell:({row:s})=>`${s.original.discount}%`},{accessorKey:"status",header:"Status",cell:({row:s})=>e.jsx(R,{variant:s.original.status==="active"?"default":"secondary",children:s.original.status})},{id:"clinics",header:"Clinics",cell:({row:s})=>e.jsx(R,{variant:"outline",children:s.original.clinicCount??0})},{accessorKey:"description",header:"Description",cell:({row:s})=>e.jsx("span",{className:"text-muted-foreground",children:s.original.description||"—"})},{id:"actions",cell:({row:s})=>e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"icon",className:"size-8",children:e.jsx(n.MoreHorizontal,{className:"size-4"})})}),e.jsxs(xe,{align:"end",children:[l?e.jsxs(z,{onClick:()=>V.mutate({id:s.original.id,status:s.original.status==="active"?"deactive":"active"}),children:[e.jsx(n.RefreshCw,{className:"mr-2 size-4"}),s.original.status==="active"?"Deactivate":"Activate"]}):null,e.jsxs(z,{onClick:()=>m({to:"/crm/price-policy/$policyId",params:{policyId:String(s.original.id)}}),children:[l?e.jsx(n.Pencil,{className:"mr-2 size-4"}):e.jsx(n.ArrowRight,{className:"mr-2 size-4"}),l?"Edit":"View"]}),g?e.jsxs(z,{className:"text-destructive focus:text-destructive",onClick:()=>{w(s.original),N(!0)},children:[e.jsx(n.Trash2,{className:"mr-2 size-4"}),"Delete"]}):null]})]})}],F=je({data:E?.items??[],columns:q,getCoreRowModel:ve(),manualPagination:!0,pageCount:E?.totalPages??0,state:{pagination:{pageIndex:r-1,pageSize:o}},onPaginationChange:s=>{if(typeof s!="function")return;const c=s({pageIndex:r-1,pageSize:o});c.pageIndex!==r-1&&u(c.pageIndex+1),c.pageSize!==o&&x(c.pageSize)}});return e.jsxs("div",{className:"flex w-full min-w-0 max-w-full flex-col gap-6",children:[e.jsxs(W,{children:[e.jsxs("div",{children:[e.jsx(X,{children:"Price Policy"}),e.jsx(Y,{children:l?"Manage organization-level clinic discount policies":"View organization-level clinic discount policies"})]}),l?e.jsxs(D,{onClick:()=>i(!0),children:[e.jsx(n.Plus,{className:"mr-1.5 size-4"}),"Add Price Policy"]}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(n.Search,{className:"text-muted-foreground absolute left-3 top-1/2 size-4 -translate-y-1/2"}),e.jsx(f,{placeholder:"Search policies...",value:y,onChange:s=>{P(s.target.value),_(s.target.value)},className:"pl-9"})]}
1),e.jsxs("select",{value:v,onChange:s=>{u(1),h(s.target.value)},className:"border-input bg-background h-9 rounded-md border px-3 text-sm",children:[e.jsx("option",{value:"",children:"All status"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"deactive",children:"Deactive"})]})]}),H?e.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((s,c)=>e.jsx(ee,{className:"h-12 w-full"},c))}):e.jsx(ye,{table:F}),e.jsx(Pe,{open:S,onOpenChange:i,onSubmit:s=>L.mutate(s),isPending:L.isPending}),e.jsx(se,{open:O,onOpenChange:N,children:e.jsxs(ae,{children:[e.jsxs(ie,{children:[e.jsx(te,{children:"Delete Price Policy"}),e.jsxs(le,{children:['Delete "',I?.name,'"? Clinics assigned to it will fall back to default pricing unless they have clinic prices.']})]}),e.jsxs(ce,{children:[e.jsx(ne,{children:"Cancel"}),e.jsx(re,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:K.isPending,onClick:()=>{I&&K.mutate({id:I.id})},children:"Delete"})]})]})})]})}function Pe({open:t,onOpenChange:d,onSubmit:m,isPending:l}){const[g,r]=a.useState(""),[u,o]=a.useState("0"),[x,j]=a.useState(""),[p,y]=a.useState(k);a.useEffect(()=>{t||(r(""),o("0"),j(""),y(k))},[t]);const P=Math.max(0,Math.min(100,Number(u)||0)),v=g.trim().length>0,h=p&&p!==k?Number(p):void 0,S=Number.isInteger(h)&&(h??0)>0;return e.jsx(oe,{open:t,onOpenChange:d,children:e.jsxs(de,{className:"sm:max-w-lg",children:[e.jsx(ue,{children:e.jsx(pe,{children:"Create Price Policy"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Name"}),e.jsx(f,{value:g,onChange:i=>r(i.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Discount (%)"}),e.jsx(f,{type:"number",min:"0",max:"100",value:u,onChange:i=>o(i.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Template clinic"}),e.jsx(fe,{value:p,onValueChange:y,includeDoctors:!1,placeholder:"No template clinic",searchPlaceholder:"Search clinic ID or name…",emptyMessage:"No clinics match that search.",className:"w-full"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Optional. Copy this clinic's current selling prices as policy item overrides. The clinic is not assigned, and clinic overrides are left unchanged."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Description"}),e.jsx(f,{value:x,onChange:i=>j(i.target.value)})]})]}),e.jsxs(me,{children:[e.jsx(D,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(D,{disabled:!v||l,onClick:()=>m({name:g.trim(),discount:P,status:"active",description:x.trim()||null,...S?{templateClinicId:h}:{}}),children:[l&&e.jsx(n.Loader2,{className:"mr-1.5 size-4 animate-spin"}),"Create"]})]})]})})}const we=De;export{we as component};

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.