1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cf7dfb68-0e81-50d2-a13a-998e2524fe74")}catch(e){}}(); 3import{bN as Ie,R as e,ad as me,ai as de,bI as Q,Y as Z,cJ as Se,Q as v,aJ as ee,V as P,W as B,aj as De,bY as Fe,bi as Re,l as ae,bk as J,bj as Oe,c9 as Le,cK as Me,aM as Ae,bG as Pe,aN as ze,C as ue,r as pe,bt as fe,a6 as z,bH as je,x as ge,y as _e,cc as L,cs as X,cL as Be,by as He,bz as Ve,v as Ue,cM as We,aL as oe,cN as A,bU as ne,k as T,ah as he,bx as qe,cO as Ke,bJ as be,cP as Ye,cp as re,I as Ge,s as $e,bm as Je,ao as Qe,aG as Xe}from"./index-Cs-In7Vx.js";import{S as Ze}from"./SearchInput-6k8qtIIx.js";import{S as et}from"./SendRounded-F14-gZ8F.js";import{n as Ee,N as tt}from"./NotificationCard-Br_kHORa.js";import{S as at}from"./StoreRounded-rFkBW34T.js";import{m as ot}from"./MarketSegmentField-Dm3gJtna.js";import{D as M,r as nt}from"./Draft-yvgGJQ1j.js";/* empty css */import{T as rt,a as se}from"./ToggleButtonGroup-Bhd5Hj6n.js";import"./DoneAllRounded-BJ8SQGoK.js";import"./DoneRounded-DPMKgf-4.js";import"./AnnouncementRounded-C3ZHSK9S.js";import"./GetAppRounded-DDuWLHeg.js";import"./NewReleasesRounded-Bx8h4pgW.js";const ye=Ie(o=>({filters:{page:1,per_page:10,order:"desc",order_by:"id",search_text:""},updateFilter:(t,a)=>o(r=>({...r,filters:t==="page"?{...r.filters,[t]:a}:{...r.filters,[t]:a,page:1}}))}));function st({onNewTemplateClick:o}){const t=ye(l=>l.updateFilter),[a,r]=e.useState(""),{hasUserRolePermissions:s}=me(),i=e.useMemo(()=>de(l=>{t("search_text",l)},600),[t]),n=e.useRef(!0);return e.useEffect(()=>{n.current?(n.current=!1,t("search_text","")):i(a)},[a,i,t]),e.createElement("div",{className:"flex w-full flex-col flex-wrap justify-end space-x-0 space-y-16 sm:flex-row sm:items-center sm:space-x-16 sm:space-y-0"},e.createElement("div",{className:"flex flex-1"},e.createElement(Ze,{placeholder:"Pesquise por descrição ou mensagem",value:a,onChange:l=>r(l.target.value),wrapperClassName:"w-full lg:w-384"})),s(Q.NOTIFICATIONS_MANAGE)&&e.createElement(Z,{variant:"contained",color:"primary",startIcon:e.createElement(Se,null),onClick:o,className:"w-full sm:w-auto"},"NOVO TEMPLATE"))}async function lt(o){return(await v.get("/api/v2/admin/companies/autocomplete",{params:o})).data}async function it(o){const t=await v.post("/api/v1/admin/notification/notification_targets",o);if(t.status===201&&t.data.status!==500)return t.data;throw Error(t.data.message)}async function ct(o){const t=o.get("id"),a=await v.put(`/api/v1/admin/notification/notification_targets/${t}`,o);if(a.status===200&&a.data.status!==500)return a.data;throw Error(a.data.message)}async function mt(o){const t=await v.delete(`/api/v1/admin/notification/notification_targets/${o}`);if(t.status===200&&t.data.status!==500)return t.data;throw Error(t.data.message)}async function dt(o){const t=await v.post(`/api/v1/admin/notification/notification_target/${o}/triggers`);if(t.status===200&&t.data.status!==500)return t.data;throw Error(t.data.message)}const ut="/api/v1/admin/notification/notification_targets";let le;const pt=o=>v.get(o).then(t=>{if(t.status!==200||t.data.status===500)throw Error(t.data.message);return t.data});function j(o=le){le=o;const t=P.queryParamsObjectToString(o);return`${ut}?${t}`}function ft(o){const{data:t,error:a,mutate:r,isLoading:s}=ee(j(o),pt,{dedupingInterval:2e4,revalidateOnFocus:!1});return{templates:t,isLoading:s,isError:a,mutate:r}}function gt({editEditTemplateDrawer:o,openTriggerNotificationDialog:t}){const a=B(),r=De(),s=ye(m=>m.filters),{templates:i,isLoading:n,isError:l,mutate:c}=ft(),[d,f]=e.useState(!1),h=Object.values(Ee),{hasUserRolePermissions:E}=me(),_=e.useMemo(()=>{const m=s.search_text.toLowerCase();return i?.filter(b=>b.message.toLowerCase().includes(m)||b.description.toLowerCase().includes(m))},[s,i]),g=e.useCallback(async m=>{try{await mt(m),c(b=>b.filter(C=>C.id!==m),!1)}catch(b){a.error(b.message||"Não foi possÃvel concluir a operação")}},[a,c]),I=e.useCallback(m=>r({title:"Confirmar exclusão?",description:"O template será excluÃdo permanentemente",confirmationText:"Excluir"}).then(async()=>{f(!0),await g(m),f(!1)}).catch(()=>{}),[g,r]),k=e.useCallback(m=>h.filter(b=>b.key===m),[h]);return e.createElement(Fe,{data:_,loading:n,loadingRowsQuantity:5,resetCurrentPage:s.page===1,showError:l,stickyHeader:!0,columns:[{Header:"Tipo",accessor:"kind",sortable:!1,
3className:"min-w-160 max-w-320",Cell:({row:m})=>e.createElement(Re,{className:k(m.kind)?.[0].colors},k(m.kind)?.[0].label)},{Header:"Descrição",accessor:"description",sortable:!1,className:"font-bold min-w-160 truncate max-w-320",Cell:({row:m})=>e.createElement("span",{className:"max-w-320 truncate",title:m.description},m.description)},{Header:"Mensagem",accessor:"message",sortable:!1,className:"min-w-160 max-w-320 truncate",Cell:({row:m})=>e.createElement("span",{className:"max-w-320 truncate",title:m.message},m.message)},{Header:"Criado em",accessor:"created_at",sortable:!1,formatDataFunction:m=>ae(m).format("DD/MM/YYYY HH:mm")},{Header:"Ãltimo disparo",accessor:"executed_at",sortable:!1,formatDataFunction:m=>ae(m).format("DD/MM/YYYY HH:mm")},{Header:"",accessor:"id",className:"text-right",sortable:!1,Cell:({row:m})=>e.createElement("div",{className:"space-x-12"},E(Q.NOTIFICATIONS_MANAGE)&&e.createElement(e.Fragment,null,e.createElement(J,{tooltip:"Editar",onClick:()=>o(m),variant:"button"},e.createElement(Oe,null)),e.createElement(J,{loading:d,tooltip:"Deletar",onClick:()=>I(m.id),variant:"button"},e.createElement(Le,null))),E(Q.NOTIFICATIONS_SEND)&&e.createElement(J,{disabled:d,tooltip:"Disparar Notificação",onClick:()=>t(m),variant:"button"},e.createElement(et,null)))}]})}function _t({onCompanySelected:o}){const[t,a]=e.useState(""),[r,s]=e.useState(!1),[i,n]=e.useState([]),l=e.useMemo(()=>Me((c,d)=>{lt({search_text:c}).then(f=>d(f)).catch(()=>d([]))},600),[]);return e.useEffect(()=>{let c=!0;if(t===""){s(!1),n([]);return}return s(!0),l(t,d=>{c&&(n(d),s(!1))}),()=>{c=!1}},[t,l]),e.createElement(Ae,{getOptionLabel:c=>c.name,options:i,fullWidth:!0,autoHighlight:!0,inputValue:t,noOptionsText:"Nada encontrado",clearText:"Limpar",onChange:(c,d)=>{d&&(a(""),o(d))},onInputChange:(c,d,f)=>{f!=="reset"&&a(d)},renderInput:c=>e.createElement(ze,{...c,label:"Procurar empresa",variant:"outlined",size:"small",fullWidth:!0,InputProps:{...c.InputProps,endAdornment:e.createElement(e.Fragment,null,r?e.createElement(ue,{color:"inherit",size:20}):null,c.InputProps.endAdornment)}}),renderOption:c=>e.createElement("div",{className:"flex min-h-44 w-full items-center space-x-16"},e.createElement("div",{className:"flex h-full items-center"},e.createElement(at,{className:"text-gray-400"})),e.createElement("div",{className:"flex-1 truncate"},e.createElement("div",{style:{fontWeight:500}},c.name),e.createElement("div",{className:"text-gray-500"},Pe(c.telephone,c.ddi))))})}const ve=pe.createContext(),ht=ve.Provider,H=()=>pe.useContext(ve);function bt(){const o=B(),{form:t,setInForm:a,errors:r}=H(),s=e.useCallback(n=>{a("selected_companies",t.selected_companies.filter(({id:l})=>l!==n))},[t.selected_companies,a]),i=e.useCallback(n=>{if(t.selected_companies.find(({id:l})=>l===n.id)){o.info("Empresa já selecionada");return}a("selected_companies",[...t.selected_companies,n])},[o,t.selected_companies,a]);return e.createElement("div",{className:"space-y-16"},e.createElement(_t,{onCompanySelected:i}),e.createElement(fe,{variant:"outlined",className:z("flex flex-wrap rounded-8 p-8",!!r.selected_companies&&"border-red")},t.selected_companies?.length>0?t.selected_companies.map(n=>e.createElement("div",{key:n.id,className:"p-4"},e.createElement(je,{label:n.name,onDelete:()=>s(n.id),className:"rounded-8 bg-gray-100 text-gray-700"}))):e.createElement("div",{className:"flex w-full items-center justify-center px-12 py-20"},e.createElement("span",{className:z("text-16",r.selected_companies?"text-red":"text-gray-600")},"Nenhuma empresa selecionada"))))}const Et=o=>v.get(o).then(t=>{if(t.status!==200||t.data.status===500)throw Error(t.data.message);return t.data});function yt(){const{data:o,error:t,mutate:a}=ee("/api/v2/admin/organizations/all",Et,{dedupingInterval:6e4,revalidateOnFocus:!1});return{data:o,isLoading:!t&&!o,isError:t,mutate:a}}const ie=Object.values(Be(X,function(o,t){return{key:t,label:o}}));function vt(){const{form:o,handleChange:t,errors:a}=H(),r=ge(({auth:n})=>n.user.role),{data:s}=yt(),i=e.useMemo(()=>r&&P.hasPermission(_e.cwManager,r),[r]);return e.createElement("div",{className:"space-y-20"},i&&e.createElement(L,{label:"Organização",name:"organizations",value:o.organizations||[],onChange:t,optionValueKey:"id",optionLabelKey:"name",options:s?.map(n=>
3({...n,checked:o.organizations?.includes(n.id)})),renderValue:n=>n.map(l=>s?.find(({id:c})=>c===l)?.name||"Desconhecido").join(", "),error:!!a.organizations,helperText:a.organizations,required:!0}),e.createElement(L,{label:"Limitar à empresas que possuem estes módulos",name:"reach_companies_with_module",value:o.reach_companies_with_module||[],onChange:t,optionValueKey:"key",optionLabelKey:"label",options:ie.map(n=>({...n,checked:o.reach_companies_with_module?.includes(n.key)})),renderValue:n=>n.map(l=>X?.[l]||"Desconhecido").join(", ")}),e.createElement(L,{label:"Limitar à empresas que não possuem estes módulos",name:"reach_companies_without_module",value:o.reach_companies_without_module||[],onChange:t,optionValueKey:"key",optionLabelKey:"label",options:ie.map(n=>({...n,checked:o.reach_companies_without_module?.includes(n.key)})),renderValue:n=>n.map(l=>X?.[l]||"Desconhecido").join(", ")}),e.createElement(L,{label:"Limitar à empresas destes segmentos",name:"market_segments",value:o.market_segments||[],onChange:t,options:ot.map(n=>({key:n,label:n,checked:o.market_segments?.includes(n)})),optionValueKey:"key",optionLabelKey:"label",renderValue:n=>n.map(l=>l||"Desconhecido").join(", ")}))}function xt(){const{form:o,setInForm:t}=H(),a=o.target_type==="segmented_group"?0:1;return e.createElement("div",{className:"space-y-20"},e.createElement("div",{className:"space-y-4"},e.createElement("div",{className:"text-16 font-semibold text-gray-600"},"Empresas que serão notificadas"),e.createElement("div",{className:"text-14 text-gray-400"},"Escolha uma das duas formas a seguir para indicar quais empresas serão notificadas")),e.createElement("div",{className:"flex w-full flex-shrink-0"},e.createElement(He,{value:a,onChange:(r,s)=>t("target_type",s===0?"segmented_group":"company"),variant:"fullWidth",classes:{root:"border-0 border-b-1 border-solid border-gray-200 min-h-auto font-normal w-full text-gray-400",indicator:"bg-gray-700"}},["Grupo alvo","Empresas alvo"].filter(r=>r).map(r=>e.createElement(Ve,{key:r,label:r,classes:{root:"normal-case min-w-0 min-h-auto py-8 font-normal",selected:"text-gray-700"}})))),a===0&&e.createElement(vt,null),a===1&&e.createElement(bt,null))}const Nt=[{name:"Gestão de pedidos",pathname:"/latest-orders"},{name:"Análise das vendas",pathname:"/analise-vendas"},{name:"Histórico de pedidos",pathname:"/pedidos"},{name:"Minha empresa",pathname:"/profile"},{name:"Catálogo",pathname:"/cardapio/produtos"},{name:"Usuários",pathname:"/usuarios"},{name:"Faturas",pathname:"/assinaturas"},{name:"Configurações",pathname:"/configuracoes"}],kt={manually:{label:"Abrir modal ao clicar na notificação",key:!1},in_real_time:{label:"Abrir modal automaticamente",key:!0}};function Ct({isNew:o}){const t=Ue(),{form:a,handleChange:r,errors:s,setInForm:i}=H(),[n,l]=e.useState(()=>M.EditorState.createEmpty()),c=e.useRef(!0);e.useEffect(()=>{!o&&c.current&&a.modal_description&&(l(M.EditorState.createWithContent(M.convertFromRaw(JSON.parse(a.modal_description)))),c.current=!1)},[a.modal_description,o]);const d=e.useMemo(()=>de(_=>{const g=_.getCurrentContent();i("modal_description",JSON.stringify(M.convertToRaw(g)))},800),[i]);e.useEffect(()=>{d(n)},[d,n]);const f=e.useCallback(_=>{_.image&&i("file",_.image),_.image_url&&i("image_url",_.image_url)},[i]),h=e.useCallback(_=>{t(We({anchorOrigin:{vertical:"top",horizontal:"center"},autoHideDuration:4e3,message:_,variant:"error"}))},[t]),E=()=>{a.image_url&&i("image_url",null),a.file_url&&i("file_url",null)};return e.createElement("div",{className:"space-y-20"},e.createElement("div",{className:"text-16 font-semibold text-gray-600"},"Notificação"),e.createElement(oe,{name:"kind",label:"Tipo de notificação",value:a.kind,onChange:r,optionValueKey:"key",optionLabelKey:"label",options:Object.values(Ee),error:!!s.kind,helperText:s.kind,required:!0}),e.createElement(A,{name:"message",label:"Mensagem",value:a.message,onChange:r,error:!!s.message,helperText:s.message,multiline:!0,rows:4,required:!0}),e.createElement(fe,{variant:"outlined",className:z("flex min-w-224 items-center space-x-8 px-8",s.link_url?"border-red":"border-grey-border-dark")}
3,e.createElement(ne,{name:"link_type",value:a.link_type,onChange:r,disableUnderline:!0,error:!!s.modal_description},e.createElement(T,{value:"internal"},"Interno"),e.createElement(T,{value:"external"},"Externo"),e.createElement(T,{value:"modal"},"Modal")),e.createElement(he,{orientation:"vertical",flexItem:!0}),a.link_type==="internal"&&e.createElement(ne,{name:"link_url",value:a.link_url,onChange:r,disableUnderline:!0,placeholder:"Selecione uma opção",fullWidth:!0},e.createElement(T,{value:""},"Nenhuma opção selecionada"),Nt.map(({name:_,pathname:g})=>e.createElement(T,{key:g,value:g},_))),a.link_type==="external"&&e.createElement(qe,{name:"link_url",value:a.link_url,onChange:r,placeholder:"https://www.google.com.br",className:"w-full text-14",style:{color:"rgba(0,0,0,0.87)"}}),a.link_type==="modal"&&e.createElement("span",{className:"text-gray-400"},"Informe abaixo o conteúdo do modal")),!!s.link_url&&e.createElement("span",{className:"ml-20 mt-12 w-full text-center text-xs text-red"},s.link_url),a.link_type==="modal"&&e.createElement(e.Fragment,null,e.createElement(A,{name:"modal_title",label:"TÃtulo do modal",value:a.modal_title,onChange:r,error:!!s.modal_title,helperText:s.modal_title,required:!0}),e.createElement(rt,{name:"modal_media_type",value:a.modal_media_type,onChange:(_,g)=>i("modal_media_type",g),size:"small",exclusive:!0,className:"flex"},e.createElement(se,{value:"image",className:"flex-1"},"Imagem/Gif"),e.createElement(se,{value:"video",className:"flex-1"},"VÃdeo do YouTube")),a.modal_media_type==="image"&&e.createElement("div",{className:"flex flex-col items-center"},e.createElement("div",{className:"h-192 w-192"},e.createElement(Ke,{imageURL:a.image_url||a.file_url,onUploaded:f,onError:h,noCrop:!0})),(a.file_url||a.image_url)&&e.createElement(Z,{variant:"outlined",onClick:E,size:"small",className:"mx-4 mt-12 text-gray-500"},"REMOVER IMAGEM")),a.modal_media_type==="video"&&e.createElement(A,{name:"youtube_video_id",label:"ID do vÃdeo no YouTube",placeholder:"Informe apenas o ID do vÃdeo, não o link",value:a.youtube_video_id,onChange:r,error:!!s.modal_description}),e.createElement("div",{className:z("flex flex-col space-y-12 rounded-2",s.modal_description?"border border-solid border-red p-1":"border-grey-border-dark")},e.createElement(nt.Editor,{editorState:n,toolbarClassName:"border-grey-border",toolbarStyle:{padding:"0.8rem",borderRounded:"0.8rem"},wrapperClassName:"p-0 border-1 border-solid border-grey-border-dark rounded-8",editorClassName:"px-12 py-0 border-0",toolbar:{options:["inline","fontSize","colorPicker","list","remove","link","emoji","textAlign"],inline:{inDropdown:!1,component:void 0,dropdownClassName:void 0,options:["bold","italic","strikethrough"]},list:{options:["unordered","ordered"]}},placeholder:"Escreva aqui a descrição da notificação",onEditorStateChange:l,localization:{locale:"pt"}})),!!s.modal_description&&e.createElement("span",{className:"ml-20 mt-12 w-full text-center text-xs text-red"},s.modal_description),e.createElement(oe,{name:"automatic_open",label:"Regra de abertura do modal",value:a.automatic_open,onChange:r,optionValueKey:"key",optionLabelKey:"label",options:Object.values(kt),required:!0})))}const ce={kind:"",message:"",modal_title:"",modal_description:"",modal_media_type:"image",file_url:"",youtube_video_id:"",automatic_open:!1,link_type:"internal",link_url:"",target_type:"segmented_group",description:"",organizations:[],reach_companies_with_module:[],reach_companies_without_module:[],market_segments:[],selected_companies:[]};function wt({open:o,initData:t,onClose:a}){const r=B(),{mutate:s}=be(),[i,n]=e.useState({}),[l,c]=e.useState(!1),d=ge(({auth:u})=>u.user.role),{form:f,handleChange:h,setForm:E,setInForm:_}=Ye(ce),g=e.useRef("new"),I=e.useCallback(()=>{t?(E({...ce,...t,selected_companies:t.selected_companies_with_details||[],modal_media_type:t.youtube_video_id?"video":"image"}),t.id?g.current="edit":g.current="new"):g.current="new"},[t,E]);e.useEffect(()=>{o&&I()},[o,I]);const k=e.useCallback(u=>{i[u.target.name]&&n(w=>({...w,[u.target.name]:""})),h(u)},[i,h]),m=e.useMemo(()=>d&&P.hasPermission(_e.admin,d),[d]),b=e.useCallback(()=>{const u={}
3,{description:w,modal_media_type:S,file:D,file_url:F,youtube_video_id:V,kind:R,message:U,modal_description:x,modal_title:O,organizations:W,selected_companies:q,target_type:K,link_type:N,link_url:Y}=f;return R||(u.kind="Informe o tipo da notificação"),re(U)||(u.message="Informe a mensagem da notificação"),(!N||N!=="modal"&&!Y)&&(u.link_url="Informe o link da notificação"),N==="modal"&&(O.length<1&&(u.modal_title="Informe o tÃtulo do modal"),JSON.parse(x).blocks.every(p=>p.text==="")&&(S==="image"&&!D&&!F?u.modal_description="Informe uma descrição ou faça upload de uma imagem para o modal":S==="video"&&!V&&(u.modal_description="Informe uma descrição ou o ID de um vÃdeo do YouTube"))),K==="segmented_group"?m&&!W?.length&&(u.organizations="Escolha pelo menos uma opção"):q?.length||(u.selected_companies="Nenhuma empresa selecionada"),re(w)||(u.description="Informe uma descrição"),Object.keys(u).length>0?(n(u),!1):!0},[f,m]),C=e.useCallback(()=>{a&&a()},[a]),xe=e.useCallback(async u=>{if(u.preventDefault(),b()&&!l){c(!0);const{description:w,id:S,modal_media_type:D,file:F,file_url:V,youtube_video_id:R,kind:U,link_type:x,link_url:O,message:W,modal_description:q,modal_title:K,target_type:N,automatic_open:Y}=f;let p={id:S,kind:U,message:W,description:w,target_type:N};x&&x!=="modal"&&O&&(p.link_type=x,p.link_url=O),x==="modal"&&(D==="image"?(p.youtube_video_id=null,F?p.file=F:V||(p.file=null)):D==="video"&&(p.file=null,R?p.youtube_video_id=R:p.youtube_video_id=null),p.link_type=x,p.modal_description=q,p.modal_title=K,p.automatic_open=Y);const{organizations:Ne,reach_companies_with_module:ke,reach_companies_without_module:Ce,market_segments:we,selected_companies:Te}=f;N==="segmented_group"?p={...p,organizations:Ne,reach_companies_with_module:ke,reach_companies_without_module:Ce,market_segments:we}:p={...p,selected_companies:Te.map(({id:y})=>y)};const G=new FormData;P.buildFormData(G,p);try{if(g.current==="new"){const y=await it(G);s(j(),$=>[...$,y])}else{const y=await ct(G);s(j(),$=>$.map(te=>te.id===y.id?y:te))}C()}catch(y){r.error(y.message||"Não foi possÃvel concluir a operação")}c(!1)}},[r,f,s,C,l,b]);return e.createElement(ht,{value:{form:f,handleChange:k,setInForm:_,errors:i}},e.createElement("div",{className:"relative flex h-screen w-400 flex-col sm:w-512"},e.createElement("div",{className:"flex items-center justify-between border-0 border-b-1 border-solid border-gray-200 pl-20 pr-12 text-20 font-semibold",style:{height:"var(--topNavigationHeight)",backgroundColor:"#FAFBFC"}},e.createElement("span",null,"Cadastrar template"),e.createElement(Ge,{style:{padding:9},onClick:C},e.createElement($e,null))),e.createElement("div",{className:"relative flex-1 overflow-auto p-16 sm:p-24"},e.createElement("div",{className:"space-y-36"},e.createElement(Ct,{isNew:g.current==="new"}),e.createElement(xt,null))),e.createElement(he,null),e.createElement("div",{className:"space-y-20 px-16 py-12 sm:px-24 sm:py-20"},e.createElement(A,{name:"description",label:"Descrição do template",placeholder:"Exemplo: Notificar empresas que possuem o plano de delivery sobre o lançamento do módulo de fidelidade...",value:f.description,onChange:k,error:!!i.description,helperText:i.description,multiline:!0,rows:3,required:!0}),e.createElement(Z,{variant:"contained",color:"primary",fullWidth:!0,onClick:xe,disabled:l},g.current==="new"?"Salvar template":"Atualizar template")),l&&e.createElement("div",{className:"absolute inset-0 z-9999 flex items-center justify-center bg-white opacity-75"},e.createElement(ue,null))))}function Tt({open:o,initData:t,onClose:a}){return e.createElement(Je,{anchor:"right",open:o,onClose:a},e.createElement(wt,{open:o,onClose:a,initData:t}))}const It=o=>v.get(o).then(t=>{if(t.status!==200||t.data.status===500)throw Error(t.data.message);return t.data});function St(o){return o?`/api/v1/admin/notification/notification_target/${o}/triggers`:null}function Dt(o){const{data:t,error:a,mutate:r}=ee(St(o),It,{dedupingInterval:2e4,revalidateOnFocus:!1});return{count:t?.total,isLoading:!a&&!t,isError:a,mutate:r}}function Ft({open:o,template:t,onClose:a}){const r=B(),{mutate:s}=be(),{count:i,isLoading:n}=Dt(o&&t?.id),[l,c]=e.useState(!1);if(!t)return null;const d=async f=>{if(f.preventDefault(),!(l||n)){if(!i){r.info("Nenhuma empresa receberá essa notificação");return}c(!0);try{await dt(t.id),s(j(),h=>h.map(E=>E.id===t.id?{...t,executed_at:new Date().toISOString()}
3:E),!1),r.success("As notificações serão disparadas dentro de alguns instantes"),a()}catch(h){r.error(h.message||"Não foi possÃvel concluir a operação")}c(!1)}};return e.createElement(Qe,{open:o,title:"Disparar notificação",confirmText:"Disparar",loading:l,onClose:a,onSubmit:d},e.createElement("div",{className:"space-y-20"},e.createElement("div",{className:"rounded-8 border-1 border-solid border-gray-200 bg-white"},e.createElement(tt,{key:t.id,kind:t.kind,message:t.message,created_at:t.created_at})),e.createElement("div",{className:"text-semibold flex items-center justify-center space-x-8 text-center text-20 text-gray-600"},n?e.createElement("div",{className:"inline-block h-28 w-56 animate-pulse rounded-4 bg-gray-200"}):e.createElement("strong",{className:"text-24 font-bold"},i||0),e.createElement("span",null,i===1?"empresa receberá essa notificação":"empresas receberão essa notificação"))))}function Kt(){const[o,t]=e.useState(!1),[a,r]=e.useState(!1),s=e.useRef(null),i=e.useCallback(()=>{s.current=null,t(!0)},[]),n=e.useCallback(d=>{s.current=d,t(!0)},[]),l=e.useCallback(d=>{s.current=d,r(!0)},[]),c=e.useCallback(()=>{s.current=null,r(!1)},[]);return e.createElement(Xe,null,e.createElement("div",{className:"flex w-full flex-1 flex-col space-y-24 overflow-auto px-12 py-24 sm:px-28"},e.createElement(st,{onNewTemplateClick:i}),e.createElement(gt,{editEditTemplateDrawer:n,openTriggerNotificationDialog:l}),e.createElement(Tt,{open:o,initData:s.current,onClose:()=>t(!1)}),e.createElement(Ft,{open:a,template:s.current,onClose:c})))}export{Kt as default}; 4 5//# debugId=cf7dfb68-0e81-50d2-a13a-998e2524fe74
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.