@e-llm-studio/instant-learning 1.3.0-alpha.37 → 1.3.0-alpha.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as l}from"react";import{Search as u,X as a}from"lucide-react";import{useApproverSearchQuery as c,useGroupSearchQuery as d}from"../queries/useApprovalQueries.js";var p={root:{marginLeft:"1.5rem"},sectionLabel:{fontSize:"0.875rem",fontWeight:500,color:"#19213D"},requiredMark:{marginRight:"0.25rem",fontSize:"1rem",fontWeight:600,color:"#8F2C23"},dropdownWrapper:{position:"relative",marginTop:"0.375rem"},inputShell:{display:"flex",minHeight:"38px",width:"100%",cursor:"text",flexWrap:"wrap",alignItems:"center",gap:"0.375rem",borderRadius:"0.375rem",border:"1px solid #E2E8F0",padding:"0.375rem 0.5rem",boxSizing:"border-box",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out"},searchIcon:{flexShrink:0,color:"#9CA3AF"},chip:{display:"flex",alignItems:"center",gap:"0.25rem",borderRadius:"9999px",backgroundColor:"#EFF6FF",padding:"0.125rem 0.625rem",fontSize:"0.75rem",fontWeight:500,color:"#1D4ED8"},chipRemoveButton:{marginLeft:"0.125rem",border:"none",borderRadius:"9999px",background:"transparent",padding:0,cursor:"pointer",outline:"none"},input:{minWidth:"120px",flex:1,border:"none",backgroundColor:"transparent",fontSize:"0.875rem",color:"#19213D",outline:"none"},dropdown:{position:"absolute",zIndex:50,marginTop:"0.25rem",maxHeight:"12rem",width:"100%",overflowY:"auto",borderRadius:"0.375rem",border:"1px solid #E2E8F0",backgroundColor:"#FFFFFF",padding:"0.25rem 0",listStyle:"none",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",boxSizing:"border-box"},skeletonItem:{padding:"0.5rem 0.75rem"},skeletonLinePrimary:{height:"1rem",width:"75%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB"},skeletonLineSecondary:{height:"0.75rem",width:"50%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB",marginTop:"0.375rem"},checkboxOption:{display:"flex",alignItems:"center",gap:"0.625rem",width:"100%",padding:"0.5rem 0.75rem",cursor:"pointer",boxSizing:"border-box"},checkboxInput:{width:"14px",height:"14px",flexShrink:0,cursor:"pointer",accentColor:"#2563EB",margin:0},optionTitle:{fontSize:"0.875rem",fontWeight:500,color:"#19213D",margin:0},optionSubtitle:{fontSize:"0.75rem",color:"#666F8D",margin:0}},s=function(s){var m=s.selectedApprovers,h=s.selectedGroupOfApprovers,f=s.onApproversChange,g=s.onGroupsChange,b=o(""),v=b[0],y=b[1],x=o(""),k=x[0],F=x[1],E=o(!1),S=E[0],w=E[1],C=i(null),L=i(null),D=o(""),M=D[0],z=D[1],B=o(""),I=B[0],_=B[1],T=o(!1),A=T[0],R=T[1],W=i(null),q=i(null),O=o(!1),P=O[0],j=O[1],G=o(!1),H=G[0],Q=G[1],Y=o(null),J=Y[0],K=Y[1],N=o(null),U=N[0],V=N[1],X=o(null),Z=X[0],$=X[1],ee=o(null),ne=ee[0],re=ee[1];l(function(){if(!v.trim())return F(""),void w(!1);var e=setTimeout(function(){return F(v)},500);return function(){return clearTimeout(e)}},[v]),l(function(){var e=setTimeout(function(){return _(M)},300);return function(){return clearTimeout(e)}},[M]);var te=c(k),oe=te.data,ie=te.isFetching,le=(oe||[]).filter(function(e){return!m.some(function(n){return n.id===e._id})}).slice(0,10).map(function(e){var n,r,t,o;return{id:e._id,email:null!==(n=e.email)&&void 0!==n?n:"",name:(null===(r=e.firstname)||void 0===r?void 0:r.trim())?"".concat(e.firstname," ").concat(null!==(t=e.lastname)&&void 0!==t?t:"").trim():null!==(o=e.email)&&void 0!==o?o:""}});l(function(){k.trim()&&(ie||le.length>0)&&w(!0)},[ie,le.length,k]);var ue=d(I),ae=ue.data,ce=ue.isFetching,de=(ae||[]).filter(function(e){return!h.some(function(n){return n._id===e._id})}).slice(0,10);l(function(){H&&(ce||de.length>0)&&R(!0)},[ce,de.length,H]),l(function(){var e=function(e){C.current&&!C.current.contains(e.target)&&w(!1),W.current&&!W.current.contains(e.target)&&R(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);return r("div",e({style:p.root},{children:[r("label",e({htmlFor:"approver-search-input",style:p.sectionLabel},{children:[t("span",e({style:p.requiredMark},{children:"*"})),"Select who can Approve"]})),r("div",e({ref:C,style:p.dropdownWrapper},{children:[r("label",e({htmlFor:"approver-search-input",style:e(e({},p.inputShell),{borderColor:P?"#2563EB":"#E2E8F0",boxShadow:P?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:p.searchIcon}),m.map(function(n){return r("span",e({style:p.chip},{children:[n.email,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n.id,f(m.filter(function(e){return e.id!==r}))},onMouseEnter:function(){return $(n.id)},onMouseLeave:function(){return $(null)},style:e(e({},p.chipRemoveButton),{backgroundColor:Z===n.id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n.id)}),t("input",{ref:L,id:"approver-search-input",type:"text",value:v,onChange:function(e){return y(e.target.value)},onFocus:function(){j(!0),(le.length>0||ie)&&w(!0)},onBlur:function(){return j(!1)},placeholder:0===m.length?"Search by name or email...":"",style:p.input})]})),S&&(ie||le.length>0)&&t("ul",e({style:p.dropdown},{children:ie?[1,2,3,4].map(function(n){return r("li",e({style:p.skeletonItem},{children:[t("div",{style:p.skeletonLinePrimary}),t("div",{style:p.skeletonLineSecondary})]}),n)}):le.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;f(n(n([],m,!0),[e],!1)),y(""),w(!1),null===(r=L.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return K(o.id)},onMouseLeave:function(){return K(null)},style:e(e({},p.checkboxOption),{backgroundColor:J===o.id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:p.checkboxInput}),r("div",{children:[t("p",e({style:p.optionTitle},{children:o.name})),t("p",e({style:p.optionSubtitle},{children:o.email}))]})]}))},o.id)})}))]})),r("label",e({htmlFor:"group-search-input",style:e(e({},p.sectionLabel),{display:"inline-block",marginTop:"0.375rem"})},{children:[t("span",e({style:p.requiredMark},{children:"*"})),"Select user group who can Approve"]})),r("div",e({ref:W,style:p.dropdownWrapper},{children:[r("label",e({htmlFor:"group-search-input",style:e(e({},p.inputShell),{borderColor:H?"#2563EB":"#E2E8F0",boxShadow:H?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:p.searchIcon}),h.map(function(n){return r("span",e({style:p.chip},{children:[n.name,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n._id,g(h.filter(function(e){return e._id!==r}))},onMouseEnter:function(){return re(n._id)},onMouseLeave:function(){return re(null)},style:e(e({},p.chipRemoveButton),{backgroundColor:ne===n._id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n._id)}),t("input",{ref:q,id:"group-search-input",type:"text",value:M,onChange:function(e){return z(e.target.value)},onFocus:function(){Q(!0)},onBlur:function(){return Q(!1)},placeholder:0===h.length?"Search by group name...":"",style:p.input})]})),A&&(ce||de.length>0)&&t("ul",e({style:p.dropdown},{children:ce?[1,2,3,4].map(function(n){return r("li",e({style:p.skeletonItem},{children:[t("div",{style:p.skeletonLinePrimary}),t("div",{style:p.skeletonLineSecondary})]}),n)}):de.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;g(n(n([],h,!0),[e],!1)),z(""),R(!1),null===(r=q.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return V(o._id)},onMouseLeave:function(){return V(null)},style:e(e({},p.checkboxOption),{backgroundColor:U===o._id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:p.checkboxInput}),r("div",{children:[t("p",e({style:p.optionTitle},{children:o.name})),t("p",e({style:p.optionSubtitle},{children:o.description}))]})]}))},o._id)})}))]}))]}))};export{s as default};
1
+ import{__assign as e,__spreadArray as n}from"tslib";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as l}from"react";import{Search as u,X as a}from"lucide-react";import{useApproverSearchQuery as c,useGroupSearchQuery as d}from"../queries/useApprovalQueries.js";var p={root:{marginLeft:"1.5rem"},sectionLabel:{fontSize:"0.875rem",fontWeight:500,color:"#19213D"},requiredMark:{marginRight:"0.25rem",fontSize:"1rem",fontWeight:600,color:"#8F2C23"},dropdownWrapper:{position:"relative",marginTop:"0.375rem"},inputShell:{display:"flex",minHeight:"38px",width:"100%",cursor:"text",flexWrap:"wrap",alignItems:"center",gap:"0.375rem",borderRadius:"0.375rem",border:"1px solid #E2E8F0",padding:"0.375rem 0.5rem",boxSizing:"border-box",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out"},searchIcon:{flexShrink:0,color:"#9CA3AF"},chip:{display:"flex",alignItems:"center",gap:"0.25rem",borderRadius:"9999px",backgroundColor:"#EFF6FF",padding:"0.125rem 0.625rem",fontSize:"0.75rem",fontWeight:500,color:"#1D4ED8"},chipRemoveButton:{marginLeft:"0.125rem",border:"none",borderRadius:"9999px",background:"transparent",padding:0,cursor:"pointer",outline:"none"},input:{minWidth:"120px",flex:1,border:"none",backgroundColor:"transparent",fontSize:"0.875rem",color:"#19213D",outline:"none"},dropdown:{position:"absolute",zIndex:50,marginTop:"0.25rem",maxHeight:"12rem",width:"100%",overflowY:"auto",borderRadius:"0.375rem",border:"1px solid #E2E8F0",backgroundColor:"#FFFFFF",padding:"0.25rem 0",listStyle:"none",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",boxSizing:"border-box"},skeletonItem:{padding:"0.5rem 0.75rem"},skeletonLinePrimary:{height:"1rem",width:"75%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB"},skeletonLineSecondary:{height:"0.75rem",width:"50%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB",marginTop:"0.375rem"},checkboxOption:{display:"flex",alignItems:"center",gap:"0.625rem",width:"100%",padding:"0.5rem 0.75rem",cursor:"pointer",boxSizing:"border-box"},checkboxInput:{width:"14px",height:"14px",flexShrink:0,cursor:"pointer",accentColor:"#2563EB",margin:0},optionTitle:{fontSize:"0.875rem",fontWeight:500,color:"#19213D",margin:0},optionSubtitle:{fontSize:"0.75rem",color:"#666F8D",margin:0}},s=function(s){var m=s.selectedApprovers,h=s.selectedGroupOfApprovers,f=s.onApproversChange,g=s.onGroupsChange,b=o(""),v=b[0],y=b[1],x=o(""),k=x[0],F=x[1],E=o(!1),S=E[0],w=E[1],C=i(null),L=i(null),D=o(""),M=D[0],z=D[1],B=o(""),I=B[0],_=B[1],T=o(!1),R=T[0],W=T[1],A=i(null),q=i(null),O=o(!1),P=O[0],j=O[1],G=o(!1),H=G[0],Q=G[1],Y=o(null),J=Y[0],K=Y[1],N=o(null),U=N[0],V=N[1],X=o(null),Z=X[0],$=X[1],ee=o(null),ne=ee[0],re=ee[1];l(function(){if(!v.trim())return F(""),void w(!1);var e=setTimeout(function(){return F(v)},500);return function(){return clearTimeout(e)}},[v]),l(function(){var e=setTimeout(function(){return _(M)},300);return function(){return clearTimeout(e)}},[M]);var te=c(k),oe=te.data,ie=te.isFetching,le=(oe||[]).filter(function(e){return!m.some(function(n){return n.id===e._id})}).slice(0,10).map(function(e){var n,r,t,o;return{id:e._id,email:null!==(n=e.email)&&void 0!==n?n:"",name:(null===(r=e.firstname)||void 0===r?void 0:r.trim())?"".concat(e.firstname," ").concat(null!==(t=e.lastname)&&void 0!==t?t:"").trim():null!==(o=e.email)&&void 0!==o?o:""}});l(function(){k.trim()&&(ie||le.length>0)&&w(!0)},[ie,le.length,k]);var ue=d(I),ae=ue.data,ce=ue.isFetching,de=(ae||[]).filter(function(e){return!h.some(function(n){return n._id===e._id})}).slice(0,10);l(function(){H&&(ce||de.length>0)&&W(!0)},[ce,de.length,H]),l(function(){var e=function(e){C.current&&!C.current.contains(e.target)&&w(!1),A.current&&!A.current.contains(e.target)&&W(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);return r("div",e({style:p.root},{children:[r("label",e({htmlFor:"approver-search-input",style:p.sectionLabel},{children:[t("span",e({style:p.requiredMark},{children:"*"})),"Select who can approve"]})),r("div",e({ref:C,style:p.dropdownWrapper},{children:[r("label",e({htmlFor:"approver-search-input",style:e(e({},p.inputShell),{borderColor:P?"#2563EB":"#E2E8F0",boxShadow:P?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:p.searchIcon}),m.map(function(n){return r("span",e({style:p.chip},{children:[n.email,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n.id,f(m.filter(function(e){return e.id!==r}))},onMouseEnter:function(){return $(n.id)},onMouseLeave:function(){return $(null)},style:e(e({},p.chipRemoveButton),{backgroundColor:Z===n.id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n.id)}),t("input",{ref:L,id:"approver-search-input",type:"text",value:v,onChange:function(e){return y(e.target.value)},onFocus:function(){j(!0),(le.length>0||ie)&&w(!0)},onBlur:function(){return j(!1)},placeholder:0===m.length?"Search by name or email...":"",style:p.input})]})),S&&(ie||le.length>0)&&t("ul",e({style:p.dropdown},{children:ie?[1,2,3,4].map(function(n){return r("li",e({style:p.skeletonItem},{children:[t("div",{style:p.skeletonLinePrimary}),t("div",{style:p.skeletonLineSecondary})]}),n)}):le.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;f(n(n([],m,!0),[e],!1)),y(""),w(!1),null===(r=L.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return K(o.id)},onMouseLeave:function(){return K(null)},style:e(e({},p.checkboxOption),{backgroundColor:J===o.id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:p.checkboxInput}),r("div",{children:[t("p",e({style:p.optionTitle},{children:o.name})),t("p",e({style:p.optionSubtitle},{children:o.email}))]})]}))},o.id)})}))]})),r("label",e({htmlFor:"group-search-input",style:e(e({},p.sectionLabel),{display:"inline-block",marginTop:"0.375rem"})},{children:[t("span",e({style:p.requiredMark},{children:"*"})),"Select user group who can approve"]})),r("div",e({ref:A,style:p.dropdownWrapper},{children:[r("label",e({htmlFor:"group-search-input",style:e(e({},p.inputShell),{borderColor:H?"#2563EB":"#E2E8F0",boxShadow:H?"0 0 0 1px #2563EB":"none"})},{children:[t(u,{size:14,style:p.searchIcon}),h.map(function(n){return r("span",e({style:p.chip},{children:[n.name,t("button",e({type:"button",onMouseDown:function(e){var r;e.preventDefault(),r=n._id,g(h.filter(function(e){return e._id!==r}))},onMouseEnter:function(){return re(n._id)},onMouseLeave:function(){return re(null)},style:e(e({},p.chipRemoveButton),{backgroundColor:ne===n._id?"#DBEAFE":"transparent"})},{children:t(a,{size:12})}))]}),n._id)}),t("input",{ref:q,id:"group-search-input",type:"text",value:M,onChange:function(e){return z(e.target.value)},onFocus:function(){Q(!0)},onBlur:function(){return Q(!1)},placeholder:0===h.length?"Search by group name...":"",style:p.input})]})),R&&(ce||de.length>0)&&t("ul",e({style:p.dropdown},{children:ce?[1,2,3,4].map(function(n){return r("li",e({style:p.skeletonItem},{children:[t("div",{style:p.skeletonLinePrimary}),t("div",{style:p.skeletonLineSecondary})]}),n)}):de.map(function(o){return t("li",{children:r("div",e({onMouseDown:function(e){e.preventDefault(),function(e){var r;g(n(n([],h,!0),[e],!1)),z(""),W(!1),null===(r=q.current)||void 0===r||r.focus()}(o)},onMouseEnter:function(){return V(o._id)},onMouseLeave:function(){return V(null)},style:e(e({},p.checkboxOption),{backgroundColor:U===o._id?"#F1F5F9":"transparent"})},{children:[t("input",{type:"checkbox",checked:!1,onChange:function(){},style:p.checkboxInput}),r("div",{children:[t("p",e({style:p.optionTitle},{children:o.name})),t("p",e({style:p.optionSubtitle},{children:o.description}))]})]}))},o._id)})}))]}))]}))};export{s as default};
2
2
  //# sourceMappingURL=AddScopeApprovalSearchComponent.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e,__generator as o,__assign as r,__spreadArray as n}from"tslib";import{jsx as t,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as s}from"react";import{useMutation as d}from"@tanstack/react-query";import{X as u,Loader2 as p}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as f}from"uuid";import h from"../components/StationOnboarding/StationAutocomplete.js";import g from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as y}from"@mui/material";import b from"../store/useAuthStore.js";import{useAppSecRolesStore as S}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x,inheritScope as _}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as k}from"../config.js";import{dt as A}from"../store/useLMSConfigStore.js";import{MIDDLE_DRAWER_ADD_SCOPE_DT_PATH as R,MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH as I}from"../constants.js";var D=function(D){var q=D.isOpen,j=D.onClose,F=D.onCreate,z=D.hasGlobalRuleSet,L=D.parentId,E=a(""),B=E[0],W=E[1],N=a(""),G=N[0],M=N[1],P=a({}),T=P[0],O=P[1],K=c(null),U=b().user,H=S(function(e){return e.roles}),J=C(function(e){return e.rbacConfig}),Q=a(null),V=Q[0],X=Q[1],Y=a("approval_required"),Z=Y[0],$=Y[1],ee=a([]),oe=ee[0],re=ee[1],ne=a([]),te=ne[0],ie=ne[1],le=a(""),ae=le[0],ce=le[1],se=d({mutationFn:function(r){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(r,null!==(e=null==U?void 0:U.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(r){return e(void 0,void 0,void 0,function(){return o(this,function(e){return console.log("Rule Set Created Successfully",r),[2]})})}});se.data;var de=se.isPending,ue=se.mutateAsync;return s(function(){q&&(W(""),M(""),O({}),X(null),$("approval_required"),re([]),ie([]),ce(""))},[q]),q?de?t(v,{isLoading:de}):i("div",r({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[t(m,{ref:K}),i("div",r({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i("div",r({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i("div",{children:[t("h2",r({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:A("".concat(R,".title"),"Add Scope")})),t("p",r({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:A("".concat(R,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),t("button",r({onClick:j,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:t(u,{size:24})}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i("div",r({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(R,".scopeName"),"Scope Name")]})),"Custom"===B?t(h,{value:G,onChange:function(e){if(e.length>50)return M(e.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});M(e),O(function(e){return r(r({},e),{name:void 0})})},onStationSelect:function(e){X(e)},style:{border:T.name?"1px solid #8F2C23":void 0}}):t(y,{value:G,onChange:function(e){var o=e.target.value;if(o.length>50)return M(o.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});M(o),O(function(e){return r(r({},e),{name:void 0})})},style:{border:"1px solid ".concat(T.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),T.name&&t("p",r({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:T.name}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(I,".title"),"Learning Approval Settings")]})),i("div",r({role:"radio","aria-checked":"approval_required"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return $("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||$("approval_required")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Z?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Z&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===Z&&t(g,{selectedApprovers:oe,selectedGroupOfApprovers:te,onApproversChange:re,onGroupsChange:ie}),ae&&t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:ae})),i("div",r({role:"radio","aria-checked":"publish_without"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){$("publish_without"),ce("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||($("publish_without"),ce(""))}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Z?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Z&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),i("div",r({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[t("button",r({onClick:j,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:de?.5:1},disabled:de},{children:A("".concat(R,".cancel"),"Cancel")})),t("button",r({onClick:function(){return e(void 0,void 0,void 0,function(){var e,r,t,i,l,a,c,s,d,u,p,m,h,g,v,y,b,S,C,x;return o(this,function(o){switch(o.label){case 0:if(e={},G.trim()?G.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required","approval_required"===Z&&0===oe.length&&0===te.length&&ce("Please select at least one approver or approver group."),e.name)return O(e),[2];if("approval_required"===Z&&0===oe.length&&0===te.length)return[2];ce(""),o.label=1;case 1:return o.trys.push([1,7,,8]),r="approval_required"===Z,t=w.getState().backwardCompatibility,i=t?{topic:z?"genreRuleSet":"globalRuleSet",customScopeGroupName:k.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:G,parentScopeId:null,customScopeName:G,customScopeId:f(),createByName:(null==U?void 0:U.firstname)||"System",createdBy:(null==U?void 0:U.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r?[{users:oe.map(function(e){return e.email}),groups:te.map(function(e){return e._id}),role:null!==(u=null===(d=H.find(function(e){return"Learning Manager"===e.name}))||void 0===d?void 0:d._id)&&void 0!==u?u:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(m=null===(p=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===p?void 0:p._id)&&void 0!==m?m:""}],!1)}}:{topic:z?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:G,parentScopeId:null!=L?L:null,scopeName:G,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r?[{users:oe.map(function(e){return e.email}),groups:te.map(function(e){return e._id}),role:null!==(g=null===(h=H.find(function(e){return"Learning Manager"===e.name}))||void 0===h?void 0:h._id)&&void 0!==g?g:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(y=null===(v=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===v?void 0:v._id)&&void 0!==y?y:""}],!1)}},console.log("Add Scope payload:",i),[4,ue(i)];case 2:if(l=o.sent(),a=null===(b=null==l?void 0:l.data)||void 0===b?void 0:b.scopeId,t||!a||!L)return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),[4,_({source_scope_id:L,target_scope_id:a,application_mapping_id:w.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return o.sent(),[3,6];case 5:return c=o.sent(),console.error("Failed to inherit rules for the new scope:",c),[3,6];case 6:return F(a),j(),[3,8];case 7:return s=o.sent(),console.error("An error occurred during scope creation.",s),null===(S=K.current)||void 0===S||S.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(x=null===(C=null==s?void 0:s.response)||void 0===C?void 0:C.data)||void 0===x?void 0:x.message)||"There was an error creating the scope. Please try again."}),[3,8];case 8:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:de||"Custom"===B&&!V?.5:1},disabled:de||"Custom"===B&&!V},{children:de?i(l,{children:[t(p,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):A("".concat(R,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};export{D as default};
1
+ import{__awaiter as e,__generator as o,__assign as r,__spreadArray as n}from"tslib";import{jsx as t,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as s}from"react";import{useMutation as d}from"@tanstack/react-query";import{X as u,Loader2 as p}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as f}from"uuid";import h from"../components/StationOnboarding/StationAutocomplete.js";import g from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as y}from"@mui/material";import b from"../store/useAuthStore.js";import{useAppSecRolesStore as S}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x,inheritScope as _}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as k}from"../config.js";import{dt as A}from"../store/useLMSConfigStore.js";import{MIDDLE_DRAWER_ADD_SCOPE_DT_PATH as R,MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH as I}from"../constants.js";var D=function(D){var q=D.isOpen,j=D.onClose,F=D.onCreate,z=D.hasGlobalRuleSet,L=D.parentId,E=a(""),B=E[0],W=E[1],N=a(""),G=N[0],M=N[1],P=a({}),T=P[0],O=P[1],K=c(null),U=b().user,H=S(function(e){return e.roles}),J=C(function(e){return e.rbacConfig}),Q=a(null),V=Q[0],X=Q[1],Y=a("approval_required"),Z=Y[0],$=Y[1],ee=a([]),oe=ee[0],re=ee[1],ne=a([]),te=ne[0],ie=ne[1],le=a(""),ae=le[0],ce=le[1],se=d({mutationFn:function(r){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(r,null!==(e=null==U?void 0:U.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(r){return e(void 0,void 0,void 0,function(){return o(this,function(e){return console.log("Rule Set Created Successfully",r),[2]})})}});se.data;var de=se.isPending,ue=se.mutateAsync;return s(function(){q&&(W(""),M(""),O({}),X(null),$("approval_required"),re([]),ie([]),ce(""))},[q]),q?de?t(v,{isLoading:de}):i("div",r({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[t(m,{ref:K}),i("div",r({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i("div",r({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i("div",{children:[t("h2",r({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:A("".concat(R,".title"),"Add Scope")})),t("p",r({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:A("".concat(R,".subtitle"),"This scope will be created under Global scope and will inherit its learnings by default.",{parent:"Global"})}))]}),t("button",r({onClick:j,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:t(u,{size:24})}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i("div",r({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(R,".scopeName"),"Scope Name")]})),"Custom"===B?t(h,{value:G,onChange:function(e){if(e.length>50)return M(e.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});M(e),O(function(e){return r(r({},e),{name:void 0})})},onStationSelect:function(e){X(e)},style:{border:T.name?"1px solid #8F2C23":void 0}}):t(y,{value:G,onChange:function(e){var o=e.target.value;if(o.length>50)return M(o.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});M(o),O(function(e){return r(r({},e),{name:void 0})})},style:{border:"1px solid ".concat(T.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),T.name&&t("p",r({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:T.name}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(I,".title"),"Learning Approval Settings")]})),i("div",r({role:"radio","aria-checked":"approval_required"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return $("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||$("approval_required")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Z?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Z&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===Z&&t(g,{selectedApprovers:oe,selectedGroupOfApprovers:te,onApproversChange:re,onGroupsChange:ie}),ae&&t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:ae})),i("div",r({role:"radio","aria-checked":"publish_without"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){$("publish_without"),ce("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||($("publish_without"),ce(""))}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Z?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Z&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),i("div",r({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[t("button",r({onClick:j,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:de?.5:1},disabled:de},{children:A("".concat(R,".cancel"),"Cancel")})),t("button",r({onClick:function(){return e(void 0,void 0,void 0,function(){var e,r,t,i,l,a,c,s,d,u,p,m,h,g,v,y,b,S,C,x;return o(this,function(o){switch(o.label){case 0:if(e={},G.trim()?G.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required","approval_required"===Z&&0===oe.length&&0===te.length&&ce("Please select at least one approver or approver group."),e.name)return O(e),[2];if("approval_required"===Z&&0===oe.length&&0===te.length)return[2];ce(""),o.label=1;case 1:return o.trys.push([1,7,,8]),r="approval_required"===Z,t=w.getState().backwardCompatibility,i=t?{topic:z?"genreRuleSet":"globalRuleSet",customScopeGroupName:k.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:G,parentScopeId:null,customScopeName:G,customScopeId:f(),createByName:(null==U?void 0:U.firstname)||"System",createdBy:(null==U?void 0:U.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r?[{users:oe.map(function(e){return e.email}),groups:te.map(function(e){return e._id}),role:null!==(u=null===(d=H.find(function(e){return"Learning Manager"===e.name}))||void 0===d?void 0:d._id)&&void 0!==u?u:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(m=null===(p=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===p?void 0:p._id)&&void 0!==m?m:""}],!1)}}:{topic:z?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:G,parentScopeId:null!=L?L:null,scopeName:G,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id,approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r?[{users:oe.map(function(e){return e.email}),groups:te.map(function(e){return e._id}),role:null!==(g=null===(h=H.find(function(e){return"Learning Manager"===e.name}))||void 0===h?void 0:h._id)&&void 0!==g?g:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(y=null===(v=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===v?void 0:v._id)&&void 0!==y?y:""}],!1)}},console.log("Add Scope payload:",i),[4,ue(i)];case 2:if(l=o.sent(),a=null===(b=null==l?void 0:l.data)||void 0===b?void 0:b.scopeId,t||!a||!L)return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),[4,_({source_scope_id:L,target_scope_id:a,application_mapping_id:w.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return o.sent(),[3,6];case 5:return c=o.sent(),console.error("Failed to inherit rules for the new scope:",c),[3,6];case 6:return F(a),j(),[3,8];case 7:return s=o.sent(),console.error("An error occurred during scope creation.",s),null===(S=K.current)||void 0===S||S.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(x=null===(C=null==s?void 0:s.response)||void 0===C?void 0:C.data)||void 0===x?void 0:x.message)||"There was an error creating the scope. Please try again."}),[3,8];case 8:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:de||"Custom"===B&&!V?.5:1},disabled:de||"Custom"===B&&!V},{children:de?i(l,{children:[t(p,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):A("".concat(R,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};export{D as default};
2
2
  //# sourceMappingURL=AddScopeModal.js.map