@s_mart/minha-conta 4.0.13 → 5.0.0
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.
- package/dist/index.mjs +38 -38
- package/package.json +64 -44
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{cloneElement as
|
|
2
|
-
background-color: ${
|
|
1
|
+
import{cloneElement as Rs}from"react";import{Grid as ar,Tab as Ms}from"@s_mart/core";import{useEffect as Dt}from"react";import{jwtDecode as Rt}from"jwt-decode";import{Backdrop as st,CircularProgress as lt}from"@s_mart/core";import{jsx as ir}from"react/jsx-runtime";function mt({show:o}){return ir(st,{open:o,style:{zIndex:1e4},children:ir(lt,{size:50,sx:{color:e=>e.palette.primary.main}})})}var nr=mt;import{create as pt}from"zustand";var Me={axiosInstance:null,ready:!1,tabAtiva:"minhaEmpresa",sistemaNome:"",telefoneSuporte:"",telefoneCS:"",minhaEmpresa:{},meuPlano:{},recursosDialog:{},planosDialog:{}};var ct=pt(o=>({...Me,setValues:e=>o(e),setTabAtiva:e=>o({tabAtiva:e}),resetState:()=>o(Me)})),u=ct;import{create as ut}from"zustand";var dt=o=>{let e=[];return typeof o!="object"||(Array.isArray(o)&&typeof o[0]=="string"?e=o:Array.isArray(o.errors)?e=o.errors:typeof o.errors=="string"?e=[o.errors]:typeof o.error=="string"?e=[o.error]:typeof o.erro=="string"?e=[o.erro]:o.erro?.mensagem?e=[o.erro.mensagem]:typeof o.message=="string"?e=[o.message]:typeof o.mensagem=="string"?e=[o.mensagem]:typeof o.authErrors?.[0]=="string"&&(e=o.authErrors)),e},sr=dt;var Ee={loading:!1,notification:null};var ft=ut(o=>({...Ee,setLoading:e=>o({loading:e}),toggleNotification:e=>o({notification:e}),handleErrors:e=>{let r=sr(e);o({loading:!1,notification:{title:r[0],variant:"error",autoHideDuration:5e3}})},resetState:()=>o(Ee)})),b=ft;import{useEffect as gt}from"react";import{useNotification as yt}from"@s_mart/hooks";var ht={success:"A\xE7\xE3o realizada com sucesso!",warning:"Aten\xE7\xE3o",error:"Algum problema ocorreu"},Ct=()=>{let o=b(a=>a.notification),e=b(a=>a.toggleNotification),r=yt();gt(()=>{o&&r.setNotification({title:o.title||ht[o.variant||"success"],message:o.message,variant:o.variant,autoHideDuration:o.autoHideDuration,onClose:(a,i)=>{i!=="clickaway"&&(o.onClose?.(),i!=="maxsnack"&&e(null))},style:{minWidth:"19rem",maxWidth:"50rem"}})},[o])},Yo=Ct;import{create as bt}from"zustand";import mr from"dayjs";import lr from"axios";var xt=()=>{let o=u.getState().axiosInstance,r=u.getState().endpointsV2?"/v2":"";return{fetchMeusDados:()=>o.get(`${r}/meus-dados`),updateMeusDados:a=>o.patch(`${r}/meus-dados`,a),confirmarEmailEmpresa:(a,i)=>lr.post(`${a}/meus-dados/confirmar-atualizacao-do-email-da-empresa/${i}`),confirmarEmailResponsavel:(a,i)=>lr.post(`${a}/meus-dados/confirmar-atualizacao-do-email-do-responsavel/${i}`),fetchMeuPlano:()=>o.get(`${r}/meus-dados/meu-plano/recursos`),contratarRecurso:a=>o.patch(`${r}/meus-dados/plano/contratar-recurso/${a}`),descontratarRecurso:a=>o.patch(`${r}/meus-dados/plano/descontratar-recurso/${a}`),buscarPlano:(a,i)=>o.get(`${r}/meus-dados/plano-buscar/${a}`,{params:{periodicidade:i}}),contratarPlano:a=>o.patch(`${r}/meus-dados/alterar-plano`,a),fetchCobrancas:()=>o.get(`${r}/meus-dados/cobrancas`),fetchBoleto:a=>o.get(`${r}/meus-dados/cobrancas/baixar-boleto/${a}`),fetchNfse:a=>o.get(`${r}/meus-dados/cobrancas/baixar-nfse/${a}`)}},w=xt;var Uo={codigoGrupo:null,codigoPlano:null,dataContratacao:null,descricaoPlano:null,diasCarencia:null,diaVencimentoBoleto:null,nomePlano:null,observacaoPlano:null,periodicidade:null,qtdeBilhetagem:null,recursos:null,tipoAcesso:null,tipoCobranca:null,valor:null,cobrancas:[],fetchedCobrancas:!1,fetchedMeuPlano:!1};var Pt=bt((o,e)=>({...Uo,fetchMeuPlano:async()=>{try{let r=await w().fetchMeuPlano();r.data&&o({...e().fetchedMeuPlano?Uo:{},...r.data,fetchedMeuPlano:!0,fetchedCobrancas:e().fetchedCobrancas})}catch(r){b.getState().handleErrors(r)}},fetchCobrancas:async()=>{try{let r=await w().fetchCobrancas();r.data&&o({cobrancas:r.data.sort((a,i)=>mr(i.dataVencimento).unix()-mr(a.dataVencimento).unix()),fetchedCobrancas:!0})}catch(r){b.getState().handleErrors(r)}},getValorTotalPlano:()=>{let r=e().valor??0,a=e().recursos?.filter(i=>i.recursoContratado).reduce((i,n)=>i+n.valorRecurso,0)??0;return r+a},getMeuPlanoData:()=>{let r={...e()},a=["cobrancas","fetchedCobrancas","fetchedMeuPlano"],i=Object.entries(r).filter(([n,l])=>typeof l!="function"&&!a.includes(n));return Object.fromEntries(i)},resetState:()=>o(Uo)})),x=Pt;import{create as St}from"zustand";var Qo={alteracaoDoEmailDaEmpresa:null,alteracaoDoEmailDoResponsavel:null,bairro:null,cep:null,cidade:null,codigoCidade:null,complemento:null,cpfCnpj:null,dataContratacao:null,dataInativacao:null,email:null,emailResponsavel:null,exibirAbaMeuPlano:null,fone:null,foneResponsavel:null,funruralDescricao:null,funruralTipo:null,ie:null,logotipo:null,motivoInativacao:null,nomeFantasia:null,nomeResponsavel:null,numero:null,razaoSocial:null,regimeTributario:null,rntrc:null,rntrcDataVencimento:null,rua:null,situacao:null,tipoPessoa:null,uf:null,fetched:!1};var vt=St((o,e)=>({...Qo,fetchMinhaEmpresa:async()=>{try{let r=await w().fetchMeusDados();r.data&&o({...Qo,...r.data,fetched:!0})}catch(r){b.getState().handleErrors(r)}},updateMinhaEmpresa:async(r,a)=>{try{await w().updateMeusDados(r),b.getState().toggleNotification({title:"Dados atualizados com sucesso!",variant:"success"}),a?.callback?.(),await e().fetchMinhaEmpresa()}catch(i){a?.fallback?.(i),b.getState().handleErrors(i)}},getMeusDados:()=>{let r={...e()},a=["fetched"],i=Object.entries(r).filter(([n,l])=>typeof l!="function"&&!a.includes(n));return Object.fromEntries(i)},resetState:()=>o(Qo)})),v=vt;import Mt from"axios";import{Fragment as pr,jsx as cr,jsxs as Tt}from"react/jsx-runtime";function Et(o){let e=u(p=>p.ready),r=b(p=>p.loading),a=u(p=>p.setValues),i=u(p=>p.resetState),n=b(p=>p.resetState),l=x(p=>p.resetState),m=v(p=>p.resetState);return Yo(),Dt(()=>{let p,c=o.axiosInstance?.defaults.headers.common.Authorization?.toString().replace("Bearer ","");if(c)try{p={email:Rt(c).email}}catch{}let C=Mt.create({...o.axiosInstance?.defaults});return C?.interceptors.response.use(function(g){return Array.isArray(g.data)?g.data:{...g.data,status:g.status}},function(g){return Promise.reject(g?.response?.data||{message:g?.message})}),a({...o,axiosInstance:C,usuario:p,ready:!0}),()=>{n(),l(),m(),i()}},[]),e?Tt(pr,{children:[o.children,cr(nr,{show:r})]}):cr(pr,{})}var So=Et;import{useMemo as Qa}from"react";import{useMediaQuery as Ss}from"@s_mart/hooks";import{memo as Ei}from"react";import{Divider as Fe,Grid as io,CircularProgress as Ti}from"@s_mart/core";import{Form as Ai}from"@s_mart/form";import{useMediaQuery as Ii}from"@s_mart/hooks";import At from"@emotion/styled";import{css as It}from"@emotion/react";import{colorPalette as Gt}from"@s_mart/tokens";var z=At.div`
|
|
2
|
+
background-color: ${Gt.neutral[0]};
|
|
3
3
|
box-shadow: 0px 3px 12px rgba(0, 0, 0, 0.12);
|
|
4
4
|
border-radius: 4px;
|
|
5
5
|
padding: 1.5rem;
|
|
6
6
|
|
|
7
|
-
height: ${({height:
|
|
7
|
+
height: ${({height:o})=>o};
|
|
8
8
|
|
|
9
|
-
${({centerContent:
|
|
9
|
+
${({centerContent:o})=>!!o&&It`
|
|
10
10
|
display: flex;
|
|
11
11
|
justify-content: center;
|
|
12
12
|
align-items: center;
|
|
@@ -15,25 +15,25 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
15
15
|
@media(max-width: 600px) {
|
|
16
16
|
padding: 1rem;
|
|
17
17
|
}
|
|
18
|
-
`;import{Avatar as
|
|
19
|
-
color: ${
|
|
18
|
+
`;import{Avatar as Lt,Button as Jo,CircularProgress as qt,Grid as Te,LIcon as Ae,Typography as Bt}from"@s_mart/core";import{linePicture as $t,lineSync as Nt,lineTrash as Wt}from"@s_mart/solid-icons";import{colorPalette as ur}from"@s_mart/tokens";import{useMediaQuery as zt}from"@s_mart/hooks";import{useDropzone as wt}from"react-dropzone";import{useFormContext as kt}from"react-hook-form";import{createResizedImage as Ft}from"@s_mart/utils";var Vt=()=>{let{open:o,getInputProps:e}=wt({noKeyboard:!0,multiple:!1,accept:{"image/jpeg":[".jpeg",".jpg"],"image/png":[".png"]},onDrop:C}),r=v(t=>t.nomeFantasia),a=v(t=>t.razaoSocial),i=b(t=>t.toggleNotification),{setValue:n,watch:l,formState:{isSubmitting:m}}=kt(),p=l("logo"),c=t=>new Promise(h=>{Ft(t,300,600,"JPEG",100,0,d=>{h(d)},"file")});async function C(t){let h=t?.[0];if(!h)return i({title:"Selecione um arquivo v\xE1lido",message:"Formatos v\xE1lidos: PNG, JPG e JPEG",variant:"warning",autoHideDuration:1e4});if(!h.type.startsWith("image/"))return i({title:"Formato de imagem inv\xE1lido",variant:"warning"});if(h.size>2e5)return i({title:"Arquivo muito grande (m\xE1ximo 200kB)",variant:"warning",autoHideDuration:5e3});let d=await c(h),D=new FileReader;D.onload=()=>{if(!D.result)return console.log("Ocorreu um erro ao ler o arquivo");n("logo",{conteudo:D.result?.toString().replace(`data:${d.type};base64,`,""),nome:d.name,mimetype:d.type,tamanho:d.size})},D.readAsDataURL(d)}return{open:o,getInputProps:e,logo:p,getIniciaisEmpresa:()=>(r||a||"").split(" ").map(h=>h[0]).join("").substring(0,2).toUpperCase(),onRemoverLogo:()=>n("logo",void 0),isSubmitting:m}},dr=Vt;import{Fragment as Ot,jsx as O,jsxs as Fo}from"react/jsx-runtime";function fr(){let{open:o,getInputProps:e,logo:r,onRemoverLogo:a,getIniciaisEmpresa:i,isSubmitting:n}=dr(),l=zt("(max-width:600px)");return Fo(Te,{container:!0,spacing:2,justifyContent:"space-between",flexWrap:l?"wrap-reverse":void 0,children:[Fo(Te,{item:!0,display:"flex",alignItems:"center",gap:l?"0.5rem":"1rem",children:[O(Lt,{src:r?`data:${r.mimetype};base64,${r.conteudo}`:void 0,sx:{borderRadius:l?"10px":"16px",height:l?"3rem":"4rem",width:l?"3rem":"4rem",backgroundColor:ur.neutral[100]},alt:"Logotipo/empresa",children:!r&&i()}),O("input",{...e()}),r?Fo(Ot,{children:[O(Jo,{type:"button",variant:"neutral",startIcon:l?void 0:O(Ae,{icon:Nt}),onClick:o,children:"Alterar logo"}),O(Jo,{type:"button",variant:"outlined",color:"error",startIcon:l?void 0:O(Ae,{icon:Wt}),onClick:a,children:"Remover"})]}):Fo("div",{children:[O(Jo,{type:"button",variant:"neutral",startIcon:O(Ae,{icon:$t}),onClick:o,children:"Adicionar logo"}),Fo(Bt,{variant:"bodyXXS",color:ur.neutral[100],style:{display:"block",marginTop:"0.3rem"},children:["Utilize imagens no formato .jpg, .png ou .jpeg com",O("br",{})," tamanho recomendado de 300x160 pixels."]})]})]}),O(Te,{item:!0,xs:12,sm:"auto",children:O(Jo,{type:"submit",size:"large",disabled:n,endIcon:n&&O("div",{style:{display:"flex"},children:O(qt,{size:"1rem",sx:{color:"#FFF"}})}),fullWidth:l,children:"Salvar informa\xE7\xF5es"})})]})}import{CircularProgress as Ut,Grid as J,LIcon as Qt,Tooltip as Jt,Typography as yr}from"@s_mart/core";import{TextField as uo,DatePicker as Zt}from"@s_mart/form";import{cpfCnpj as Kt,composeValidators as Vo,required as Lo,email as oi,telefone as ei,maxLength as hr}from"@s_mart/rules";import{lineSync as ri}from"@s_mart/solid-icons";import jt from"@emotion/styled";import{Typography as Ht}from"@s_mart/core";var Ie=jt(Ht)`
|
|
19
|
+
color: ${o=>o?.theme?.palette?.primary?.main};
|
|
20
20
|
cursor: pointer;
|
|
21
21
|
|
|
22
22
|
a {
|
|
23
23
|
text-decoration: none;
|
|
24
|
-
color: ${
|
|
24
|
+
color: ${o=>o?.theme?.palette?.primary?.main};
|
|
25
25
|
}
|
|
26
|
-
`;import{useFormContext as ea}from"react-hook-form";import oa from"dayjs";var a0=()=>{let a=h.getState().axiosInstance,o=h.getState().endpointsV2?"/v2":"";return{fetchRntrc:i=>a.get(`${o}/rntrc?cnpj=${i}`),fetchCep:i=>a.get(`${o}/cep/${i}`),fetchCidades:i=>a.get(`${o}/cidades?search=${i}`)}};var ia=()=>{let a=h(d=>d.minhaEmpresa.camposAdicionais),e=h(d=>d.minhaEmpresa.helperCamposDeEmail),o=h(d=>d.usuario?.email),i=z(d=>d.emailResponsavel),r=z(d=>d.cpfCnpj),n=z(d=>d.alteracaoDoEmailDaEmpresa),s=y(d=>d.toggleNotification),c=y(d=>d.handleErrors),{setValue:m,watch:q,getValues:f}=ea(),{fetchRntrc:v}=a0(),u=q("flags.fetchingRntrc");return{helperCamposDeEmail:e,onAtualizarRntrc:async()=>{if(!(u||!r))try{m("flags.fetchingRntrc",!0);let d=await v(r);if(d.data){let C=f("empresa.rntrc"),b=f("empresa.rntrcDataVencimento"),w=oa(d.data.data_validade,"DD/MM/YYYY");m("empresa.rntrc",d.data.rntrc),m("empresa.rntrcDataVencimento",w),d.data.rntrc===C&&b?.isSame(w)?s({title:"Seu RNTRC est\xE1 atualizado",variant:"success"}):s({title:"RNTRC foi atualizado com sucesso",variant:"success"})}}catch(d){c(d)}finally{m("flags.fetchingRntrc",!1)}},camposAdicionais:a,fetchingRntrc:u,usuarioResponsavel:!!o&&!!i&&o===i,alteracaoDoEmailDaEmpresa:n}},C2=ia;import{jsx as x,jsxs as h1}from"react/jsx-runtime";function x2(){let{camposAdicionais:a,fetchingRntrc:e,onAtualizarRntrc:o,usuarioResponsavel:i,helperCamposDeEmail:r,alteracaoDoEmailDaEmpresa:n}=C2();return h1(Y,{container:!0,spacing:2,children:[h1(Y,{item:!0,xs:12,children:[x(b2,{variant:"titleSM",children:"Dados da empresa"}),!!n&&x(na,{placement:"top-start",title:h1(b2,{variant:"titleXS",children:["Altera\xE7\xE3o de e-mail da empresa solicitada.",x("br",{})," Pendente a confirma\xE7\xE3o de e-mail."]}),children:x("div",{style:{display:"inline"},children:x(ra,{icon:z1,top:"4px"})})})]}),x(Y,{item:!0,xs:12,md:6,children:x(d1,{name:"empresa.cpfCnpj",label:"CNPJ",mask:"cpfCnpj",disabled:!0,required:!0,rules:w1([I1,sa])})}),x(Y,{item:!0,xs:12,md:6,children:x(d1,{name:"empresa.razaoSocial",label:"Raz\xE3o social",required:!0,rules:w1([I1,S2(60)])})}),x(Y,{item:!0,xs:12,md:4,children:x(d1,{name:"empresa.nomeFantasia",label:"Nome fantasia",required:!0,rules:w1([I1,S2(60)])})}),h1(Y,{item:!0,xs:12,md:4,children:[x(d1,{name:"empresa.email",label:"E-mail para recebimento de boletos",disabled:!i,required:!0,rules:w1([I1,ca])}),r]}),x(Y,{item:!0,xs:12,md:4,children:x(d1,{name:"empresa.fone",label:"Telefone da empresa",mask:"telefone",required:!0,rules:w1([I1,ma])})}),a?.ie&&x(Y,{item:!0,xs:12,md:4,...a.ie.grid,children:x(d1,{name:"empresa.ie",label:"Inscri\xE7\xE3o estadual",required:a.ie.required,rules:a.ie.rules})}),a?.rntrc&&h1(Y,{item:!0,xs:12,sm:6,md:4,...a.rntrc.grid,children:[x(d1,{name:"empresa.rntrc",label:"RNTRC",mask:"numero",disabled:e,required:a.rntrc.required,rules:a.rntrc.rules,inputProps:{maxLength:8}}),h1(R0,{variant:"bodyXXS",onClick:o,children:["Atualizar RNTRC",e&&x(la,{size:"0.5rem",thickness:5,style:{marginLeft:"0.3rem"}})]})]}),a?.rntrcVencimento&&h1(Y,{item:!0,xs:12,sm:6,md:4,...a.rntrcVencimento.grid,children:[x(ta,{name:"empresa.rntrcDataVencimento",label:"Vencimento",disabled:e,required:a.rntrcVencimento.required,rules:a.rntrcVencimento.rules}),x(R0,{variant:"bodyXXS",children:x("a",{href:"https://consultapublica.antt.gov.br/Site/ConsultaRNTRC.aspx/ConsultaPublica/",target:"_blank",rel:"noopener noreferrer",children:"Consultar site da ANTT"})})]})]})}import{CircularProgress as ga,Grid as l1,Typography as fa}from"@s_mart/core";import{Autocomplete as Ma,TextField as F1}from"@s_mart/form";import{cep as ya,composeValidators as e0,maxLength as o0,required as G1}from"@s_mart/rules";import{useMemo as qa,useState as da}from"react";import{cep as ha}from"@s_mart/rules";import{useFormContext as pa}from"react-hook-form";import{debounce as va}from"lodash-es";var ua=()=>{let a=y(l=>l.handleErrors),{watch:e,getValues:o,setValue:i}=pa(),[r,n]=da([]),{fetchCep:s,fetchCidades:c}=a0(),m=e("flags.fetchingCep"),q=async l=>{let g=l.replace(/\D/g,"");if(g&&!ha.validate.cep(g)&&g!==o("flags.ultimoCepBuscado"))try{i("flags.fetchingCep",!0);let d=await s(g);d.data.codigo_ibge&&i("endereco.cidade",{label:`${d.data.cidade}/${d.data.uf}`,value:{codigo:d.data.codigo_ibge,nome:d.data.cidade,uf:d.data.uf}}),d.data.bairro&&i("endereco.bairro",d.data.bairro),d.data.logradouro&&i("endereco.rua",d.data.logradouro),d.data.complemento&&i("endereco.complemento",d.data.complemento),i("flags.ultimoCepBuscado",g)}catch{}finally{i("flags.fetchingCep",!1)}},f=async l=>{try{let g=await c(l);n(g.data?.map(d=>({label:`${d.nome}/${d.uf}`,value:{codigo:d.codigo,nome:d.nome,uf:d.uf}})))}catch(g){a(g)}},v=qa(()=>va(f,500),[]);return{onChangeCep:q,fetchingCep:m,onChangeInputCidades:v,onFocusInputCidades:()=>!r.length&&f(""),cidades:r}},P2=ua;import{jsx as R,jsxs as Ha}from"react/jsx-runtime";function Z2(){let{onChangeCep:a,fetchingCep:e,onChangeInputCidades:o,onFocusInputCidades:i,cidades:r}=P2();return Ha(l1,{container:!0,spacing:2,children:[R(l1,{item:!0,xs:12,children:R(fa,{variant:"titleSM",children:"Endere\xE7o"})}),R(l1,{item:!0,xs:12,md:4,children:R(F1,{name:"endereco.cep",label:"CEP",mask:"cep",disabled:e,required:!0,rules:e0([G1,ya]),onInputChange:a,InputProps:{endAdornment:e&&R("div",{style:{display:"flex"},children:R(ga,{thickness:6,size:"1.5rem"})})}})}),R(l1,{item:!0,xs:12,md:4,children:R(Ma,{name:"endereco.cidade",label:"Cidade/UF",options:r,onInputChange:o,onFocus:i,noOptionsText:"Nenhuma cidade encontrada",disabled:e,required:!0,rules:G1})}),R(l1,{item:!0,xs:12,md:4,children:R(F1,{name:"endereco.bairro",label:"Bairro",disabled:e,required:!0,rules:e0([G1,o0(60)])})}),R(l1,{item:!0,xs:12,md:4,children:R(F1,{name:"endereco.rua",label:"Rua",disabled:e,required:!0,rules:e0([G1,o0(60)])})}),R(l1,{item:!0,xs:12,md:4,children:R(F1,{name:"endereco.numero",label:"N\xFAmero",disabled:e,required:!0,rules:e0([G1,o0(60)])})}),R(l1,{item:!0,xs:12,md:4,children:R(F1,{name:"endereco.complemento",label:"Complemento",disabled:e,rules:o0(60)})})]})}import{Grid as B1,LIcon as Va,Tooltip as za,Typography as L2}from"@s_mart/core";import{TextField as k0}from"@s_mart/form";import{composeValidators as T0,email as Ca,maxLength as ba,required as E0,telefone as Sa}from"@s_mart/rules";import{jsx as J,jsxs as i0}from"react/jsx-runtime";function D2(){let a=h(n=>n.usuario?.email),e=z(n=>n.emailResponsavel),o=z(n=>n.alteracaoDoEmailDoResponsavel),i=h(n=>n.minhaEmpresa.helperCamposDeEmail),r=!!a&&!!e&&a===e;return i0(B1,{container:!0,spacing:2,children:[i0(B1,{item:!0,xs:12,children:[J(L2,{variant:"titleSM",children:"Dados do respons\xE1vel"}),!!o&&J(za,{placement:"top-start",title:i0(L2,{variant:"titleXS",children:["Altera\xE7\xE3o de respons\xE1vel solicitada.",J("br",{})," Pendente a confirma\xE7\xE3o de e-mail."]}),children:J("div",{style:{display:"inline"},children:J(Va,{icon:z1,top:"4px"})})})]}),J(B1,{item:!0,xs:12,md:4,children:J(k0,{name:"responsavel.nome",label:"Nome do respons\xE1vel",required:!0,rules:T0([E0,ba(60)])})}),i0(B1,{item:!0,xs:12,md:4,children:[J(k0,{name:"responsavel.email",label:"Email do respons\xE1vel",disabled:!r,required:!0,rules:T0([E0,Ca])}),i]}),J(B1,{item:!0,xs:12,md:4,children:J(k0,{name:"responsavel.fone",label:"Telefone do respons\xE1vel",mask:"telefone",required:!0,rules:T0([E0,Sa])})})]})}import{useState as xa}from"react";import{Button as A2,CircularProgress as Pa,Dialog as l0,Grid as R2,Typography as Za}from"@s_mart/core";import{useFormContext as La}from"react-hook-form";import{Fragment as k2,jsx as T,jsxs as r0}from"react/jsx-runtime";function T2({onConfirmar:a,onClose:e,tipo:o,open:i}){let r=h(f=>f.sistemaNome),[n,s]=xa(!1),{getValues:c}=La(),m=async()=>{s(!0),await a?.(),s(!1)},q={empresa:{title:"Alterar e-mail",content:r0(k2,{children:["O e-mail ",T("strong",{children:c("empresa.email")})," ser\xE1 atualizado para receber mensagens importantes e boletos do ",r,". Fique atento(a) \xE0 sua caixa de entrada para n\xE3o perder informa\xE7\xF5es essenciais.",T("br",{}),T("br",{}),"Deseja alterar o e-mail?"]})},responsavel:{title:"Alterar respons\xE1vel",content:r0(k2,{children:["O respons\xE1vel \xE9 o \xFAnico que pode alterar o e-mail da empresa e dados do respons\xE1vel.",T("br",{}),T("br",{}),"Ao realizar essa altera\xE7\xE3o, voc\xEA perder\xE1 as permiss\xF5es atuais.",T("br",{})," Deseja salvar as altera\xE7\xF5es?"]})}};return r0(l0,{open:i,onClose:e,closeIcon:!n,maxWidth:"xs",disableBackdropClick:n,children:[T(l0.Header,{children:!!o&&q[o].title}),T(l0.Content,{children:T(R2,{container:!0,spacing:2,display:"flex",children:T(R2,{item:!0,xs:12,children:T(Za,{variant:"bodySM",children:!!o&&q[o].content})})})}),r0(l0.Footer,{children:[T(A2,{variant:"neutral",onClick:e,disabled:n,children:"Voltar"}),T(A2,{onClick:m,disabled:n,endIcon:n&&T("div",{style:{display:"flex"},children:T(Pa,{size:"1rem",sx:{color:"#FFF"}})}),children:"Salvar"})]})]})}import{useEffect as Aa,useState as I2}from"react";import Da from"dayjs";var E2=a=>{let e={empresa:{},endereco:{},responsavel:{},flags:{}};return a.logotipo&&(e.logo=a.logotipo),a.cpfCnpj&&(e.empresa.cpfCnpj=a.cpfCnpj),a.razaoSocial&&(e.empresa.razaoSocial=a.razaoSocial),a.nomeFantasia&&(e.empresa.nomeFantasia=a.nomeFantasia),a.email&&(e.empresa.email=a.email),a.fone&&(e.empresa.fone=a.fone),a.ie&&(e.empresa.ie=a.ie),a.rntrc&&(e.empresa.rntrc=a.rntrc),a.rntrcDataVencimento&&a.rntrcDataVencimento!=="0001-01-01T00:00:00Z"&&(e.empresa.rntrcDataVencimento=Da(a.rntrcDataVencimento)),a.cep&&(e.endereco.cep=a.cep,e.flags.ultimoCepBuscado=a.cep),a.cidade&&a.codigoCidade&&a.uf&&(e.endereco.cidade={label:`${a.cidade}/${a.uf}`,value:{codigo:a.codigoCidade,nome:a.cidade,uf:a.uf}}),a.bairro&&(e.endereco.bairro=a.bairro),a.rua&&(e.endereco.rua=a.rua),a.numero&&(e.endereco.numero=a.numero),a.complemento&&(e.endereco.complemento=a.complemento),a.nomeResponsavel&&(e.responsavel.nome=a.nomeResponsavel),a.emailResponsavel&&(e.responsavel.email=a.emailResponsavel),a.foneResponsavel&&(e.responsavel.fone=a.foneResponsavel),e},w2=a=>{let e={};if(a.empresa){let o=a.empresa;o.razaoSocial&&(e.razaoSocial=o.razaoSocial.trim()),o.nomeFantasia&&(e.nomeFantasia=o.nomeFantasia.trim()),o.email&&(e.email=o.email.toLowerCase().trim()),o.ie&&(e.ie=o.ie),o.fone&&(e.fone=o.fone),e.rntrc=o.rntrc||"",o.rntrcDataVencimento?e.rntrcDataVencimento=o.rntrcDataVencimento.toISOString():e.rntrcDataVencimento="0001-01-01T00:00:00Z"}if(a.endereco){let o=a.endereco;o.cep&&(e.cep=o.cep),o.bairro&&(e.bairro=o.bairro),o.rua&&(e.rua=o.rua),o.numero&&(e.numero=o.numero),o.complemento&&(e.complemento=o.complemento),o.cidade?.value&&(e.codigoCidade=o.cidade.value.codigo)}if(a.responsavel){let o=a.responsavel;o.nome&&(e.nomeResponsavel=o.nome.trim()),o.email&&(e.emailResponsavel=o.email.toLowerCase().trim()),o.fone&&(e.foneResponsavel=o.fone)}return a.logo&&(e.logotipo={conteudo:a.logo.conteudo,nome:a.logo.nome,mimetype:a.logo.mimetype,tamanho:a.logo.tamanho}),e};var Ra=()=>{let a=z(l=>l.fetched),e=z(l=>l.email),o=z(l=>l.emailResponsavel),i=z(l=>l.getMeusDados),r=z(l=>l.fetchMinhaEmpresa),n=z(l=>l.updateMinhaEmpresa),s=h(l=>l.minhaEmpresa.onDadosAtualizadosComSucesso),[c,m]=I2(null),[q,f]=I2({open:!1,tipo:"empresa"});Aa(()=>{a?m(E2(i())):r()},[a]);let v=async(l,g)=>{let d=w2(l);await n(d,{callback:()=>{s?.(d),g&&f(w=>({...w,open:!1}))},fallback:()=>g&&f(w=>({...w,open:!1}))})};return{onFormSubmit:async l=>{if(e?.toLowerCase().trim()!==l.empresa.email?.toLowerCase().trim())return f({open:!0,tipo:"empresa",onConfirmar:()=>v(l,!0)});if(o?.toLowerCase().trim()!==l.responsavel.email?.toLowerCase().trim())return f({open:!0,tipo:"responsavel",onConfirmar:()=>v(l,!0)});await v(l)},initialValues:c,confirmarEmailDialog:q,setConfirmarEmailDialog:f}},F2=Ra;import{jsx as Z,jsxs as G2}from"react/jsx-runtime";function Ia(){let{onFormSubmit:a,initialValues:e,confirmarEmailDialog:o,setConfirmarEmailDialog:i}=F2(),r=wa("(max-width: 600px)");return e?G2(Ea,{onSubmit:a,defaultValues:e,children:[Z(O,{style:{borderRadius:r?"0 0 16px 16px":"0 16px 16px 16px"},children:G2(r1,{container:!0,spacing:3,children:[Z(r1,{item:!0,xs:12,children:Z(z2,{})}),Z(r1,{item:!0,xs:12,children:Z(w0,{})}),Z(r1,{item:!0,xs:12,children:Z(x2,{})}),Z(r1,{item:!0,xs:12,children:Z(w0,{})}),Z(r1,{item:!0,xs:12,children:Z(Z2,{})}),Z(r1,{item:!0,xs:12,children:Z(w0,{})}),Z(r1,{item:!0,xs:12,children:Z(D2,{})})]})}),Z(T2,{open:o.open,tipo:o?.tipo,onClose:()=>i(n=>({...n,open:!1})),onConfirmar:o?.onConfirmar})]}):Z(O,{centerContent:!0,height:"75vh",children:Z(Ta,{})})}var B2=ka(Ia);import{memo as mo}from"react";import{Grid as r4}from"@s_mart/core";import{useMediaQuery as qo}from"@s_mart/hooks";import{useState as Ie}from"react";import{Button as N3,CircularProgress as Fe,Grid as $1,LIcon as W3,Typography as c1}from"@s_mart/core";import{decimal as Ge,valor as j3}from"@s_mart/masks";import{colorPalette as Q3}from"@s_mart/tokens";import{useMediaQuery as Be}from"@s_mart/hooks";import{Button as ae,CircularProgress as ee,Dialog as g0,Divider as c3,Grid as a1,LIcon as oe,Typography as m3}from"@s_mart/core";var n0={description:"M24.6 7.6a17 17 0 1 0 0 34 17 17 0 0 0 0-34m0 3.3a13.7 13.7 0 1 1 0 27.4 13.7 13.7 0 0 1 0-27.4m9.6 9-1.5-1.6a1 1 0 0 0-1.2 0l-9.7 9.6-4-4.1a1 1 0 0 0-1.2 0L15 25.3a1 1 0 0 0 0 1.2l6.2 6.3q.7.4 1.2 0L34.2 21q.6-.6 0-1.1",id:"line-check-circle-regular"};var O2={description:"m27 36.9 1.2-1.1a1 1 0 0 0 0-1L18 24.6l10.2-10.3a1 1 0 0 0 0-1l-1.2-1q-.4-.6-1 0L14.5 24q-.5.4 0 1L26 36.8q.5.4 1 0Z",id:"line-chevron-left-regular"},U2={description:"m19.9 12.2-1.1 1q-.5.7 0 1l10 10.3-10 10.3q-.5.5 0 1l1 1q.5.6 1 0L32.5 25q.4-.5 0-1L20.8 12.3q-.5-.5-1 0Z",id:"line-chevron-right-regular"};var $2={description:"M31 25.9H17q-.3 0-.4.4v2q0 .4.4.4h14q.3 0 .4-.5v-1.9q0-.4-.4-.4m3.3-16.6-2.6 1.9-2.2-1.7q-1.7-1-3.3 0L24 11.2l-2.2-1.7a3 3 0 0 0-3.3 0l-2.2 1.7-2.6-1.9c-1.1-.8-2.7 0-2.7 1.5v26.4c0 1.4 1.6 2.3 2.7 1.5l2.6-1.9 2.2 1.7q1.7 1 3.3 0l2.2-1.7 2.2 1.7q1.6 1 3.3 0l2.2-1.7 2.6 1.9c1.1.8 2.7 0 2.7-1.5V10.8c0-1.4-1.6-2.3-2.7-1.5m0 25.9-2.6-1.8-3.8 2.8-4-2.8-3.8 2.8-3.8-2.8-2.5 1.8V12.8l2.5 1.8 3.8-2.8 4 2.8 3.8-2.8 3.8 2.8 2.5-1.8v22.4ZM31 19.3H17q-.3 0-.4.5v1.9q0 .3.4.4h14q.3 0 .4-.4v-2q0-.3-.4-.4",id:"line-receipt-regular"};var C1={description:"M35.2 12.7a15.9 15.9 0 0 0-25 19.1L8 40l8.4-2.2a16 16 0 0 0 23.6-14 16 16 0 0 0-4.8-11.1M24 37a13 13 0 0 1-6.7-1.9l-.5-.3-5 1.3 1.3-4.8-.3-.5a13.2 13.2 0 0 1 20.5-16.3q3.9 3.8 4 9.3C37.3 31 31.3 37 24 37m7.2-10-2.7-1q-.5-.3-.9.2l-1.2 1.5q-.4.4-.9.1c-2.3-1.1-3.9-2-5.4-4.7-.4-.7.4-.6 1.2-2.1v-.7c-.2-.2-1-2.2-1.3-3s-.6-.6-.9-.6h-.7q-.5-.1-1 .4c-.4.4-1.5 1.4-1.5 3.3 0 2 1.5 3.9 1.6 4.1.2.3 2.8 4.3 6.8 6 2.5 1.1 3.5 1.2 4.8 1 .7 0 2.3-1 2.6-1.9q.5-1.5.3-1.9l-.8-.4Z",id:"line-whatsapp-regular"};import{colorPalette as B0}from"@s_mart/tokens";import{useState as Fa}from"react";var Ga=a=>{let[e,o]=Fa(!0);return{open:e,onCloseDialog:()=>{o(!1),setTimeout(()=>a(),100)}}},N=Ga;var Ba=a=>{let e=`https://api.whatsapp.com/send?phone=${a}`;window.open(e,"_blank","noopener noreferrer")},n1=Ba;import{Button as _2,LIcon as F0,Tooltip as Oa,Typography as b1}from"@s_mart/core";import{valor as Ua}from"@s_mart/masks";import{colorPalette as X2}from"@s_mart/tokens";import $a from"dayjs";import{css as N2}from"@emotion/react";import I0 from"@emotion/styled";import{colorPalette as t0}from"@s_mart/tokens";var W2=I0.div`
|
|
26
|
+
`;import{useFormContext as Xt}from"react-hook-form";import _t from"dayjs";var Zo=()=>{let o=u.getState().axiosInstance,r=u.getState().endpointsV2?"/v2":"";return{fetchRntrc:a=>o.get(`${r}/rntrc?cnpj=${a}`),fetchCep:a=>o.get(`${r}/cep/${a}`),fetchCidades:a=>o.get(`${r}/cidades?search=${a}`)}};var Yt=()=>{let o=u(d=>d.minhaEmpresa.camposAdicionais),e=u(d=>d.minhaEmpresa.helperCamposDeEmail),r=u(d=>d.usuario?.email),a=v(d=>d.emailResponsavel),i=v(d=>d.cpfCnpj),n=v(d=>d.alteracaoDoEmailDaEmpresa),l=b(d=>d.toggleNotification),m=b(d=>d.handleErrors),{setValue:p,watch:c,getValues:C}=Xt(),{fetchRntrc:g}=Zo(),y=c("flags.fetchingRntrc");return{helperCamposDeEmail:e,onAtualizarRntrc:async()=>{if(!(y||!i))try{p("flags.fetchingRntrc",!0);let d=await g(i);if(d.data){let D=C("empresa.rntrc"),R=C("empresa.rntrcDataVencimento"),q=_t(d.data.data_validade,"DD/MM/YYYY");p("empresa.rntrc",d.data.rntrc),p("empresa.rntrcDataVencimento",q),d.data.rntrc===D&&R?.isSame(q)?l({title:"Seu RNTRC est\xE1 atualizado",variant:"success"}):l({title:"RNTRC foi atualizado com sucesso",variant:"success"})}}catch(d){m(d)}finally{p("flags.fetchingRntrc",!1)}},camposAdicionais:o,fetchingRntrc:y,usuarioResponsavel:!!r&&!!a&&r===a,alteracaoDoEmailDaEmpresa:n}},gr=Yt;import{jsx as E,jsxs as fo}from"react/jsx-runtime";function Cr(){let{camposAdicionais:o,fetchingRntrc:e,onAtualizarRntrc:r,usuarioResponsavel:a,helperCamposDeEmail:i,alteracaoDoEmailDaEmpresa:n}=gr();return fo(J,{container:!0,spacing:2,children:[fo(J,{item:!0,xs:12,children:[E(yr,{variant:"titleSM",children:"Dados da empresa"}),!!n&&E(Jt,{placement:"top-start",title:fo(yr,{variant:"titleXS",children:["Altera\xE7\xE3o de e-mail da empresa solicitada.",E("br",{})," Pendente a confirma\xE7\xE3o de e-mail."]}),children:E("div",{style:{display:"inline"},children:E(Qt,{icon:ri,top:"4px"})})})]}),E(J,{item:!0,xs:12,md:6,children:E(uo,{name:"empresa.cpfCnpj",label:"CNPJ",mask:"cpfCnpj",disabled:!0,required:!0,rules:Vo([Lo,Kt])})}),E(J,{item:!0,xs:12,md:6,children:E(uo,{name:"empresa.razaoSocial",label:"Raz\xE3o social",required:!0,rules:Vo([Lo,hr(60)])})}),E(J,{item:!0,xs:12,md:4,children:E(uo,{name:"empresa.nomeFantasia",label:"Nome fantasia",required:!0,rules:Vo([Lo,hr(60)])})}),fo(J,{item:!0,xs:12,md:4,children:[E(uo,{name:"empresa.email",label:"E-mail para recebimento de boletos",disabled:!a,required:!0,rules:Vo([Lo,oi])}),i]}),E(J,{item:!0,xs:12,md:4,children:E(uo,{name:"empresa.fone",label:"Telefone da empresa",mask:"telefone",required:!0,rules:Vo([Lo,ei])})}),o?.ie&&E(J,{item:!0,xs:12,md:4,...o.ie.grid,children:E(uo,{name:"empresa.ie",label:"Inscri\xE7\xE3o estadual",required:o.ie.required,rules:o.ie.rules})}),o?.rntrc&&fo(J,{item:!0,xs:12,sm:6,md:4,...o.rntrc.grid,children:[E(uo,{name:"empresa.rntrc",label:"RNTRC",mask:"numero",disabled:e,required:o.rntrc.required,rules:o.rntrc.rules,inputProps:{maxLength:8}}),fo(Ie,{variant:"bodyXXS",onClick:r,children:["Atualizar RNTRC",e&&E(Ut,{size:"0.5rem",thickness:5,style:{marginLeft:"0.3rem"}})]})]}),o?.rntrcVencimento&&fo(J,{item:!0,xs:12,sm:6,md:4,...o.rntrcVencimento.grid,children:[E(Zt,{name:"empresa.rntrcDataVencimento",label:"Vencimento",disabled:e,required:o.rntrcVencimento.required,rules:o.rntrcVencimento.rules}),E(Ie,{variant:"bodyXXS",children:E("a",{href:"https://consultapublica.antt.gov.br/Site/ConsultaRNTRC.aspx/ConsultaPublica/",target:"_blank",rel:"noopener noreferrer",children:"Consultar site da ANTT"})})]})]})}import{CircularProgress as mi,Grid as to,Typography as pi}from"@s_mart/core";import{Autocomplete as ci,TextField as qo}from"@s_mart/form";import{cep as di,composeValidators as Ko,maxLength as oe,required as Bo}from"@s_mart/rules";import{useMemo as ai,useState as ti}from"react";import{cep as ii}from"@s_mart/rules";import{useFormContext as ni}from"react-hook-form";import{debounce as si}from"lodash-es";var li=()=>{let o=b(t=>t.handleErrors),{watch:e,getValues:r,setValue:a}=ni(),[i,n]=ti([]),{fetchCep:l,fetchCidades:m}=Zo(),p=e("flags.fetchingCep"),c=async t=>{let h=t.replace(/\D/g,"");if(h&&!ii.validate.cep(h)&&h!==r("flags.ultimoCepBuscado"))try{a("flags.fetchingCep",!0);let d=await l(h);d.data.codigo_ibge&&a("endereco.cidade",{label:`${d.data.cidade}/${d.data.uf}`,value:{codigo:d.data.codigo_ibge,nome:d.data.cidade,uf:d.data.uf}}),d.data.bairro&&a("endereco.bairro",d.data.bairro),d.data.logradouro&&a("endereco.rua",d.data.logradouro),d.data.complemento&&a("endereco.complemento",d.data.complemento),a("flags.ultimoCepBuscado",h)}catch{}finally{a("flags.fetchingCep",!1)}},C=async t=>{try{let h=await m(t);n(h.data?.map(d=>({label:`${d.nome}/${d.uf}`,value:{codigo:d.codigo,nome:d.nome,uf:d.uf}})))}catch(h){o(h)}},g=ai(()=>si(C,500),[]);return{onChangeCep:c,fetchingCep:p,onChangeInputCidades:g,onFocusInputCidades:()=>!i.length&&C(""),cidades:i}},xr=li;import{jsx as k,jsxs as ui}from"react/jsx-runtime";function br(){let{onChangeCep:o,fetchingCep:e,onChangeInputCidades:r,onFocusInputCidades:a,cidades:i}=xr();return ui(to,{container:!0,spacing:2,children:[k(to,{item:!0,xs:12,children:k(pi,{variant:"titleSM",children:"Endere\xE7o"})}),k(to,{item:!0,xs:12,md:4,children:k(qo,{name:"endereco.cep",label:"CEP",mask:"cep",disabled:e,required:!0,rules:Ko([Bo,di]),onInputChange:o,InputProps:{endAdornment:e&&k("div",{style:{display:"flex"},children:k(mi,{thickness:6,size:"1.5rem"})})}})}),k(to,{item:!0,xs:12,md:4,children:k(ci,{name:"endereco.cidade",label:"Cidade/UF",options:i,onInputChange:r,onFocus:a,noOptionsText:"Nenhuma cidade encontrada",disabled:e,required:!0,rules:Bo})}),k(to,{item:!0,xs:12,md:4,children:k(qo,{name:"endereco.bairro",label:"Bairro",disabled:e,required:!0,rules:Ko([Bo,oe(60)])})}),k(to,{item:!0,xs:12,md:4,children:k(qo,{name:"endereco.rua",label:"Rua",disabled:e,required:!0,rules:Ko([Bo,oe(60)])})}),k(to,{item:!0,xs:12,md:4,children:k(qo,{name:"endereco.numero",label:"N\xFAmero",disabled:e,required:!0,rules:Ko([Bo,oe(60)])})}),k(to,{item:!0,xs:12,md:4,children:k(qo,{name:"endereco.complemento",label:"Complemento",disabled:e,rules:oe(60)})})]})}import{Grid as $o,LIcon as fi,Tooltip as gi,Typography as Pr}from"@s_mart/core";import{TextField as Ge}from"@s_mart/form";import{composeValidators as we,email as yi,maxLength as hi,required as ke,telefone as Ci}from"@s_mart/rules";import{lineSync as xi}from"@s_mart/solid-icons";import{jsx as Z,jsxs as ee}from"react/jsx-runtime";function Sr(){let o=u(n=>n.usuario?.email),e=v(n=>n.emailResponsavel),r=v(n=>n.alteracaoDoEmailDoResponsavel),a=u(n=>n.minhaEmpresa.helperCamposDeEmail),i=!!o&&!!e&&o===e;return ee($o,{container:!0,spacing:2,children:[ee($o,{item:!0,xs:12,children:[Z(Pr,{variant:"titleSM",children:"Dados do respons\xE1vel"}),!!r&&Z(gi,{placement:"top-start",title:ee(Pr,{variant:"titleXS",children:["Altera\xE7\xE3o de respons\xE1vel solicitada.",Z("br",{})," Pendente a confirma\xE7\xE3o de e-mail."]}),children:Z("div",{style:{display:"inline"},children:Z(fi,{icon:xi,top:"4px"})})})]}),Z($o,{item:!0,xs:12,md:4,children:Z(Ge,{name:"responsavel.nome",label:"Nome do respons\xE1vel",required:!0,rules:we([ke,hi(60)])})}),ee($o,{item:!0,xs:12,md:4,children:[Z(Ge,{name:"responsavel.email",label:"Email do respons\xE1vel",disabled:!i,required:!0,rules:we([ke,yi])}),a]}),Z($o,{item:!0,xs:12,md:4,children:Z(Ge,{name:"responsavel.fone",label:"Telefone do respons\xE1vel",mask:"telefone",required:!0,rules:we([ke,Ci])})})]})}import{useState as bi}from"react";import{Button as vr,CircularProgress as Pi,Dialog as re,Grid as Dr,Typography as Si}from"@s_mart/core";import{useFormContext as vi}from"react-hook-form";import{Fragment as Rr,jsx as V,jsxs as ae}from"react/jsx-runtime";function Mr({onConfirmar:o,onClose:e,tipo:r,open:a}){let i=u(C=>C.sistemaNome),[n,l]=bi(!1),{getValues:m}=vi(),p=async()=>{l(!0),await o?.(),l(!1)},c={empresa:{title:"Alterar e-mail",content:ae(Rr,{children:["O e-mail ",V("strong",{children:m("empresa.email")})," ser\xE1 atualizado para receber mensagens importantes e boletos do ",i,". Fique atento(a) \xE0 sua caixa de entrada para n\xE3o perder informa\xE7\xF5es essenciais.",V("br",{}),V("br",{}),"Deseja alterar o e-mail?"]})},responsavel:{title:"Alterar respons\xE1vel",content:ae(Rr,{children:["O respons\xE1vel \xE9 o \xFAnico que pode alterar o e-mail da empresa e dados do respons\xE1vel.",V("br",{}),V("br",{}),"Ao realizar essa altera\xE7\xE3o, voc\xEA perder\xE1 as permiss\xF5es atuais.",V("br",{})," Deseja salvar as altera\xE7\xF5es?"]})}};return ae(re,{open:a,onClose:e,closeIcon:!n,maxWidth:"xs",disableBackdropClick:n,children:[V(re.Header,{children:!!r&&c[r].title}),V(re.Content,{children:V(Dr,{container:!0,spacing:2,display:"flex",children:V(Dr,{item:!0,xs:12,children:V(Si,{variant:"bodySM",children:!!r&&c[r].content})})})}),ae(re.Footer,{children:[V(vr,{variant:"neutral",onClick:e,disabled:n,children:"Voltar"}),V(vr,{onClick:p,disabled:n,endIcon:n&&V("div",{style:{display:"flex"},children:V(Pi,{size:"1rem",sx:{color:"#FFF"}})}),children:"Salvar"})]})]})}import{useEffect as Ri,useState as Ar}from"react";import Di from"dayjs";var Er=o=>{let e={empresa:{},endereco:{},responsavel:{},flags:{}};return o.logotipo&&(e.logo=o.logotipo),o.cpfCnpj&&(e.empresa.cpfCnpj=o.cpfCnpj),o.razaoSocial&&(e.empresa.razaoSocial=o.razaoSocial),o.nomeFantasia&&(e.empresa.nomeFantasia=o.nomeFantasia),o.email&&(e.empresa.email=o.email),o.fone&&(e.empresa.fone=o.fone),o.ie&&(e.empresa.ie=o.ie),o.rntrc&&(e.empresa.rntrc=o.rntrc),o.rntrcDataVencimento&&o.rntrcDataVencimento!=="0001-01-01T00:00:00Z"&&(e.empresa.rntrcDataVencimento=Di(o.rntrcDataVencimento)),o.cep&&(e.endereco.cep=o.cep,e.flags.ultimoCepBuscado=o.cep),o.cidade&&o.codigoCidade&&o.uf&&(e.endereco.cidade={label:`${o.cidade}/${o.uf}`,value:{codigo:o.codigoCidade,nome:o.cidade,uf:o.uf}}),o.bairro&&(e.endereco.bairro=o.bairro),o.rua&&(e.endereco.rua=o.rua),o.numero&&(e.endereco.numero=o.numero),o.complemento&&(e.endereco.complemento=o.complemento),o.nomeResponsavel&&(e.responsavel.nome=o.nomeResponsavel),o.emailResponsavel&&(e.responsavel.email=o.emailResponsavel),o.foneResponsavel&&(e.responsavel.fone=o.foneResponsavel),e},Tr=o=>{let e={};if(o.empresa){let r=o.empresa;r.razaoSocial&&(e.razaoSocial=r.razaoSocial.trim()),r.nomeFantasia&&(e.nomeFantasia=r.nomeFantasia.trim()),r.email&&(e.email=r.email.toLowerCase().trim()),r.ie&&(e.ie=r.ie),r.fone&&(e.fone=r.fone),e.rntrc=r.rntrc||"",r.rntrcDataVencimento?e.rntrcDataVencimento=r.rntrcDataVencimento.toISOString():e.rntrcDataVencimento="0001-01-01T00:00:00Z"}if(o.endereco){let r=o.endereco;r.cep&&(e.cep=r.cep),r.bairro&&(e.bairro=r.bairro),r.rua&&(e.rua=r.rua),r.numero&&(e.numero=r.numero),r.complemento&&(e.complemento=r.complemento),r.cidade?.value&&(e.codigoCidade=r.cidade.value.codigo)}if(o.responsavel){let r=o.responsavel;r.nome&&(e.nomeResponsavel=r.nome.trim()),r.email&&(e.emailResponsavel=r.email.toLowerCase().trim()),r.fone&&(e.foneResponsavel=r.fone)}return o.logo&&(e.logotipo={conteudo:o.logo.conteudo,nome:o.logo.nome,mimetype:o.logo.mimetype,tamanho:o.logo.tamanho}),e};var Mi=()=>{let o=v(t=>t.fetched),e=v(t=>t.email),r=v(t=>t.emailResponsavel),a=v(t=>t.getMeusDados),i=v(t=>t.fetchMinhaEmpresa),n=v(t=>t.updateMinhaEmpresa),l=u(t=>t.minhaEmpresa.onDadosAtualizadosComSucesso),[m,p]=Ar(null),[c,C]=Ar({open:!1,tipo:"empresa"});Ri(()=>{o?p(Er(a())):i()},[o]);let g=async(t,h)=>{let d=Tr(t);await n(d,{callback:()=>{l?.(d),h&&C(q=>({...q,open:!1}))},fallback:()=>h&&C(q=>({...q,open:!1}))})};return{onFormSubmit:async t=>{if(e?.toLowerCase().trim()!==t.empresa.email?.toLowerCase().trim())return C({open:!0,tipo:"empresa",onConfirmar:()=>g(t,!0)});if(r?.toLowerCase().trim()!==t.responsavel.email?.toLowerCase().trim())return C({open:!0,tipo:"responsavel",onConfirmar:()=>g(t,!0)});await g(t)},initialValues:m,confirmarEmailDialog:c,setConfirmarEmailDialog:C}},Ir=Mi;import{jsx as A,jsxs as Gr}from"react/jsx-runtime";function Gi(){let{onFormSubmit:o,initialValues:e,confirmarEmailDialog:r,setConfirmarEmailDialog:a}=Ir(),i=Ii("(max-width: 600px)");return e?Gr(Ai,{onSubmit:o,defaultValues:e,children:[A(z,{style:{borderRadius:i?"0 0 16px 16px":"0 16px 16px 16px"},children:Gr(io,{container:!0,spacing:3,children:[A(io,{item:!0,xs:12,children:A(fr,{})}),A(io,{item:!0,xs:12,children:A(Fe,{})}),A(io,{item:!0,xs:12,children:A(Cr,{})}),A(io,{item:!0,xs:12,children:A(Fe,{})}),A(io,{item:!0,xs:12,children:A(br,{})}),A(io,{item:!0,xs:12,children:A(Fe,{})}),A(io,{item:!0,xs:12,children:A(Sr,{})})]})}),A(Mr,{open:r.open,tipo:r?.tipo,onClose:()=>a(n=>({...n,open:!1})),onConfirmar:r?.onConfirmar})]}):A(z,{centerContent:!0,height:"75vh",children:A(Ti,{})})}var wr=Ei(Gi);import{memo as xs}from"react";import{Grid as _a}from"@s_mart/core";import{useMediaQuery as bs}from"@s_mart/hooks";import{useState as zn}from"react";import{Button as ka,CircularProgress as On,Grid as zo,LIcon as Fa,Typography as mo}from"@s_mart/core";import{decimal as jn,valor as Va}from"@s_mart/masks";import{colorPalette as La}from"@s_mart/tokens";import{lineShoppingCard as Hn,lineStar as Xn}from"@s_mart/solid-icons";import{useMediaQuery as _n}from"@s_mart/hooks";import{Button as Qi,CircularProgress as Ji,Dialog as fe,Divider as Jr,Grid as oo,LIcon as Zi,Typography as Zr}from"@s_mart/core";import{lineWhatsApp as Ki}from"@s_mart/regular-icons";import{colorPalette as Be}from"@s_mart/tokens";import{useState as wi}from"react";var ki=o=>{let[e,r]=wi(!0);return{open:e,onCloseDialog:()=>{r(!1),setTimeout(()=>o(),100)}}},H=ki;var Fi=o=>{let e=`https://api.whatsapp.com/send?phone=${o}`;window.open(e,"_blank","noopener noreferrer")},no=Fi;import{Button as qr,LIcon as Le,Tooltip as Vi,Typography as vo}from"@s_mart/core";import{lineCheckCircle as Li}from"@s_mart/regular-icons";import{lineStar as qi,lineWhatsappBrands as Bi}from"@s_mart/solid-icons";import{valor as $i}from"@s_mart/masks";import{colorPalette as Br}from"@s_mart/tokens";import Ni from"dayjs";import{css as kr}from"@emotion/react";import Ve from"@emotion/styled";import{colorPalette as te}from"@s_mart/tokens";var Fr=Ve.div`
|
|
27
27
|
display: flex;
|
|
28
28
|
padding: 1rem;
|
|
29
29
|
gap: 1rem;
|
|
30
30
|
min-height: 10rem;
|
|
31
|
-
border: 1px solid ${
|
|
31
|
+
border: 1px solid ${te.neutral[50]};
|
|
32
32
|
border-radius: 6px;
|
|
33
|
-
background-color: ${({recursoContratado:
|
|
33
|
+
background-color: ${({recursoContratado:o})=>o?te.neutral[30]:te.neutral[0]};
|
|
34
34
|
transition: 200ms;
|
|
35
35
|
|
|
36
|
-
${({emDestaque:
|
|
36
|
+
${({emDestaque:o,theme:e})=>o&&kr`
|
|
37
37
|
border: 1px solid ${e.palette.primary.main};
|
|
38
38
|
box-shadow:
|
|
39
39
|
0px 0px 4px 0px rgba(0, 0, 0, 0.25),
|
|
@@ -41,21 +41,21 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
41
41
|
`}
|
|
42
42
|
|
|
43
43
|
:hover {
|
|
44
|
-
background-color: ${({recursoContratado:
|
|
45
|
-
border: 1px solid ${({recursoContratado:
|
|
44
|
+
background-color: ${({recursoContratado:o})=>o&&te.neutral[50]};
|
|
45
|
+
border: 1px solid ${({recursoContratado:o,theme:e})=>!o&&e?.palette?.primary?.main};
|
|
46
46
|
}
|
|
47
|
-
`,
|
|
47
|
+
`,Vr=Ve.img`
|
|
48
48
|
height: 3.5rem;
|
|
49
49
|
width: 3.5rem;
|
|
50
50
|
|
|
51
|
-
cursor: ${({hasGif:
|
|
52
|
-
`,
|
|
51
|
+
cursor: ${({hasGif:o})=>o?"pointer":void 0};
|
|
52
|
+
`,Lr=Ve.div`
|
|
53
53
|
display: flex;
|
|
54
54
|
justify-content: space-between;
|
|
55
55
|
align-items: center;
|
|
56
56
|
margin-top: 0.5rem;
|
|
57
57
|
|
|
58
|
-
${({emDestaque:
|
|
58
|
+
${({emDestaque:o})=>o&&kr`
|
|
59
59
|
justify-content: end;
|
|
60
60
|
gap: 0.5rem;
|
|
61
61
|
`}
|
|
@@ -68,7 +68,7 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
68
68
|
width: 100%;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
`;import{Fragment as
|
|
71
|
+
`;import{Fragment as Wi,jsx as B,jsxs as go}from"react/jsx-runtime";function qe({recurso:o,periodicidade:e,onClick:r,onAdquirir:a,onRemover:i}){let n=u(g=>g.telefoneCS),l=u(g=>g.telefoneSuporte),m=u(g=>g.recursosDialog.esconderValoresRecursos),p=o.valorRecurso===0&&o.recursoContratado,c=u(g=>g.recursosDialog.acaoSecundariaOnClickRecurso),C=()=>p?B(Wi,{}):o.recursoContratado?o.dataExclusaoRecurso?B(Vi,{title:go(vo,{variant:"bodySM",children:["Recurso dispon\xEDvel at\xE9 ",Ni(o.dataExclusaoRecurso).format("DD/MM/YYYY")]}),children:B("div",{style:{padding:"0.3rem 0"},children:B(vo,{variant:"bodySM",children:"Removido"})})}):B(qr,{variant:"neutral",size:"small",onClick:g=>{g.stopPropagation(),i(o)},children:"Remover"}):B(qr,{variant:o.emDestaque?"contained":"outlined",size:"small",fullWidth:m,startIcon:m&&B(Le,{icon:Bi,size:"22px",removeMargin:!0}),onClick:g=>{m?no(n||l):(g.stopPropagation(),a(o)),c?.()},children:m?"Quero saber mais":"Adquirir"});return go(Fr,{recursoContratado:o.recursoContratado,emDestaque:o.emDestaque,onClick:()=>o.gif&&r(o),children:[B("div",{children:B(Vr,{src:o.caminhoImagem,hasGif:!!o.gif})}),go("div",{style:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1},children:[go("div",{children:[go("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"0.1rem"},children:[B(vo,{variant:"titleSM",children:o.nomeRecurso}),o.recursoContratado&&B(Le,{icon:Li,size:"24px",color:Br.green[500]}),o.emDestaque&&B(Le,{icon:qi,size:"24px",color:Br.yellow[300]})]}),B(vo,{variant:"bodySM",children:o.descricaoRecurso})]}),go(Lr,{emDestaque:o.emDestaque,children:[p?B(vo,{variant:"titleXS",padding:"0.3rem 0",children:"Recurso incluso"}):!m&&go(vo,{variant:"titleXS",children:[$i.format(o.valorRecurso),"/",e]}),C()]})]})]})}import{Button as Nr,Dialog as ie,Grid as ne,Typography as Wr}from"@s_mart/core";import zi from"@emotion/styled";var $r=zi.img`
|
|
72
72
|
max-width: 520px;
|
|
73
73
|
|
|
74
74
|
@media only screen and (max-width: 640px) {
|
|
@@ -82,14 +82,14 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
82
82
|
@media only screen and (max-width: 420px) {
|
|
83
83
|
max-width: 260px;
|
|
84
84
|
}
|
|
85
|
-
`;import{jsx as
|
|
85
|
+
`;import{jsx as _,jsxs as zr}from"react/jsx-runtime";function Or({recurso:o,onClose:e,onAdquirirRecurso:r,onRemoverRecurso:a}){let{open:i,onCloseDialog:n}=H(e),l=o.valorRecurso===0&&o.recursoContratado,m=async()=>{await a(o),n()},p=async()=>{await r(o),n()};return zr(ie,{open:i,closeIcon:!0,onClose:n,children:[_(ie.Header,{children:"Este recurso pode ajudar voc\xEA!"}),_(ie.Content,{children:zr(ne,{container:!0,direction:"column",alignItems:"center",spacing:2,children:[_(ne,{item:!0,children:_(Wr,{variant:"titleSM",children:o.nomeRecurso})}),_(ne,{item:!0,children:_(Wr,{variant:"bodySM",children:o.descricaoRecurso})}),o.gif&&_(ne,{item:!0,children:_($r,{src:o.gif})})]})}),!l&&!o.dataExclusaoRecurso&&_(ie.Footer,{children:o.recursoContratado?_(Nr,{color:"error",onClick:m,children:"Remover recurso"}):_(Nr,{onClick:p,children:"Adquirir recurso"})})]})}import{Button as jr,Dialog as se,Grid as le,Typography as me}from"@s_mart/core";import{valor as ji}from"@s_mart/masks";var Oi=(o,e)=>{let r=e?.modelo||"mes",a=o??0;return{mes:{0:"m\xEAs",1:"tri",2:"sem",3:"ano"},mensais:{0:"mensais",1:"trimestrais",2:"semestrais",3:"anuais"},mensalidade:{0:"mensalidade",1:"trimestralidade",2:"semestralidade",3:"anualidade"}}[r][a]},$=Oi;import{jsx as Y,jsxs as No}from"react/jsx-runtime";function Hr({recurso:o,onClose:e,onConfirmar:r}){let a=x(m=>m.periodicidade),{open:i,onCloseDialog:n}=H(e),l=async()=>{await r(o),n()};return No(se,{open:i,closeIcon:!0,onClose:n,children:[Y(se.Header,{children:"Adquirir novo recurso"}),Y(se.Content,{children:No(le,{container:!0,children:[No(le,{item:!0,xs:12,children:[Y(me,{variant:"bodySM",children:"Voc\xEA est\xE1 adquirindo um recurso do seu sistema: "}),Y(me,{variant:"titleXS",children:o.nomeRecurso})]}),Y(le,{item:!0,xs:12,children:No(me,{variant:"bodySM",children:["Informamos que sua ",$(a,{modelo:"mensalidade"})," ter\xE1 uma adi\xE7\xE3o de"," ",ji.format(o.valorRecurso)]})}),Y("br",{}),Y("br",{}),Y(le,{item:!0,xs:12,children:Y(me,{variant:"bodySM",children:"Deseja confirmar a aquisi\xE7\xE3o?"})})]})}),No(se.Footer,{children:[Y(jr,{variant:"neutral",onClick:n,children:"Cancelar"}),Y(jr,{onClick:l,children:"Confirmar"})]})]})}import{Button as Xr,Dialog as pe,Grid as ce,Typography as de}from"@s_mart/core";import{jsx as U,jsxs as Wo}from"react/jsx-runtime";function _r({recurso:o,onClose:e,onRemover:r}){let a=x(m=>m.periodicidade),{open:i,onCloseDialog:n}=H(e),l=async()=>{await r(o),n()};return Wo(pe,{open:i,closeIcon:!0,onClose:n,children:[U(pe.Header,{children:"Remover recurso"}),U(pe.Content,{children:Wo(ce,{container:!0,children:[Wo(ce,{item:!0,xs:12,children:[U(de,{variant:"bodySM",children:"Voc\xEA est\xE1 removendo um recurso do seu sistema: "}),U(de,{variant:"titleXS",children:o.nomeRecurso})]}),U(ce,{item:!0,xs:12,children:Wo(de,{variant:"bodySM",children:["Sua ",$(a,{modelo:"mensalidade"})," ter\xE1 uma altera\xE7\xE3o."]})}),U("br",{}),U("br",{}),U(ce,{item:!0,xs:12,children:U(de,{variant:"bodySM",children:"Deseja confirmar a remo\xE7\xE3o?"})})]})}),Wo(pe.Footer,{children:[U(Xr,{color:"error",onClick:l,children:"Remover"}),U(Xr,{variant:"neutral",onClick:n,children:"Cancelar"})]})]})}import{Grid as ue,Typography as Yr}from"@s_mart/core";import{jsx as Do,jsxs as Hi}from"react/jsx-runtime";function Ur(){let o=u(e=>e.recursosDialog.emptyStateImg);return Hi(ue,{container:!0,spacing:2,direction:"column",alignItems:"center",margin:"2rem 0",children:[!!o&&Do(ue,{item:!0,children:Do("img",{src:o,alt:"emptyStateImg"})}),Do(ue,{item:!0,textAlign:"center",children:Do(Yr,{variant:"titleMD",children:"Novos recursos v\xEAm a\xED"})}),Do(ue,{item:!0,textAlign:"center",children:Do(Yr,{variant:"bodyMD",children:"Voc\xEA j\xE1 possui todos os recursos dispon\xEDveis no momento."})})]})}import{useEffect as Xi,useMemo as _i,useState as Yi}from"react";var Ui=()=>{let[o,e]=Yi(null),r=x(s=>s.fetchedMeuPlano),a=x(s=>s.fetchMeuPlano),i=x(s=>s.recursos),n=x(s=>s.periodicidade),l=u(s=>s.sistemaNome),m=u(s=>s.telefoneSuporte),p=u(s=>s.telefoneCS),c=u(s=>s.recursosDialog.recursosGifs),C=u(s=>s.recursosDialog.recursoEmDestaque),g=u(s=>s.recursosDialog.onContratarRecurso),y=u(s=>s.recursosDialog.onRemoverRecurso),t=b(s=>s.handleErrors),h=b(s=>s.setLoading),d=b(s=>s.toggleNotification),{contratarRecurso:D,descontratarRecurso:R}=w(),q=$(n),ro=_i(()=>{let s={contratados:[],naoContratados:[]};return i?.forEach(f=>{let P=c?.find(S=>S.slug===f.slugRecurso)?.gif||null;f.recursoContratado?s.contratados.push({...f,gif:P,emDestaque:!1}):s.naoContratados.push({...f,gif:P,emDestaque:f.slugRecurso===C})}),C&&s.naoContratados.sort(f=>f.emDestaque?-1:1),s},[i,c,C]);return Xi(()=>{r||a()},[r]),{sistemaNome:l,alreadyFetchedMeuPlano:r,telefoneSuporte:m,telefoneCS:p,recursos:ro,periodicidadeLabel:q,handleClickRecurso:s=>e({open:"gif",recurso:s}),openedDialog:o,handleCloseDialog:()=>e(null),handleAdquirirRecurso:s=>e({open:"confirmacaoAdquirir",recurso:s}),handleRemoverRecurso:s=>e({open:"confirmacaoRemover",recurso:s}),adquirirRecurso:async s=>{try{h(!0),await D(s.codigoRecurso),a(),d({title:"Novo recurso adquirido"}),h(!1),g?.(s)}catch(f){t(f)}},removerRecurso:async s=>{try{h(!0),await R(s.codigoRecurso),a(),d({title:"O recurso foi removido"}),h(!1),y?.(s)}catch(f){t(f)}}}},Qr=Ui;import{Fragment as Kr,jsx as M,jsxs as yo}from"react/jsx-runtime";function ge({onClose:o,esconderValoresRecursos:e}){let{sistemaNome:r,alreadyFetchedMeuPlano:a,telefoneSuporte:i,telefoneCS:n,recursos:l,periodicidadeLabel:m,handleClickRecurso:p,openedDialog:c,handleAdquirirRecurso:C,handleCloseDialog:g,handleRemoverRecurso:y,adquirirRecurso:t,removerRecurso:h}=Qr(),{open:d,onCloseDialog:D}=H(o);return yo(Kr,{children:[yo(fe,{open:d,onClose:D,fullWidth:!0,maxWidth:"lg",closeIcon:!0,disableBackdropClick:!0,children:[yo(fe.Header,{children:["Recursos ",r]}),a?yo(Kr,{children:[M(fe.Content,{style:{marginTop:"1rem"},children:yo(oo,{container:!0,spacing:2,children:[yo(oo,{item:!0,xs:12,display:"flex",alignItems:"center",children:[M(Zr,{variant:"titleSM",children:"Recursos feitos para ajudar voc\xEA"}),M(Jr,{style:{flex:1,marginLeft:"1rem",color:Be.neutral[30]}})]}),M(oo,{item:!0,xs:12,children:M(oo,{container:!0,spacing:2,children:l.naoContratados.length?l.naoContratados.map(R=>M(oo,{item:!0,xs:12,sm:R.emDestaque?12:6,children:M(qe,{recurso:R,periodicidade:m,esconderValoresRecursos:e,onClick:p,onAdquirir:C,onRemover:y})},R.codigoRecurso)):M(Ur,{})})}),yo(oo,{item:!0,xs:12,display:"flex",alignItems:"center",children:[M(Zr,{variant:"titleSM",children:"Recursos que voc\xEA j\xE1 adquiriu"}),M(Jr,{style:{flex:1,marginLeft:"1rem",color:Be.neutral[30]}})]}),M(oo,{item:!0,xs:12,children:M(oo,{container:!0,spacing:2,children:l.contratados.map(R=>M(oo,{item:!0,xs:12,sm:6,children:M(qe,{recurso:R,periodicidade:m,onClick:p,onAdquirir:C,onRemover:y})},R.codigoRecurso))})})]})}),M(fe.Footer,{children:M(Qi,{variant:"outlined",color:"neutral",startIcon:M(Zi,{icon:Ki,size:"22px",removeMargin:!0}),style:{color:Be.neutral[100]},onClick:()=>no(n||i),children:"Preciso de Ajuda"})})]}):M("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"20vh"},children:M(Ji,{})})]}),c?.open==="gif"&&M(Or,{recurso:c.recurso,onClose:g,onAdquirirRecurso:t,onRemoverRecurso:h}),c?.open==="confirmacaoAdquirir"&&M(Hr,{recurso:c.recurso,onClose:g,onConfirmar:t}),c?.open==="confirmacaoRemover"&&M(_r,{recurso:c.recurso,onClose:g,onRemover:h})]})}import{Button as Ga,Dialog as Pe,LIcon as Vn,Typography as Ln}from"@s_mart/core";import{Form as qn,Select as Bn}from"@s_mart/form";import{lineWhatsApp as $n}from"@s_mart/regular-icons";import{colorPalette as Nn}from"@s_mart/tokens";import{CircularProgress as on}from"@s_mart/core";import{jsx as oa}from"react/jsx-runtime";function ea(){return oa("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"20vh"},children:oa(on,{})})}import{LIcon as pa}from"@s_mart/core";import{lineChevronLeft as un,lineChevronRight as fn}from"@s_mart/regular-icons";import en from"@emotion/styled";import{colorPalette as rn}from"@s_mart/tokens";var $e=en.div`
|
|
86
86
|
display: flex;
|
|
87
87
|
align-items: center;
|
|
88
88
|
border-radius: 4px;
|
|
89
89
|
cursor: pointer;
|
|
90
90
|
|
|
91
91
|
:hover {
|
|
92
|
-
background-color: ${
|
|
92
|
+
background-color: ${rn.neutral[30]};
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
@media (max-width: 450px) {
|
|
@@ -99,9 +99,9 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
99
99
|
background-color: #fff;
|
|
100
100
|
border-radius: 50%;
|
|
101
101
|
|
|
102
|
-
${({side:
|
|
102
|
+
${({side:o})=>`${o}: 0;`}
|
|
103
103
|
}
|
|
104
|
-
`;import{Button as
|
|
104
|
+
`;import{Button as tn,LIcon as ia,Tooltip as nn,Typography as so}from"@s_mart/core";import{colorPalette as We}from"@s_mart/tokens";import{lineStar as sn}from"@s_mart/solid-icons";import{lineCheckCircle as ln,lineWhatsApp as mn}from"@s_mart/regular-icons";import Ne from"@emotion/styled";import{colorPalette as an}from"@s_mart/tokens";var ra=Ne.div`
|
|
105
105
|
display: flex;
|
|
106
106
|
min-width: calc(100% / 3);
|
|
107
107
|
max-width: calc(100% / 3); // Precisa ter o min e max, por algum krl o width não funciona
|
|
@@ -115,7 +115,7 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
115
115
|
min-width: 100%;
|
|
116
116
|
max-width: 100%;
|
|
117
117
|
}
|
|
118
|
-
`,
|
|
118
|
+
`,aa=Ne.div`
|
|
119
119
|
position: relative;
|
|
120
120
|
display: flex;
|
|
121
121
|
flex-direction: column;
|
|
@@ -125,9 +125,9 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
125
125
|
border-radius: 4px;
|
|
126
126
|
padding: 2rem 1.5rem 1.5rem;
|
|
127
127
|
margin: 0.8rem;
|
|
128
|
-
border: ${({destaque:
|
|
129
|
-
background-color: ${({disabled:
|
|
130
|
-
opacity: ${({disabled:
|
|
128
|
+
border: ${({destaque:o,theme:e})=>o?`2px solid ${e.palette.primary.main}`:void 0};
|
|
129
|
+
background-color: ${({disabled:o})=>o?an.neutral[30]:void 0};
|
|
130
|
+
opacity: ${({disabled:o})=>o?.6:void 0};
|
|
131
131
|
|
|
132
132
|
@media (max-width: 1050px) {
|
|
133
133
|
margin: 0.5rem;
|
|
@@ -136,18 +136,18 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
136
136
|
@media (max-width: 400px) {
|
|
137
137
|
padding: 1rem;
|
|
138
138
|
}
|
|
139
|
-
`,
|
|
139
|
+
`,ta=Ne.div`
|
|
140
140
|
display: flex;
|
|
141
141
|
flex-direction: column;
|
|
142
142
|
justify-content: space-between;
|
|
143
143
|
align-items: center;
|
|
144
144
|
min-height: 7rem;
|
|
145
|
-
`;import{Fragment as
|
|
145
|
+
`;import{Fragment as sa,jsx as T,jsxs as ho}from"react/jsx-runtime";function na({plano:o,id:e,reduceFont:r,onContratar:a,periodicidadePlanoAtual:i}){let n=u(g=>g.planosDialog.esconderValorPlanos),l=u(g=>g.planosDialog.habilitarPlanoAtual),m=u(g=>g.telefoneCS),p=u(g=>g.telefoneSuporte),c=o.planoAtual&&!l,C=()=>c?"Seu plano atual":n?"Quero saber mais":l&&o.planoAtual||o.periodicidade!==i?"Contratar plano":o.valorMensalMenorQueAtual?"Diminuir plano":"Aumentar plano";return T(ra,{id:e,children:T(pn,{title:o.disabled30Dias?ho(so,{variant:"bodyXS",children:["A troca para um plano de valor ",T("br",{}),"menor, s\xF3 \xE9 poss\xEDvel ap\xF3s 30 dias ",T("br",{}),"de uso do seu plano atual."]}):"",placement:"right",children:ho(aa,{destaque:!!o.destaque,disabled:c||o.disabled||o.disabled30Dias,children:[!!o.destaque&&T(ia,{icon:sn,color:We.yellow[300],style:{position:"absolute",top:"5px",right:"5px"}}),ho(ta,{children:[T("div",{style:{textAlign:"center"},children:T(so,{variant:r?"titleMS":"titleMD",children:o.nome})}),!!o.fraseDeEfeito&&T("div",{children:T(so,{variant:"bodySM",color:We.neutral[100],children:o.fraseDeEfeito})}),!n&&ho(sa,{children:[!!o.valorPeriodicoPromocional&&T("div",{children:ho(so,{variant:"bodySM",color:We.red[300],style:{textDecorationLine:"line-through",marginRight:"2rem"},children:["R$ ",o.valorPeriodico]})}),ho("div",{style:{display:"flex",justifyContent:"center",alignItems:"end"},children:[T(so,{variant:"titleXXS",alignSelf:"center",children:"R$"}),T(so,{variant:r?"titleLG":"titleXL",style:{fontSize:"3rem"},children:o.valorPeriodicoPromocional||o.valorPeriodico}),ho(so,{variant:r?"titleMS":"titleMD",marginBottom:"0.3rem",children:["/",$(o.periodicidade)]})]})]})]}),T(tn,{fullWidth:!0,variant:c?"neutral":"contained",disabled:c||o.disabled||o.disabled30Dias,startIcon:(c||n)&&T(ia,{icon:c?ln:mn,size:"25px"}),onClick:()=>{n?no(m||p):a(o)},style:{margin:"1.5rem 0"},children:C()}),T("div",{style:{paddingLeft:"1rem"},children:T(so,{variant:"bodySM",children:T("div",{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:o.descricao}})})})]})})})}function pn(o){return o.title?T(nn,{...o}):T(sa,{children:o.children})}import{useMemo as ze}from"react";import{useMediaQuery as Oe}from"@s_mart/hooks";import{useFormContext as cn}from"react-hook-form";import la from"dayjs";var dn=({planos:o})=>{let e=x(f=>f.codigoPlano),r=x(f=>f.periodicidade),a=x(f=>f.valor),i=x(f=>f.dataContratacao),n=x(f=>f.recursos),l=b(f=>f.handleErrors),m=b(f=>f.setLoading),p=u(f=>f.planosDialog.bloquearDowngrade),c=u(f=>f.planosDialog.bloquearDowngrade30Dias),C=u(f=>f.planosDialog.desabilitarPlanosMenores),g=u(f=>f.planosDialog.mostrarSomentePlanosDaPeriodicidade),y=u(f=>f.planosDialog.mostrarPlanosDeterminados?.codigoPlanoValor),{buscarPlano:t}=w(),{watch:h,setValue:d}=cn(),D=Oe("(max-width: 900px)"),R=Oe("(max-width: 700px)"),q=Oe("(max-width: 450px)"),ro=h("filtroPeriodicidade"),wo=!!c&&la().diff(la(i),"days")<30,ao=ze(()=>{let f={previous:0,next:4};return R?f.next=2:D&&(f.next=3),f},[R,D,ro]),K=ze(()=>{let f=[];if(!o)return f;if(y&&!g)f=[...o.mensais,...o.trimestrais,...o.semestrais,...o.anuais].filter(F=>y.includes(F.codigoPlanoValor));else if(ro){let F=g||["mensais","trimestrais","semestrais","anuais"][ro.value];f=o[F]}return f.sort((S,F)=>S.valorPeriodico-F.valorPeriodico),f.map(S=>{let F=S.valorPeriodicoPromocional||S.valorPeriodico,X=ko(F,S.periodicidade)<ko(a??0,r);return{...S,planoAtual:S.codigo===e&&S.periodicidade===r,valorMensalMenorQueAtual:X,disabled:(!!p||!!C)&&X,disabled30Dias:wo&&X}})},[o,ro,y]),Ho=ze(()=>R?K.length>1:D?K.length>2:K.length>3,[R,D,K]);function ko(f,P){switch(P){case 1:return f/3;case 2:return f/6;case 3:return f/12;default:return f}}return{planosFiltrados:K,scrollPlanos:f=>{let P=ao[f];if(P===0||P>K.length)return;let S=document.getElementById(`plano-${P}`);S&&(S.scrollIntoView({behavior:"smooth"}),f==="next"?(ao.next++,ao.previous++):(ao.next--,ao.previous--))},showScrollControllers:Ho,maxWidth700:R,maxWidth450:q,handleClickContratarPlano:async f=>{try{m(!0);let P=await t(f.codigo,f.periodicidade);if(P.data){let S={},F=P.data.recursos?.filter(W=>!W?.valorRecurso)?.map(W=>W?.slugRecurso);n?.filter(W=>W.recursoContratado)?.forEach(W=>{P.data.recursos.some(_o=>_o.slugRecurso===W.slugRecurso)&&!F?.includes(W.slugRecurso)&&(S[W.slugRecurso]=!0)}),d("recursosSelecionados",S),d("planoSelecionado",{...f,recursos:P.data.recursos})}m(!1)}catch(P){l(P)}},periodicidadePlanoAtual:r}},ma=dn;import{jsx as Ro,jsxs as gn}from"react/jsx-runtime";function ca(o){let{planosFiltrados:e,scrollPlanos:r,showScrollControllers:a,maxWidth700:i,maxWidth450:n,handleClickContratarPlano:l,periodicidadePlanoAtual:m}=ma(o);return gn("div",{style:{display:"flex",position:"relative"},children:[a&&Ro($e,{side:"left",onClick:()=>r("previous"),children:Ro(pa,{icon:un,size:i?"2rem":"3rem"})}),Ro("div",{style:{display:"flex",justifyContent:a?void 0:"center",overflow:"hidden",flex:1},children:e.map((p,c)=>Ro(na,{id:`plano-${c+1}`,plano:p,reduceFont:n,periodicidadePlanoAtual:m??0,onContratar:l},p.codigoPlanoValor))}),a&&Ro($e,{side:"right",onClick:()=>r("next"),children:Ro(pa,{icon:fn,size:i?"2rem":"3rem"})})]})}import{Grid as Ke}from"@s_mart/core";import{Grid as yn,Typography as Xe}from"@s_mart/core";import{valor as hn}from"@s_mart/masks";import{Switch as Cn}from"@s_mart/form";import{useFormContext as xn}from"react-hook-form";import{Grid as je}from"@s_mart/core";import He from"@emotion/styled";var da=He(je)`
|
|
146
146
|
display: flex;
|
|
147
147
|
justify-content: end;
|
|
148
148
|
margin-bottom: 1.5rem;
|
|
149
149
|
margin-right: 0.5rem;
|
|
150
|
-
`,
|
|
150
|
+
`,ua=He(je)`
|
|
151
151
|
@media (min-height: 800px) {
|
|
152
152
|
max-height: 50vh;
|
|
153
153
|
overflow-y: auto;
|
|
@@ -156,7 +156,7 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
156
156
|
@media (max-width: 960px) {
|
|
157
157
|
max-height: fit-content;
|
|
158
158
|
}
|
|
159
|
-
`,
|
|
159
|
+
`,fa=He(je)`
|
|
160
160
|
display: flex;
|
|
161
161
|
justify-content: space-between;
|
|
162
162
|
align-items: center;
|
|
@@ -168,7 +168,7 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
168
168
|
@media ((min-height: 800px) or (max-width: 960px)) {
|
|
169
169
|
margin-right: 0.5rem;
|
|
170
170
|
}
|
|
171
|
-
`;import{Fragment as
|
|
171
|
+
`;import{Fragment as bn,jsx as Mo,jsxs as _e}from"react/jsx-runtime";function ga(){let{getValues:o}=xn(),r=o("planoSelecionado.recursos").filter(a=>!!a.valorRecurso);return r.length?_e(yn,{container:!0,children:[Mo(da,{item:!0,xs:12,children:Mo(Xe,{variant:"titleSM",children:"Confira os recursos em seu novo plano"})}),Mo(ua,{item:!0,xs:12,children:r.map(a=>_e(fa,{item:!0,xs:12,children:[_e(Xe,{variant:"titleXS",children:[a.nomeRecurso," (",hn.format(a.valorRecurso),")"]}),Mo(Cn,{name:`recursosSelecionados.${a.slugRecurso}`,label:Mo(Xe,{variant:"titleXXS",children:"Adicionar"})})]},a.codigoRecurso))})]}):Mo(bn,{})}import{useState as En}from"react";import{Button as Tn,Grid as Sa,Typography as Q}from"@s_mart/core";import{valor as Ze}from"@s_mart/masks";import{Button as ha,Dialog as ye,Grid as Ue,Typography as vn}from"@s_mart/core";import{valor as Dn}from"@s_mart/masks";import{useMemo as Ye}from"react";import{useFormContext as Pn}from"react-hook-form";var Sn=()=>{let o=x(y=>y.valor),e=x(y=>y.tipoCobranca),r=x(y=>y.periodicidade),a=x(y=>y.nomePlano),i=x(y=>y.getValorTotalPlano),n=u(y=>y.planosDialog.imagensAlterarPlano),{getValues:l}=Pn(),m=l("planoSelecionado"),p=l("recursosSelecionados"),c=Ye(()=>{let y=[];m?.recursos&&p&&Object.entries(p).forEach(([d,D])=>{if(D){let R=m.recursos.find(q=>q.slugRecurso===d);R&&y.push(R)}});let t=m?.valorPeriodicoPromocional||m?.valorPeriodico||0;return y.reduce((d,D)=>d+D.valorRecurso,t)},[m,p]),C=Ye(()=>m?.periodicidade!==r?{title:"Contratar",buttonLabel:"Confirmar contrata\xE7\xE3o de plano",img:n?.contratar}:c>i()?{title:"Melhorar",buttonLabel:"Confirmar altera\xE7\xE3o de plano",img:n?.melhorar}:{title:"Diminuir",buttonLabel:"Confirmar altera\xE7\xE3o de plano",img:n?.diminuir},[m,r]),g=Ye(()=>{let y=m?.valorPeriodicoPromocional||m?.valorPeriodico;return o&&y&&e&&m.tipoDeCobranca&&e!==m.tipoDeCobranca?{de:e===2?"p\xF3s-pago":"pr\xE9-pago",para:m.tipoDeCobranca===2?"p\xF3s-pago":"pr\xE9-pago"}:null},[o,e,m]);return{valorTotal:c,mudouTipoCobranca:g,dynamicText:C,nomePlanoPlanoAtual:a,planoSelecionado:m}},ya=Sn;import{Fragment as Qe,jsx as j,jsxs as eo}from"react/jsx-runtime";function Ca({onClose:o}){let{mudouTipoCobranca:e,dynamicText:r,valorTotal:a,nomePlanoPlanoAtual:i,planoSelecionado:n}=ya(),{open:l,onCloseDialog:m}=H(o);return eo(ye,{open:l,onClose:m,maxWidth:"xs",fullWidth:!0,closeIcon:!0,disablePortal:!0,children:[eo(ye.Header,{children:[r.title," plano"]}),j(ye.Content,{children:eo(Ue,{container:!0,spacing:2,children:[j(Ue,{item:!0,xs:12,style:{display:"flex"},children:eo(vn,{variant:"bodySM",children:[e?eo(Qe,{children:["Voc\xEA est\xE1 alterando seu plano ",j("strong",{children:i})," para uma nova modalidade:"," ",j("strong",{style:{textTransform:"capitalize"},children:e.para})]}):eo(Qe,{children:["Voc\xEA est\xE1 alterando seu plano para ",j("strong",{children:n?.nome}),". O boleto ser\xE1 enviado por email em at\xE9 2 dias \xFAteis."]}),j("br",{}),j("br",{}),e&&eo(Qe,{children:["A forma de pagamento ser\xE1 alterada de ",e.de," para ",e.para,". O"," ",j("strong",{children:"boleto ser\xE1 enviado por email"})," em at\xE9 2 dias \xFAteis, com data de vencimento de at\xE9 5 dias.",j("br",{})]}),"Ao confirmar sua nova escolha, sua fatura ser\xE1 alterada para"," ",eo("strong",{children:[Dn.format(a)," ",$(n?.periodicidade??0,{modelo:"mensais"})]}),"."]})}),j(Ue,{item:!0,xs:12,style:{display:"flex",alignItems:"center",justifyContent:"center"},children:!!r.img&&j("img",{src:r.img,alt:r.title})})]})}),eo(ye.Footer,{children:[j(ha,{variant:"neutral",onClick:m,children:"Cancelar"}),j(ha,{type:"submit",onClick:m,children:r.buttonLabel})]})]})}import{Grid as xa}from"@s_mart/core";import Je from"@emotion/styled";var ba=Je(xa)`
|
|
172
172
|
width: 90%;
|
|
173
173
|
border-radius: 16px;
|
|
174
174
|
padding: 1.5rem;
|
|
@@ -185,23 +185,23 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
185
185
|
padding: 1rem;
|
|
186
186
|
margin: 0.5rem;
|
|
187
187
|
}
|
|
188
|
-
`,
|
|
188
|
+
`,he=Je(xa)`
|
|
189
189
|
display: flex;
|
|
190
190
|
justify-content: center;
|
|
191
191
|
margin-bottom: 0.5rem;
|
|
192
|
-
`,
|
|
192
|
+
`,Ce=Je.div`
|
|
193
193
|
display: flex;
|
|
194
194
|
justify-content: space-between;
|
|
195
195
|
margin-bottom: 0.3rem;
|
|
196
|
-
`;import{useFormContext as Ve}from"react-hook-form";var ze=()=>{let{watch:a,getValues:e}=Ve(),o=e("planoSelecionado"),i=a("recursosSelecionados"),r=()=>{let s=[];return o.recursos&&(s=o.recursos.filter(c=>!c.valorRecurso)),Object.entries(i||{}).forEach(([c,m])=>{if(m){let q=o.recursos?.find(f=>f.slugRecurso===c);q&&s.push(q)}}),s};return{getValorTotal:s=>{let c=r(),m=s?0:o.valorPeriodicoPromocional||o.valorPeriodico;return c.reduce((f,v)=>f+v.valorRecurso,m)},getRecursos:r,planoSelecionado:o}},R3=ze;import{Fragment as Se,jsx as E,jsxs as s1}from"react/jsx-runtime";function T3(){let[a,e]=Ce(!1),{planoSelecionado:o,getRecursos:i,getValorTotal:r}=R3();return s1(Se,{children:[s1(A3,{container:!0,children:[E(y0,{item:!0,xs:12,style:{marginBottom:"1.5rem"},children:E(X,{variant:"titleMD",align:"center",children:o.nome})}),E(y0,{item:!0,xs:12,children:E(X,{variant:"titleSM",children:"Valor do plano"})}),s1(y0,{item:!0,xs:12,children:[E(X,{variant:"bodyLG",style:{alignSelf:"center"},children:"R$"}),E(X,{variant:"titleXXL",children:Number(r().toFixed(2))}),s1(X,{variant:"bodyLG",style:{alignSelf:"end"},children:["/",F(o.periodicidade)]})]}),E(k3,{item:!0,xs:12,style:{marginBottom:"1rem"},children:E(be,{size:"large",fullWidth:!0,onClick:()=>e(!0),children:"Contratar agora"})}),s1(k3,{item:!0,xs:12,children:[s1(H0,{children:[E(X,{variant:"bodyMD",children:o.nome}),E(X,{variant:"bodyMD",children:e2.format(o.valorPeriodicoPromocional||o.valorPeriodico)})]}),s1(H0,{children:[E(X,{variant:"bodySM",children:"Subtotal recursos"}),E(X,{variant:"bodySM",children:e2.format(r(!0))})]}),i().map(n=>s1(H0,{children:[E(X,{variant:"bodySM",children:n.nomeRecurso}),E(X,{variant:"bodySM",children:e2.format(n.valorRecurso)})]},n.codigoRecurso))]})]}),a&&E(L3,{onClose:()=>e(!1)})]})}import{jsx as V0,jsxs as xe}from"react/jsx-runtime";function E3(){return xe(o2,{container:!0,spacing:2,children:[V0(o2,{item:!0,xs:12,md:7,children:V0(x3,{})}),V0(o2,{item:!0,xs:12,md:5,style:{display:"flex",justifyContent:"center",alignItems:"start"},children:V0(T3,{})})]})}import{Grid as z0,Typography as w3}from"@s_mart/core";import{jsx as Z1,jsxs as Pe}from"react/jsx-runtime";function I3(){let a=h(e=>e.planosDialog.emptyStateImg);return Pe(z0,{container:!0,spacing:2,direction:"column",alignItems:"center",padding:"1rem 0",children:[!!a&&Z1(z0,{item:!0,children:Z1("img",{src:a,alt:"emptyStateImg"})}),Z1(z0,{item:!0,textAlign:"center",children:Z1(w3,{variant:"titleMD",children:"Voc\xEA precisa de um plano especial"})}),Z1(z0,{item:!0,textAlign:"center",children:Z1(w3,{variant:"bodyMD",children:"Para trocar de plano solicite ajuda da nossa equipe no bot\xE3o abaixo."})})]})}import{useEffect as G3,useMemo as B3,useState as Le}from"react";var Ze=()=>{let a=h.getState().axiosInstance,e=a.defaults.baseURL?.includes("staging")?"https://apistaging-controle.sbsistemas.com.br":"https://apicontrole.sbsistemas.com.br";return{fetchPlanosEGrupos:o=>a.get("/contrate/planos-e-grupos",{baseURL:e,params:{grupo:o??"",tipoPlano:window.location.hostname.includes("parceiro")?1:0}})}},F3=Ze;var L1=[{label:"Mensais",value:0},{label:"Trimestrais",value:1},{label:"Semestrais",value:2},{label:"Anuais",value:3}];var De=({onClose:a})=>{let e=M(t=>t.fetchedMeuPlano),o=M(t=>t.fetchMeuPlano),i=M(t=>t.codigoGrupo),r=M(t=>t.periodicidade),n=M(t=>t.getMeuPlanoData),s=h(t=>t.telefoneSuporte),c=h(t=>t.planosDialog.mostrarPlanosDeterminados),m=h(t=>t.planosDialog.esconderPeriodicidade),q=h(t=>t.planosDialog.onContratarSuccess),f=y(t=>t.handleErrors),v=y(t=>t.setLoading),u=y(t=>t.toggleNotification),[l,g]=Le(null),{fetchPlanosEGrupos:d}=F3(),{contratarPlano:C,contratarRecurso:b}=A(),w=!e||!l,o1=B3(()=>{let t={};return e&&typeof r=="number"&&(t.filtroPeriodicidade=L1[r]),t},[r]),k1=B3(()=>{let t=[];return l?.planos&&(l.planos.mensais.length&&t.push(L1[0]),l.planos.trimestrais.length&&t.push(L1[1]),l.planos.semestrais.length&&t.push(L1[2]),l.planos.anuais.length&&t.push(L1[3])),t},[l]),i1=!m&&!c?.codigoPlanoValor&&k1.length>1;G3(()=>{e||o()},[e]),G3(()=>{e&&!l&&K()},[e,l]);let K=async()=>{let t=i;c?.codigoGrupo&&(t=c.codigoGrupo);try{let H={...(await d(t)).data};H.planos&&![...H.planos.mensais,...H.planos.trimestrais,...H.planos.semestrais,...H.planos.anuais].length&&(H.planos=null),g(H)}catch(p){f(p)}},j1=async t=>{try{if(!t.planoSelecionado)throw{error:"Ocorreu um erro inesperado"};v(!0);let p={codigoPlano:t.planoSelecionado.codigo,codigoPlanoValor:t.planoSelecionado.codigoPlanoValor};await C(p);let H=()=>{q?.(n(),t.planoSelecionado),u({title:"Seu plano foi atualizado com sucesso."}),o(),a()},V=Object.entries(t.recursosSelecionados||{});if(V.length){let k=[];V.forEach(([B,Q1])=>{if(Q1){let _1=t.planoSelecionado?.recursos?.find(f4=>f4.slugRecurso===B);_1&&k.push(_1)}});let W=await T1(k);if(W.length){let B=W.map(Q1=>Q1.nomeRecurso);H(),u({title:"Ocorreu um erro ao contratar os seguintes recursos:",message:B.join(" ; "),autoHideDuration:1e4})}else H()}else H();v(!1)}catch(p){f(p)}},T1=t=>{let p=[];return new Promise(H=>{let V=k=>{let W=k.shift();if(!W)return H(p);b(Number(W.codigoRecurso)).catch(()=>p.push(W)).finally(()=>V(k))};V([...t])})};return{telefoneSuporte:s,handleContratarPlano:j1,isLoading:w,mostrarPeriodicidade:i1,filtroPeriodicidadeOptions:k1,initialValues:o1,planosEGrupos:l,getDialogTitle:t=>t?t.periodicidade!==r?"Contratar plano":t.valorMensalMenorQueAtual?"Diminuir plano":"Aumentar plano":"Meus planos"}},O3=De;import{Fragment as we,jsx as G,jsxs as $3}from"react/jsx-runtime";function b0({onClose:a}){let{open:e,onCloseDialog:o}=N(a),{isLoading:i,mostrarPeriodicidade:r,filtroPeriodicidadeOptions:n,handleContratarPlano:s,telefoneSuporte:c,initialValues:m,planosEGrupos:q,getDialogTitle:f}=O3({onClose:o}),v=u=>i?G(h3,{}):q?.planos?u?G(E3,{}):G(z3,{planos:q.planos}):G(I3,{});return G(C0,{open:e,onClose:o,fullWidth:!0,maxWidth:"xl",closeIcon:!0,disableBackdropClick:!0,children:G(ke,{onSubmit:s,defaultValues:m,style:{display:"flex",flexDirection:"column",overflowY:"auto"},children:({watch:u,setValue:l})=>{let g=u("planoSelecionado");return $3(we,{children:[G(C0.Header,{children:$3("div",{style:{display:"flex",flex:1,justifyContent:"space-between"},children:[G(Re,{variant:"titleMD",children:f(g)}),r&&!g&&G(Te,{name:"filtroPeriodicidade",options:n,style:{minWidth:"7rem",marginRight:"0.5rem"}})]})}),G(C0.Content,{children:v(!!g)}),G(C0.Footer,{children:g?G(U3,{variant:"neutral",disableRipple:!0,onClick:()=>{l("planoSelecionado",void 0),l("recursosSelecionados",void 0)},children:"Voltar"}):G(U3,{variant:"outlined",color:"neutral",startIcon:G(Ae,{icon:C1,size:"22px",removeMargin:!0}),style:{color:Ee.neutral[100]},onClick:()=>n1(c),children:"Preciso de Ajuda"})})]})}})})}import{Fragment as Oe,jsx as D,jsxs as m1}from"react/jsx-runtime";function _3(){let{valor:a,recursos:e,nomePlano:o,periodicidade:i,getValorTotalPlano:r,fetchedMeuPlano:n}=M(),s=h(u=>u.meuPlano.esconderPlanos),c=h(u=>u.meuPlano.esconderLojaDeRecursos),[m,q]=Ie(null),f=Be("(max-width: 400px)"),v=e?.filter(u=>u.recursoContratado).sort((u,l)=>u.valorRecurso-l.valorRecurso);return n?m1(Oe,{children:[D(O,{style:{padding:"1.5rem",borderRadius:"8px"},children:m1($1,{container:!0,children:[D($1,{item:!0,xs:12,textAlign:"center",children:D(c1,{variant:"titleSM",children:e?"Valor Total":"Valor do plano"})}),m1($1,{item:!0,xs:12,display:"flex",justifyContent:"center",alignItems:"end",children:[D(c1,{variant:"titleXXS",alignSelf:"center",children:"R$"}),D(c1,{variant:"titleXL",style:{fontSize:"3rem"},children:Ge.format(r())}),m1(c1,{variant:"titleMD",marginBottom:"0.3rem",children:["/",F(i)]})]}),m1($1,{item:!0,xs:12,marginTop:"2rem",children:[m1("div",{style:{display:"flex",justifyContent:"space-between"},children:[D(c1,{variant:"bodySM",children:o?.includes("Plano")?o:`Plano ${o}`}),D(c1,{variant:"titleXS",children:j3.format(a??0)})]}),!!v?.length&&v.map(u=>m1("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.2rem"},children:[D(c1,{variant:"bodySM",color:Q3.neutral[100],children:u.nomeRecurso}),D(c1,{variant:"titleXS",color:Q3.neutral[100],children:j3.format(u.valorRecurso??0)})]},u.codigoRecurso))]}),m1($1,{item:!0,xs:12,display:"flex",flexDirection:f?"column":"row",justifyContent:"space-between",gap:"0.5rem",marginTop:"2rem",children:[!s&&D(N3,{startIcon:D(W3,{icon:V1,removeMargin:!0}),fullWidth:f||c,onClick:()=>q("planos"),children:"Ver planos"}),!c&&D(N3,{variant:"outlined",disabled:!e,startIcon:D(W3,{icon:f2,removeMargin:!0}),fullWidth:f||s,onClick:()=>q("recursos"),children:"Loja de recursos"})]})]})}),m==="recursos"&&D(f0,{onClose:()=>q(null)}),m==="planos"&&D(b0,{onClose:()=>q(null)})]}):D(O,{centerContent:!0,height:"60vh",children:D(Fe,{})})}import{Chip as _e,CircularProgress as Xe,Grid as x0,LIcon as Ye,Typography as A1}from"@s_mart/core";import{DataTable as Je,List as a4}from"@s_mart/data";import{useMediaQuery as Ke}from"@s_mart/hooks";import{colorPalette as N1}from"@s_mart/tokens";import{valor as ao}from"@s_mart/masks";import eo from"dayjs";import{Grid as S0,Typography as X3}from"@s_mart/core";import{jsx as g1,jsxs as Ue}from"react/jsx-runtime";function Y3(){let a=h(e=>e.meuPlano.faturasEmptyStateImg);return g1(O,{children:Ue(S0,{container:!0,spacing:2,flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:"25rem",children:[!!a&&g1(S0,{item:!0,children:g1("img",{src:a})}),g1(S0,{item:!0,textAlign:"center",children:g1(X3,{variant:"titleMD",children:"Nenhuma fatura para mostrar"})}),g1(S0,{item:!0,children:g1(X3,{variant:"bodyMD",children:"Voc\xEA n\xE3o possui faturas."})})]})})}import{useMemo as J3}from"react";import{Chip as $e,LIcon as Ne,Tooltip as We,Typography as i2}from"@s_mart/core";import{valor as je}from"@s_mart/masks";import{colorPalette as D1}from"@s_mart/tokens";import{downloadFile as l2}from"@s_mart/utils";import q1 from"dayjs";import{jsx as f1}from"react/jsx-runtime";var Qe=()=>{let a=M(l=>l.cobrancas),e=M(l=>l.fetchedCobrancas),o=z(l=>l.email),i=y(l=>l.handleErrors),r=y(l=>l.setLoading),{fetchBoleto:n,fetchNfse:s}=A(),c=J3(()=>{let l=null;return e?a.length||(l="empty"):l="loading",l},[e,a]),m=l=>{switch(l.situacao){case"EMITIDO":{let g=q1().startOf("day"),d=q1(l.dataVencimento?.replace("Z","")).startOf("day");return g.isAfter(d)&&(q1(d).day()===6?d=d.add(2,"d"):q1(d).day()===0&&(d=d.add(1,"d"))),g.isAfter(d)?{label:"Vencida",color:D1.red[100]}:{label:"A pagar",color:D1.neutral[30]}}case"LIQUIDADO":return{label:"Paga",color:D1.green[100]};case"ISENTADO":return{label:"Isenta",color:D1.neutral[50]};default:return{label:"",color:D1.neutral[0]}}},q=l=>{switch(l.situacao){case"EMITIDO":return{label:"Baixar boleto",onClick:()=>f(l)};case"LIQUIDADO":return{label:"Baixar nota",onClick:()=>v(l)}}},f=async l=>{try{r(!0);let g=await n(l.identificador);g.data.boleto&&l2(g.data.boleto,`Boleto_${q1(l.dataEmissao).format("YYYY[_]MM")}.pdf`,"application/pdf")}catch(g){i(g)}finally{r(!1)}},v=async l=>{try{r(!0);let g=await s(l.identificador);g.data&&(g.data.xml&&l2(g.data.xml,`Nota_XML_${q1(l.dataEmissao).format("YYYY[_]MM")}.xml`,"text/xml"),g.data.danfse?l2(g.data.danfse,`Nota_PDF_${q1(l.dataEmissao).format("YYYY[_]MM")}.pdf`,"application/pdf"):g.data.link_impressao_danfse&&window.open(g.data.link_impressao_danfse,"_blank","noopener=yes,noreferrer=yes"))}catch(g){i(g)}finally{r(!1)}},u=J3(()=>[{field:"dataVencimento",headerName:"Vencimento",flex:2,minWidth:100,valueFormatter:({value:l})=>q1(l).format("DD/MM/YYYY")},{field:"situacao",headerName:"Situa\xE7\xE3o",flex:5,minWidth:115,valueGetter:l=>m(l.row),renderCell:({value:l})=>f1($e,{label:l.label,style:{backgroundColor:l.color,minWidth:"6.5rem"}})},{field:"descricao",headerName:"Ref",renderCell:({value:l})=>f1(We,{title:f1(i2,{variant:"bodySM",children:l}),children:f1("div",{children:f1(Ne,{icon:u2,color:D1.neutral[100]})})}),flex:1},{field:"valor",headerName:"Valor",flex:1,minWidth:100,renderCell:({formattedValue:l})=>f1(i2,{variant:"titleXS",children:l}),valueFormatter:({value:l})=>je.format(l)},{field:"acao",headerName:"A\xE7\xF5es",flex:1.5,minWidth:110,renderCell:({value:l})=>!!l&&f1(i2,{variant:"bodySM",style:{textDecorationLine:"underline",cursor:"pointer"},onClick:l.onClick,children:l.label}),valueGetter:l=>q(l.row)}],[]);return{faturasList:a,tableStatus:c,tableColumns:u,fetchedCobrancas:e,empresaEmail:o,getActions:q,getSituacao:m}},K3=Qe;import{jsx as L,jsxs as M1}from"react/jsx-runtime";function e4(){let{faturasList:a,tableStatus:e,tableColumns:o,fetchedCobrancas:i,empresaEmail:r,getActions:n,getSituacao:s}=K3(),c=Ke("(max-width: 700px)");return i?e==="empty"?L(Y3,{}):L(O,{style:{borderRadius:"8px",padding:c?0:"1rem",boxShadow:c?"none":void 0},children:M1(x0,{container:!0,children:[M1(x0,{item:!0,xs:12,display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",paddingBottom:"0.5rem",children:[M1("div",{style:{display:"flex",alignItems:"center"},children:[L(Ye,{icon:$2,size:"25px"}),L(A1,{variant:"titleSM",children:"Gerenciamento de faturas"})]}),M1(A1,{variant:"bodySM",marginY:c?"0.5rem":void 0,children:["Boletos enviados para: ",c&&L("br",{})," ",L("strong",{children:r})]})]}),c?L(x0,{item:!0,xs:12,children:L(a4.Root,{data:a,isLoading:e==="loading",children:a.map((m,q)=>{let f=s(m),v=n(m),u=f.label==="Vencida";return M1(a4.ListItem,{index:q,style:{width:"calc(100% + 2rem)",marginLeft:"-1rem",padding:"1.5rem 1rem",backgroundColor:u?"#FFE3E3":void 0},children:[M1("div",{style:{display:"flex",justifyContent:"space-between"},children:[L(_e,{label:f.label,size:"small",style:{backgroundColor:f.color,minWidth:"6.5rem"}}),L(A1,{variant:"bodySM",color:u?N1.red[300]:void 0,children:eo(m.dataVencimento).format("DD/MM/YYYY")})]}),L("div",{style:{margin:"0.75rem 0"},children:L(A1,{variant:"bodyXS",color:u?N1.neutral[500]:N1.neutral[100],children:m.descricao})}),M1("div",{style:{display:"flex",justifyContent:"space-between"},children:[L(A1,{variant:"titleXS",color:u?N1.red[300]:void 0,children:ao.format(m.valor)}),!!v&&L(A1,{variant:"bodySM",color:u?N1.red[300]:void 0,fontWeight:u?700:void 0,style:{textDecorationLine:"underline",cursor:"pointer"},onClick:v.onClick,children:v.label})]})]},m.identificador||m.dataVencimento)})})}):L(x0,{item:!0,xs:12,sx:{overflow:"auto",maxHeight:"65vh","@media(max-height: 750px)":{maxHeight:"60vh"}},children:L(Je,{rows:a,loading:e==="loading",columns:o,getRowId:m=>m.identificador||m.dataVencimento,disableRowSelectionOnClick:!0})})]})}):L(O,{centerContent:!0,height:"60vh",children:L(Xe,{})})}import{Grid as oo,LIcon as io,Typography as lo}from"@s_mart/core";import{colorPalette as ro}from"@s_mart/tokens";import{jsx as r2,jsxs as no}from"react/jsx-runtime";function o4({link:a}){return r2(oo,{item:!0,display:"flex",marginTop:"1.5rem",children:no("a",{href:a,rel:"noopener noreferrer",target:"_blank",style:{display:"flex",alignItems:"center",color:ro.neutral[100]},children:[r2(lo,{variant:"bodySM",children:"Termos de uso"}),r2(io,{icon:v2})]})})}import to from"@emotion/styled";import{Grid as so}from"@s_mart/core";var i4=to(so)`
|
|
196
|
+
`;import{useFormContext as Rn}from"react-hook-form";var Mn=()=>{let{watch:o,getValues:e}=Rn(),r=e("planoSelecionado"),a=o("recursosSelecionados"),i=()=>{let l=[];return r.recursos&&(l=r.recursos.filter(m=>!m.valorRecurso)),Object.entries(a||{}).forEach(([m,p])=>{if(p){let c=r.recursos?.find(C=>C.slugRecurso===m);c&&l.push(c)}}),l};return{getValorTotal:l=>{let m=i(),p=l?0:r.valorPeriodicoPromocional||r.valorPeriodico;return m.reduce((C,g)=>C+g.valorRecurso,p)},getRecursos:i,planoSelecionado:r}},Pa=Mn;import{Fragment as An,jsx as L,jsxs as lo}from"react/jsx-runtime";function va(){let[o,e]=En(!1),{planoSelecionado:r,getRecursos:a,getValorTotal:i}=Pa();return lo(An,{children:[lo(ba,{container:!0,children:[L(he,{item:!0,xs:12,style:{marginBottom:"1.5rem"},children:L(Q,{variant:"titleMD",align:"center",children:r.nome})}),L(he,{item:!0,xs:12,children:L(Q,{variant:"titleSM",children:"Valor do plano"})}),lo(he,{item:!0,xs:12,children:[L(Q,{variant:"bodyLG",style:{alignSelf:"center"},children:"R$"}),L(Q,{variant:"titleXXL",children:Number(i().toFixed(2))}),lo(Q,{variant:"bodyLG",style:{alignSelf:"end"},children:["/",$(r.periodicidade)]})]}),L(Sa,{item:!0,xs:12,style:{marginBottom:"1rem"},children:L(Tn,{size:"large",fullWidth:!0,onClick:()=>e(!0),children:"Contratar agora"})}),lo(Sa,{item:!0,xs:12,children:[lo(Ce,{children:[L(Q,{variant:"bodyMD",children:r.nome}),L(Q,{variant:"bodyMD",children:Ze.format(r.valorPeriodicoPromocional||r.valorPeriodico)})]}),lo(Ce,{children:[L(Q,{variant:"bodySM",children:"Subtotal recursos"}),L(Q,{variant:"bodySM",children:Ze.format(i(!0))})]}),a().map(n=>lo(Ce,{children:[L(Q,{variant:"bodySM",children:n.nomeRecurso}),L(Q,{variant:"bodySM",children:Ze.format(n.valorRecurso)})]},n.codigoRecurso))]})]}),o&&L(Ca,{onClose:()=>e(!1)})]})}import{jsx as xe,jsxs as In}from"react/jsx-runtime";function Da(){return In(Ke,{container:!0,spacing:2,children:[xe(Ke,{item:!0,xs:12,md:7,children:xe(ga,{})}),xe(Ke,{item:!0,xs:12,md:5,style:{display:"flex",justifyContent:"center",alignItems:"start"},children:xe(va,{})})]})}import{Grid as be,Typography as Ra}from"@s_mart/core";import{jsx as Eo,jsxs as Gn}from"react/jsx-runtime";function Ma(){let o=u(e=>e.planosDialog.emptyStateImg);return Gn(be,{container:!0,spacing:2,direction:"column",alignItems:"center",padding:"1rem 0",children:[!!o&&Eo(be,{item:!0,children:Eo("img",{src:o,alt:"emptyStateImg"})}),Eo(be,{item:!0,textAlign:"center",children:Eo(Ra,{variant:"titleMD",children:"Voc\xEA precisa de um plano especial"})}),Eo(be,{item:!0,textAlign:"center",children:Eo(Ra,{variant:"bodyMD",children:"Para trocar de plano solicite ajuda da nossa equipe no bot\xE3o abaixo."})})]})}import{useEffect as Ta,useMemo as Aa,useState as kn}from"react";var wn=()=>{let o=u.getState().axiosInstance,e=o.defaults.baseURL?.includes("staging")?"https://apistaging-controle.sbsistemas.com.br":"https://apicontrole.sbsistemas.com.br";return{fetchPlanosEGrupos:r=>o.get("/contrate/planos-e-grupos",{baseURL:e,params:{grupo:r??"",tipoPlano:window.location.hostname.includes("parceiro")?1:0}})}},Ea=wn;var To=[{label:"Mensais",value:0},{label:"Trimestrais",value:1},{label:"Semestrais",value:2},{label:"Anuais",value:3}];var Fn=({onClose:o})=>{let e=x(s=>s.fetchedMeuPlano),r=x(s=>s.fetchMeuPlano),a=x(s=>s.codigoGrupo),i=x(s=>s.periodicidade),n=x(s=>s.getMeuPlanoData),l=u(s=>s.telefoneSuporte),m=u(s=>s.planosDialog.mostrarPlanosDeterminados),p=u(s=>s.planosDialog.esconderPeriodicidade),c=u(s=>s.planosDialog.onContratarSuccess),C=b(s=>s.handleErrors),g=b(s=>s.setLoading),y=b(s=>s.toggleNotification),[t,h]=kn(null),{fetchPlanosEGrupos:d}=Ea(),{contratarPlano:D,contratarRecurso:R}=w(),q=!e||!t,ro=Aa(()=>{let s={};return e&&typeof i=="number"&&(s.filtroPeriodicidade=To[i]),s},[i]),wo=Aa(()=>{let s=[];return t?.planos&&(t.planos.mensais.length&&s.push(To[0]),t.planos.trimestrais.length&&s.push(To[1]),t.planos.semestrais.length&&s.push(To[2]),t.planos.anuais.length&&s.push(To[3])),s},[t]),ao=!p&&!m?.codigoPlanoValor&&wo.length>1;Ta(()=>{e||r()},[e]),Ta(()=>{e&&!t&&K()},[e,t]);let K=async()=>{let s=a;m?.codigoGrupo&&(s=m.codigoGrupo);try{let P={...(await d(s)).data};P.planos&&![...P.planos.mensais,...P.planos.trimestrais,...P.planos.semestrais,...P.planos.anuais].length&&(P.planos=null),h(P)}catch(f){C(f)}},Ho=async s=>{try{if(!s.planoSelecionado)throw{error:"Ocorreu um erro inesperado"};g(!0);let f={codigoPlano:s.planoSelecionado.codigo,codigoPlanoValor:s.planoSelecionado.codigoPlanoValor};await D(f);let P=()=>{c?.(n(),s.planoSelecionado),y({title:"Seu plano foi atualizado com sucesso."}),r(),o()},S=Object.entries(s.recursosSelecionados||{});if(S.length){let F=[];S.forEach(([W,Xo])=>{if(Xo){let _o=s.planoSelecionado?.recursos?.find(nt=>nt.slugRecurso===W);_o&&F.push(_o)}});let X=await ko(F);if(X.length){let W=X.map(Xo=>Xo.nomeRecurso);P(),y({title:"Ocorreu um erro ao contratar os seguintes recursos:",message:W.join(" ; "),autoHideDuration:1e4})}else P()}else P();g(!1)}catch(f){C(f)}},ko=s=>{let f=[];return new Promise(P=>{let S=F=>{let X=F.shift();if(!X)return P(f);R(Number(X.codigoRecurso)).catch(()=>f.push(X)).finally(()=>S(F))};S([...s])})};return{telefoneSuporte:l,handleContratarPlano:Ho,isLoading:q,mostrarPeriodicidade:ao,filtroPeriodicidadeOptions:wo,initialValues:ro,planosEGrupos:t,getDialogTitle:s=>s?s.periodicidade!==i?"Contratar plano":s.valorMensalMenorQueAtual?"Diminuir plano":"Aumentar plano":"Meus planos"}},Ia=Fn;import{Fragment as Wn,jsx as N,jsxs as wa}from"react/jsx-runtime";function Se({onClose:o}){let{open:e,onCloseDialog:r}=H(o),{isLoading:a,mostrarPeriodicidade:i,filtroPeriodicidadeOptions:n,handleContratarPlano:l,telefoneSuporte:m,initialValues:p,planosEGrupos:c,getDialogTitle:C}=Ia({onClose:r}),g=y=>a?N(ea,{}):c?.planos?y?N(Da,{}):N(ca,{planos:c.planos}):N(Ma,{});return N(Pe,{open:e,onClose:r,fullWidth:!0,maxWidth:"xl",closeIcon:!0,disableBackdropClick:!0,children:N(qn,{onSubmit:l,defaultValues:p,style:{display:"flex",flexDirection:"column",overflowY:"auto"},children:({watch:y,setValue:t})=>{let h=y("planoSelecionado");return wa(Wn,{children:[N(Pe.Header,{children:wa("div",{style:{display:"flex",flex:1,justifyContent:"space-between"},children:[N(Ln,{variant:"titleMD",children:C(h)}),i&&!h&&N(Bn,{name:"filtroPeriodicidade",options:n,style:{minWidth:"7rem",marginRight:"0.5rem"}})]})}),N(Pe.Content,{children:g(!!h)}),N(Pe.Footer,{children:h?N(Ga,{variant:"neutral",disableRipple:!0,onClick:()=>{t("planoSelecionado",void 0),t("recursosSelecionados",void 0)},children:"Voltar"}):N(Ga,{variant:"outlined",color:"neutral",startIcon:N(Vn,{icon:$n,size:"22px",removeMargin:!0}),style:{color:Nn.neutral[100]},onClick:()=>no(m),children:"Preciso de Ajuda"})})]})}})})}import{Fragment as Yn,jsx as G,jsxs as po}from"react/jsx-runtime";function qa(){let{valor:o,recursos:e,nomePlano:r,periodicidade:a,getValorTotalPlano:i,fetchedMeuPlano:n}=x(),l=u(y=>y.meuPlano.esconderPlanos),m=u(y=>y.meuPlano.esconderLojaDeRecursos),[p,c]=zn(null),C=_n("(max-width: 400px)"),g=e?.filter(y=>y.recursoContratado).sort((y,t)=>y.valorRecurso-t.valorRecurso);return n?po(Yn,{children:[G(z,{style:{padding:"1.5rem",borderRadius:"8px"},children:po(zo,{container:!0,children:[G(zo,{item:!0,xs:12,textAlign:"center",children:G(mo,{variant:"titleSM",children:e?"Valor Total":"Valor do plano"})}),po(zo,{item:!0,xs:12,display:"flex",justifyContent:"center",alignItems:"end",children:[G(mo,{variant:"titleXXS",alignSelf:"center",children:"R$"}),G(mo,{variant:"titleXL",style:{fontSize:"3rem"},children:jn.format(i())}),po(mo,{variant:"titleMD",marginBottom:"0.3rem",children:["/",$(a)]})]}),po(zo,{item:!0,xs:12,marginTop:"2rem",children:[po("div",{style:{display:"flex",justifyContent:"space-between"},children:[G(mo,{variant:"bodySM",children:r?.includes("Plano")?r:`Plano ${r}`}),G(mo,{variant:"titleXS",children:Va.format(o??0)})]}),!!g?.length&&g.map(y=>po("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.2rem"},children:[G(mo,{variant:"bodySM",color:La.neutral[100],children:y.nomeRecurso}),G(mo,{variant:"titleXS",color:La.neutral[100],children:Va.format(y.valorRecurso??0)})]},y.codigoRecurso))]}),po(zo,{item:!0,xs:12,display:"flex",flexDirection:C?"column":"row",justifyContent:"space-between",gap:"0.5rem",marginTop:"2rem",children:[!l&&G(ka,{startIcon:G(Fa,{icon:Xn,removeMargin:!0}),fullWidth:C||m,onClick:()=>c("planos"),children:"Ver planos"}),!m&&G(ka,{variant:"outlined",disabled:!e,startIcon:G(Fa,{icon:Hn,removeMargin:!0}),fullWidth:C||l,onClick:()=>c("recursos"),children:"Loja de recursos"})]})]})}),p==="recursos"&&G(ge,{onClose:()=>c(null)}),p==="planos"&&G(Se,{onClose:()=>c(null)})]}):G(z,{centerContent:!0,height:"60vh",children:G(On,{})})}import{Chip as rs,CircularProgress as as,Grid as De,LIcon as ts,Typography as Io}from"@s_mart/core";import{DataTable as is,List as za}from"@s_mart/data";import{lineReceipt as ns}from"@s_mart/regular-icons";import{useMediaQuery as ss}from"@s_mart/hooks";import{colorPalette as Oo}from"@s_mart/tokens";import{valor as ls}from"@s_mart/masks";import ms from"dayjs";import{Grid as ve,Typography as Ba}from"@s_mart/core";import{jsx as Co,jsxs as Un}from"react/jsx-runtime";function $a(){let o=u(e=>e.meuPlano.faturasEmptyStateImg);return Co(z,{children:Un(ve,{container:!0,spacing:2,flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:"25rem",children:[!!o&&Co(ve,{item:!0,children:Co("img",{src:o})}),Co(ve,{item:!0,textAlign:"center",children:Co(Ba,{variant:"titleMD",children:"Nenhuma fatura para mostrar"})}),Co(ve,{item:!0,children:Co(Ba,{variant:"bodyMD",children:"Voc\xEA n\xE3o possui faturas."})})]})})}import{useMemo as Na}from"react";import{Chip as Qn,LIcon as Jn,Tooltip as Zn,Typography as or}from"@s_mart/core";import{lineInfoCircle as Kn}from"@s_mart/solid-icons";import{valor as os}from"@s_mart/masks";import{colorPalette as Ao}from"@s_mart/tokens";import{downloadFile as er}from"@s_mart/utils";import co from"dayjs";import{jsx as xo}from"react/jsx-runtime";var es=()=>{let o=x(t=>t.cobrancas),e=x(t=>t.fetchedCobrancas),r=v(t=>t.email),a=b(t=>t.handleErrors),i=b(t=>t.setLoading),{fetchBoleto:n,fetchNfse:l}=w(),m=Na(()=>{let t=null;return e?o.length||(t="empty"):t="loading",t},[e,o]),p=t=>{switch(t.situacao){case"EMITIDO":{let h=co().startOf("day"),d=co(t.dataVencimento?.replace("Z","")).startOf("day");return h.isAfter(d)&&(co(d).day()===6?d=d.add(2,"d"):co(d).day()===0&&(d=d.add(1,"d"))),h.isAfter(d)?{label:"Vencida",color:Ao.red[100]}:{label:"A pagar",color:Ao.neutral[30]}}case"LIQUIDADO":return{label:"Paga",color:Ao.green[100]};case"ISENTADO":return{label:"Isenta",color:Ao.neutral[50]};default:return{label:"",color:Ao.neutral[0]}}},c=t=>{switch(t.situacao){case"EMITIDO":return{label:"Baixar boleto",onClick:()=>C(t)};case"LIQUIDADO":return{label:"Baixar nota",onClick:()=>g(t)}}},C=async t=>{try{i(!0);let h=await n(t.identificador);h.data.boleto&&er(h.data.boleto,`Boleto_${co(t.dataEmissao).format("YYYY[_]MM")}.pdf`,"application/pdf")}catch(h){a(h)}finally{i(!1)}},g=async t=>{try{i(!0);let h=await l(t.identificador);h.data&&(h.data.xml&&er(h.data.xml,`Nota_XML_${co(t.dataEmissao).format("YYYY[_]MM")}.xml`,"text/xml"),h.data.danfse?er(h.data.danfse,`Nota_PDF_${co(t.dataEmissao).format("YYYY[_]MM")}.pdf`,"application/pdf"):h.data.link_impressao_danfse&&window.open(h.data.link_impressao_danfse,"_blank","noopener=yes,noreferrer=yes"))}catch(h){a(h)}finally{i(!1)}},y=Na(()=>[{field:"dataVencimento",headerName:"Vencimento",flex:2,minWidth:100,valueFormatter:({value:t})=>co(t).format("DD/MM/YYYY")},{field:"situacao",headerName:"Situa\xE7\xE3o",flex:5,minWidth:115,valueGetter:t=>p(t.row),renderCell:({value:t})=>xo(Qn,{label:t.label,style:{backgroundColor:t.color,minWidth:"6.5rem"}})},{field:"descricao",headerName:"Ref",renderCell:({value:t})=>xo(Zn,{title:xo(or,{variant:"bodySM",children:t}),children:xo("div",{children:xo(Jn,{icon:Kn,color:Ao.neutral[100]})})}),flex:1},{field:"valor",headerName:"Valor",flex:1,minWidth:100,renderCell:({formattedValue:t})=>xo(or,{variant:"titleXS",children:t}),valueFormatter:({value:t})=>os.format(t)},{field:"acao",headerName:"A\xE7\xF5es",flex:1.5,minWidth:110,renderCell:({value:t})=>!!t&&xo(or,{variant:"bodySM",style:{textDecorationLine:"underline",cursor:"pointer"},onClick:t.onClick,children:t.label}),valueGetter:t=>c(t.row)}],[]);return{faturasList:o,tableStatus:m,tableColumns:y,fetchedCobrancas:e,empresaEmail:r,getActions:c,getSituacao:p}},Wa=es;import{jsx as I,jsxs as bo}from"react/jsx-runtime";function Oa(){let{faturasList:o,tableStatus:e,tableColumns:r,fetchedCobrancas:a,empresaEmail:i,getActions:n,getSituacao:l}=Wa(),m=ss("(max-width: 700px)");return a?e==="empty"?I($a,{}):I(z,{style:{borderRadius:"8px",padding:m?0:"1rem",boxShadow:m?"none":void 0},children:bo(De,{container:!0,children:[bo(De,{item:!0,xs:12,display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",paddingBottom:"0.5rem",children:[bo("div",{style:{display:"flex",alignItems:"center"},children:[I(ts,{icon:ns,size:"25px"}),I(Io,{variant:"titleSM",children:"Gerenciamento de faturas"})]}),bo(Io,{variant:"bodySM",marginY:m?"0.5rem":void 0,children:["Boletos enviados para: ",m&&I("br",{})," ",I("strong",{children:i})]})]}),m?I(De,{item:!0,xs:12,children:I(za.Root,{data:o,isLoading:e==="loading",children:o.map((p,c)=>{let C=l(p),g=n(p),y=C.label==="Vencida";return bo(za.ListItem,{index:c,style:{width:"calc(100% + 2rem)",marginLeft:"-1rem",padding:"1.5rem 1rem",backgroundColor:y?"#FFE3E3":void 0},children:[bo("div",{style:{display:"flex",justifyContent:"space-between"},children:[I(rs,{label:C.label,size:"small",style:{backgroundColor:C.color,minWidth:"6.5rem"}}),I(Io,{variant:"bodySM",color:y?Oo.red[300]:void 0,children:ms(p.dataVencimento).format("DD/MM/YYYY")})]}),I("div",{style:{margin:"0.75rem 0"},children:I(Io,{variant:"bodyXS",color:y?Oo.neutral[500]:Oo.neutral[100],children:p.descricao})}),bo("div",{style:{display:"flex",justifyContent:"space-between"},children:[I(Io,{variant:"titleXS",color:y?Oo.red[300]:void 0,children:ls.format(p.valor)}),!!g&&I(Io,{variant:"bodySM",color:y?Oo.red[300]:void 0,fontWeight:y?700:void 0,style:{textDecorationLine:"underline",cursor:"pointer"},onClick:g.onClick,children:g.label})]})]},p.identificador||p.dataVencimento)})})}):I(De,{item:!0,xs:12,sx:{overflow:"auto",maxHeight:"65vh","@media(max-height: 750px)":{maxHeight:"60vh"}},children:I(is,{rows:o,loading:e==="loading",columns:r,getRowId:p=>p.identificador||p.dataVencimento,disableRowSelectionOnClick:!0})})]})}):I(z,{centerContent:!0,height:"60vh",children:I(as,{})})}import{Grid as ps,LIcon as cs,Typography as ds}from"@s_mart/core";import{lineExternalLink as us}from"@s_mart/solid-icons";import{colorPalette as fs}from"@s_mart/tokens";import{jsx as rr,jsxs as gs}from"react/jsx-runtime";function ja({link:o}){return rr(ps,{item:!0,display:"flex",marginTop:"1.5rem",children:gs("a",{href:o,rel:"noopener noreferrer",target:"_blank",style:{display:"flex",alignItems:"center",color:fs.neutral[100]},children:[rr(ds,{variant:"bodySM",children:"Termos de uso"}),rr(cs,{icon:us})]})})}import ys from"@emotion/styled";import{Grid as hs}from"@s_mart/core";var Ha=ys(hs)`
|
|
197
197
|
@media (min-width: 600px) {
|
|
198
198
|
max-width: 24rem;
|
|
199
199
|
}
|
|
200
|
-
`;import{useEffect as
|
|
200
|
+
`;import{useEffect as Re}from"react";var Cs=()=>{let o=x(c=>c.fetchedMeuPlano),e=x(c=>c.fetchedCobrancas),r=x(c=>c.fetchMeuPlano),a=x(c=>c.fetchCobrancas),i=v(c=>c.fetched),n=v(c=>c.fetchMinhaEmpresa),l=u(c=>c.meuPlano.linkTermosDeUso),m=u(c=>c.meuPlano.onRenderTabMeuPlano),p=u(c=>c.meuPlano.esconderInformacoesPlano);return Re(()=>{o||r()},[o]),Re(()=>{e||a()},[e]),Re(()=>{i||n()},[i]),Re(()=>{m?.()},[]),{linkTermosDeUso:l,esconderInformacoesPlano:p}},Xa=Cs;import{jsx as jo,jsxs as Ya}from"react/jsx-runtime";function Ps(){let{linkTermosDeUso:o,esconderInformacoesPlano:e}=Xa(),r=bs("(max-width: 600px)");return jo(z,{style:{borderRadius:r?0:"0px 16px 16px 16px"},children:Ya(_a,{container:!0,spacing:4,children:[!e&&Ya(Ha,{item:!0,xs:12,sm:7,md:5,lg:4,xl:3,children:[jo(qa,{}),!!o&&jo(ja,{link:o})]}),jo(_a,{item:!0,xs:12,md:7,lg:8,xl:6,children:jo(Oa,{})})]})})}var Ua=xs(Ps);var vs={minhaEmpresa:wr,meuPlano:Ua},Ds=()=>{let o=u(l=>l.tabAtiva),e=u(l=>l.setTabAtiva),r=u(l=>l.esconderTabMeuPlano),a=Ss("(max-width:600px)"),i=Qa(()=>{let l=[{label:"Minha empresa",value:"minhaEmpresa"},{label:"Meu plano",value:"meuPlano"}];return r&&(l=l.filter(m=>m.value!=="meuPlano")),l},[r]),n=Qa(()=>vs[o||"minhaEmpresa"],[o]);return{tabs:i,tabAtiva:o,setTabAtiva:e,TabComponent:n,fullWidthTabs:a}},Ja=Ds;import{jsx as Go,jsxs as As}from"react/jsx-runtime";function Es(){let{tabs:o,tabAtiva:e,setTabAtiva:r,TabComponent:a,fullWidthTabs:i}=Ja();return As(ar,{container:!0,children:[Go(ar,{item:!0,xs:12,sm:"auto",children:Go(Ms,{variant:i?"fullWidth":"standard",items:o,value:e,onChange:(n,l)=>r(l)})}),Go(ar,{item:!0,xs:12,children:Rs(Go(a,{}))})]})}function Ts(o){return Go(So,{...o,children:Go(Es,{})})}import{Button as ws,Typography as ks}from"@s_mart/core";import Za from"@emotion/styled";import{Grid as Ka}from"@s_mart/core";var ot=Za(Ka)`
|
|
201
201
|
height: 100vh;
|
|
202
202
|
|
|
203
|
-
background: ${({theme:
|
|
204
|
-
`,
|
|
203
|
+
background: ${({theme:o})=>o?.palette?.primary?.main};
|
|
204
|
+
`,et=Za(Ka)`
|
|
205
205
|
display: flex;
|
|
206
206
|
flex-direction: column;
|
|
207
207
|
align-items: center;
|
|
@@ -210,4 +210,4 @@ import{cloneElement as go}from"react";import{Grid as n2,Tab as fo}from"@s_mart/c
|
|
|
210
210
|
background-color: #ffffff;
|
|
211
211
|
padding: 32px;
|
|
212
212
|
border-radius: 8px;
|
|
213
|
-
`;import{useEffect as
|
|
213
|
+
`;import{useEffect as Is}from"react";var Gs=(o,e)=>{let r=b(m=>m.handleErrors);Yo();let{confirmarEmailEmpresa:a,confirmarEmailResponsavel:i}=w(),n=new URLSearchParams(window.location.search).get("token");Is(()=>{l()},[n]);let l=async()=>{try{n&&(e==="empresa"?await a(o,n):e==="respons\xE1vel"&&await i(o,n))}catch(m){r(m?.response?.data||m)}}},rt=Gs;import{jsx as Po,jsxs as at}from"react/jsx-runtime";function Fs({apiUrl:o,imagem:e,onSubmit:r,tipo:a}){return rt(o,a),Po(ot,{container:!0,justifyContent:"center",alignItems:"center",children:at(et,{item:!0,sm:5,md:4,lg:3,children:[Po("div",{children:Po("img",{src:e,alt:"E-mail confirmado",style:{width:"150px"}})}),Po("div",{style:{display:"flex"},children:at(ks,{variant:"bodyXL",align:"center",children:["E-mail ",a=="empresa"?"da":"do"," ",a,Po("br",{}),"alterado com sucesso!"]})}),Po("div",{children:Po(ws,{size:"large",onClick:r,children:"Continuar para o sistema"})})]})})}import{jsx as tt}from"react/jsx-runtime";function Vs({onClose:o,axiosInstance:e,sistemaNome:r,telefoneSuporte:a,telefoneCS:i,endpointsV2:n,...l}){return tt(So,{...{axiosInstance:e,sistemaNome:r,telefoneSuporte:a,recursosDialog:l,endpointsV2:n,telefoneCS:i},children:tt(ge,{onClose:o})})}import{jsx as it}from"react/jsx-runtime";function Ls({onClose:o,axiosInstance:e,telefoneSuporte:r,endpointsV2:a,telefoneCS:i,...n}){return it(So,{...{axiosInstance:e,telefoneSuporte:r,telefoneCS:i,planosDialog:n,endpointsV2:a},children:it(Se,{onClose:o})})}export{Fs as ConfirmarEmail,Ts as MinhaConta,Ls as PlanosDialog,Vs as RecursosDialog};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s_mart/minha-conta",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -9,56 +9,76 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**"
|
|
11
11
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsup src/index.tsx --minify --format esm --dts --external react",
|
|
14
|
-
"dev": "tsup src/index.tsx --format esm --watch --dts --external react",
|
|
15
|
-
"lint": "eslint src/**/*.ts* --fix"
|
|
16
|
-
},
|
|
17
12
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@s_mart/tokens": "*",
|
|
25
|
-
"@s_mart/utils": "*",
|
|
13
|
+
"tsup": "^6.7.0",
|
|
14
|
+
"@emotion/react": "11.11.1",
|
|
15
|
+
"@emotion/styled": "11.11.0",
|
|
16
|
+
"@mui/material": "^5.14.6",
|
|
17
|
+
"@mui/x-data-grid": "^6.11.2",
|
|
18
|
+
"@types/lodash-es": "^4.17.12",
|
|
26
19
|
"@types/react": "^18.2.21",
|
|
27
20
|
"@types/react-dom": "18.2.4",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
21
|
+
"axios": "^1.6.7",
|
|
22
|
+
"dayjs": "^1.11.10",
|
|
23
|
+
"eslint": "^8.47.0",
|
|
24
|
+
"jwt-decode": "^4.0.0",
|
|
25
|
+
"lodash-es": "^4.17.21",
|
|
26
|
+
"notistack": "^2.0.8",
|
|
27
|
+
"react": "^18.2.0",
|
|
28
|
+
"react-dom": "^18.2.0",
|
|
29
|
+
"react-dropzone": "^14.2.3",
|
|
30
|
+
"react-hook-form": "^7.51.0",
|
|
31
|
+
"typescript": "^5.4.2",
|
|
32
|
+
"zustand": "^4.5.2",
|
|
33
|
+
"@s_mart/core": "5.0.0",
|
|
34
|
+
"@s_mart/data": "5.0.0",
|
|
35
|
+
"@s_mart/form": "5.0.0",
|
|
36
|
+
"@s_mart/hooks": "5.0.0",
|
|
37
|
+
"@s_mart/masks": "5.0.0",
|
|
38
|
+
"@s_mart/regular-icons": "5.0.0",
|
|
39
|
+
"@s_mart/rules": "5.0.0",
|
|
40
|
+
"@s_mart/solid-icons": "5.0.0",
|
|
41
|
+
"@s_mart/tokens": "5.0.0",
|
|
42
|
+
"@s_mart/typed": "5.0.0",
|
|
43
|
+
"@s_mart/utils": "5.0.0",
|
|
44
|
+
"eslint-config-smarten": "4.0.1"
|
|
30
45
|
},
|
|
31
46
|
"peerDependencies": {
|
|
32
|
-
"@emotion/react": ">=11.
|
|
33
|
-
"@emotion/styled": ">=11.
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"@s_mart/
|
|
57
|
-
"@s_mart/
|
|
58
|
-
"eslint": "
|
|
59
|
-
"eslint-config-smarten": "*"
|
|
47
|
+
"@emotion/react": ">=11.11.1",
|
|
48
|
+
"@emotion/styled": ">=11.11.0",
|
|
49
|
+
"@types/lodash-es": "^4.17.12",
|
|
50
|
+
"@types/react": "^18.2.21",
|
|
51
|
+
"@types/react-dom": "18.2.4",
|
|
52
|
+
"axios": "^1.6.7",
|
|
53
|
+
"dayjs": "^1.11.10",
|
|
54
|
+
"jwt-decode": "^4.0.0",
|
|
55
|
+
"lodash-es": "^4.17.21",
|
|
56
|
+
"notistack": "^2.0.8",
|
|
57
|
+
"react": "^18.2.0",
|
|
58
|
+
"react-dom": "^18.2.0",
|
|
59
|
+
"react-dropzone": "^14.2.3",
|
|
60
|
+
"react-hook-form": "^7.51.0",
|
|
61
|
+
"typescript": "^5.4.2",
|
|
62
|
+
"zustand": "^4.5.2",
|
|
63
|
+
"@s_mart/core": "5.0.0",
|
|
64
|
+
"@s_mart/data": "5.0.0",
|
|
65
|
+
"@s_mart/form": "5.0.0",
|
|
66
|
+
"@s_mart/hooks": "5.0.0",
|
|
67
|
+
"@s_mart/masks": "5.0.0",
|
|
68
|
+
"@s_mart/regular-icons": "5.0.0",
|
|
69
|
+
"@s_mart/rules": "5.0.0",
|
|
70
|
+
"@s_mart/solid-icons": "5.0.0",
|
|
71
|
+
"@s_mart/tokens": "5.0.0",
|
|
72
|
+
"@s_mart/utils": "5.0.0",
|
|
73
|
+
"eslint-config-smarten": "4.0.1"
|
|
60
74
|
},
|
|
75
|
+
"devDependencies": {},
|
|
61
76
|
"publishConfig": {
|
|
62
77
|
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"build": "tsup src/index.tsx --minify --format esm --dts --external react",
|
|
81
|
+
"dev": "tsup src/index.tsx --format esm --watch --dts --external react",
|
|
82
|
+
"lint": "eslint src/**/*.ts* --fix"
|
|
63
83
|
}
|
|
64
84
|
}
|