PageSourceSearch

https://app.cortile.com/assets/NewRulePage-4rw6xLMg.js

js cortile.com collected 2026-10-10 00:16:41 UTC 6,133 bytes, 2 lines download raw bytes

1import{r as o,j as e,B as l,T as S,c0 as D,V as O,az as P,eI as E,i as M,g as F,eJ as _,eD as H,b7 as U,A as V,eK as Q,eL as $}from"./index-D3kpS0cr.js";import{O as R,a as C,T as q}from"./Skeletons-DWucM2OW.js";import{T as G}from"./TopBar-BnOpr_Gd.js";import{E as y}from"./EditableField-embyc3nO.js";import{S as J,a as w,c as K,L as X}from"./ListItem-CCMwRKpF.js";import{F as Y}from"./FilterSearchMenu-CcXtoud-.js";import{P as Z}from"./PageHeader-DVhhXO_M.js";import{S as ee}from"./SearchInput-BjQveMri.js";import{a as te}from"./ListItemHeader-B0N2_5qt.js";import{L as ae,A as se,T as L}from"./ListItemSkeleton-BijcCcei.js";import{A as re}from"./patterns-BOK3No2q.js";import{C as ie,a as s}from"./CommunitiesListHeader-DnABrTB3.js";import{f as ne}from"./files-bn7Xthl9.js";import{L as oe}from"./Lock-Ca84YQkt.js";import{L as I}from"./ListItemText-9H0eQ8SK.js";import"./Tabs-DKKxxlAt.js";import"./FilterSearchMenuSearch-BdMGgmRV.js";import"./Clear-auIChMaG.js";import"./ArrowDropDown-Tf7ysG19.js";import"./SwapVert-BPyjrlXE.js";import"./ArrowDropUp-D1b5xLlG.js";import"./Checkbox-FufQABsl.js";import"./RadioButtonChecked-KVSjK03F.js";import"./RadioButtonUnchecked-DesbRazY.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[a]="712a6f88-08c1-4e6d-ba9f-94abeec24de8",r._sentryDebugIdIdentifier="sentry-dbid-712a6f88-08c1-4e6d-ba9f-94abeec24de8")}catch{}})();const le=({allCommunities:r,selectedCommunityIds:a,onCommunityToggle:m,loading:h})=>{const[c,p]=o.useState(""),f=o.useMemo(()=>r.map(t=>({value:t.id,label:t.name||"",checked:a.includes(t.id)})),[r,a]),g=o.useMemo(()=>{const t=r.filter(i=>a.includes(i.id));return c?t.filter(i=>i.name?.toLowerCase().includes(c.toLowerCase())):t},[r,a,c]),d=a.length||3;return e.jsxs(R,{children:[e.jsx(C,{label:"Categories",variant:"inline",children:e.jsxs(l,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(oe,{sx:{fontSize:14,color:"text.disabled"}}),e.jsx(S,{component:"span",sx:{color:"text.disabled",fontSize:"inherit"},children:"No categories"})]})}),e.jsxs(C,{label:"Communities",children:[e.jsx(Z,{innerBoxSx:{paddingLeft:0,paddingRight:0},headerSx:{top:32},searchComponent:e.jsx(ee,{placeholder:"Search communities...",onSearchChange:p}),filterComponents:[e.jsx(Y,{options:f,buttonLabel:"Add Communities",searchPlaceholder:"Search communities...",onFilterChange:m,selectAll:!1,
1controlRowLabel:"Name",anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},paperSx:{marginLeft:"8px",marginBottom:"8px"}},"filter-menu")]}),e.jsxs(l,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(ie,{}),h&&Array.from({length:d<10?d:10}).map((t,i)=>e.jsxs(ae,{variant:"communities",size:"md",children:[e.jsx(se,{flexBasis:s[0].flexBasis,minWidth:s[0].minWidth,avatarSize:20}),e.jsx(L,{flexBasis:s[1].flexBasis,minWidth:s[1].minWidth}),e.jsx(L,{flexBasis:s[2].flexBasis,minWidth:s[2].minWidth}),e.jsx(te,{width:40})]},i)),!h&&g.map(t=>e.jsxs(J,{variant:"communities",size:"md",cursor:"default","data-list-item":!0,children:[e.jsx(re,{avatar:{src:t.avatar?ne(t.avatar):void 0,fallback:t.name?.[0]||"",color:D.black,size:20},primary:t.name,flexBasis:s[0].flexBasis,minWidth:s[0].minWidth}),e.jsx(w,{flexBasis:s[1].flexBasis,minWidth:s[1].minWidth,children:e.jsx(I,{children:t.homeCount})}),e.jsx(w,{flexBasis:s[2].flexBasis,minWidth:s[2].minWidth,children:e.jsx(I,{children:t.residentCount})}),e.jsx(K,{width:40,children:e.jsx(O,{size:"small",onClick:()=>m(t.id,!1),children:e.jsx(P,{fontSize:"small",sx:{color:i=>i.palette.grey[700]}})})})]},t.id))]})]}),a.length===0&&e.jsxs(l,{sx:{mt:3,p:2,backgroundColor:"action.hover",borderRadius:1,display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(E,{sx:{fontSize:20,color:"text.secondary"}}),e.jsx(S,{variant:"body2",sx:{color:"text.secondary"},children:"Select at least one community"})]})]})},Ne=()=>{const r=M(),{enqueueSnackbar:a}=F(),[m,h]=o.useState("overview"),[c,p]=o.useState(""),[f,g]=o.useState(""),[d,t]=o.useState([]),[i,b]=o.useState(!1),[B]=_(),{data:j,loading:T}=H({variables:{orderBy:"name"}}),k=o.useMemo(()=>U(j?.communities?.edges)||[],[j?.communities?.edges]),z=(n,u)=>{t(x=>u?[...x,n]:x.filter(W=>W!==n))},v=c.trim().length>0&&d.length>0,A=async()=>{if(v){b(!0);try{const n=await B({variables:{input:{name:c.trim(),description:f||null,communities:d}},refetchQueries:[$]}),u=n.data?.createRule?.errors;if(u?.length&&u[0]){a(u[0].messages[0],{variant:"error"}),b(!1);return}const x=n.data?.createRule?.rule?.id;x&&(a("Rule created successfully",{variant:"success"}),r(`/rules/${x}`))}catch{a("Failed to create rule. Please try again.",{variant:"error"}),b(!1)}}},N=[{label:"Overview",value:"overview",content:e.jsx(le,{allCommunities:k,selectedCommunityIds:d,onCommunityToggle:z,loading:T})},{label:"Conditions",value:"conditions",content:e.jsx(l,{}),disabled:!0},{label:"Actions",value:"actions",content:e.jsx(l,{}),disabled:!0}];return e.jsxs(l,{children:[e.jsx(G,{title:"New Rule",breadcrumbs:[{label:"Rules",path:"/rules"},{label:"New Rule"}],sx:{borderBottom:n=>`1px solid ${n.palette.background.paper}`},Actions:[e.jsx(V,{variant:"primary",sx:{height:"fit-content"},onClick:A,disabled:!v||i,children:i?"Creating...":"Create Rule"},"create-rule")]}),e.jsx(q,{tabs:N,value:m,onChange:n=>h(n),defaultTab:"overview",headerIcon:e.jsxs(l,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(l,{sx:{width:32,height:32,borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Q,{style:{fontSize:24,color:"text.secondary"}})}),e.jsx(X,{color:"warning",children:"Pending"})]}),header:e.jsxs(R,{children:[e.jsx(y,{label:"Rule Name",value:c,originalValue:"",onChange:p,onSave:async()=>{},variant:"title",maxLength:100,placeholder:"Enter rule name..."}),e.jsx(y,{label:"Description",value:f,originalValue:"",onChange:g,onSave:async()=>{},maxLength:500,multiline:!0,placeholder:"Enter description (optional)..."})]})})]})};export{Ne as NewRulePage};
2//# sourceMappingURL=NewRulePage-4rw6xLMg.js.map

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.