PageSourceSearch

https://sayy.ai/assets/NotificationsPage-DHXXJ2Hp.js

js sayy.ai collected 2026-10-05 12:54:23 UTC 14,548 bytes, 11 lines download raw bytes

1import{j as e}from"./crypto-BhrlFu3K.js";import{r as s}from"./routing-BWf71gZX.js";import{u as ge}from"./useBotConfig-CvSR2Ffe.js";import{a as P,x as $,y as ae,z as se,A as Ne,E as we,F as je,G as ye}from"./index-D9Fb1lmT.js";import{updateAgentNotifications as ve}from"./agent-B9rs43Gt.js";import{n as x}from"./notifications-CP6RlmgK.js";import{C as Ee}from"./country-dropdown-BngY7efg.js";import{x as Ce,X as D,m as ne,M as Ae}from"./ui-CIKeZNy-.js";import"./state-BY8jJeYO.js";import"./date-CROXBL6n.js";import"./utils-Dtd7kdR7.js";import"./utils-dl30yseS.js";const Se=()=>$,U={leads:!0,calendar:!0,products:!0},H={leads:!0,calendar:!0,products:!0},Ue=({embedded:M=!1})=>{const y=Ne(),i=P(t=>t.business),z=P(t=>t.isBusinessLoaded),I=P(t=>t.loadBusiness),{activeBotId:b,activeBotData:B,setRefetchBotData:ie}=ge(),m=1,f=1,[l,g]=s.useState([]),[K,v]=s.useState(""),[E,d]=s.useState(""),[C,R]=s.useState($),[A,N]=s.useState(""),[r,w]=s.useState([]),[S,o]=s.useState(""),[c,Y]=s.useState(!1),[re,F]=s.useState(!1),[le,L]=s.useState(!1),[T,V]=s.useState(null),[p,q]=s.useState(!1),[G,J]=s.useState(null),[X,oe]=s.useState(null),[O,de]=s.useState(null),k=c||T!==null,W=p||G!==null,h=s.useMemo(()=>{const t=i==null?void 0:i.notificationSettings,a=ae(t==null?void 0:t.whatsapp);return JSON.stringify({email:se(t)[0]??"",whatsapp:a})},[i==null?void 0:i.notificationSettings,y]),Q=s.useMemo(()=>h,[B,b,h,y]);s.useEffect(()=>{z||I()},[z,I,y]),s.useEffect(()=>{if(!h||k||W||h===O)return;const t=i==null?void 0:i.notificationSettings;g(se(t));const a=ae(t==null?void 0:t.whatsapp);w(a?[a]:[]),R((a==null?void 0:a.countryCode)||Se()),N(""),oe("business"),de(h)},[i==null?void 0:i.notificationSettings,i==null?void 0:i.subscriptionCurrency,h,k,W,O,y]),s.useEffect(()=>{},[B,b,k,W,X,Q]),s.useEffect(()=>{},[B,b,k,W,X,O,Q]);const _=async(t,a)=>{try{const n=we({emails:t,whatsappNumbers:a});return await je(n),await I({force:!0}),!0}catch(n){return console.error("Error updating business notification settings:",n),x.error("Failed to update notification settings"),!1}if(!b)return x.error("No active agent selected"),!1;try{return await ve(b,{email:{enabled:t.length>0,emails:t.slice(0,m),leads:{enabled:U.leads},calendar:{enabled:U.calendar},products:{enabled:U.products}},whatsapp:{enabled:a.length>0,numbers:a.slice(0,f),leads:{enabled:H.leads},calendar:{enabled:H.calendar},products:{enabled:H.products}}}),ie(),!0}catch(n){return console.error("Error updating notification settings:",n),x.error("Failed to update notification settings"),!1}},ce=t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t),pe=async()=>{const t=K.trim().toLowerCase();if(!t){d("Email is required");return}if(!ce(t)){d("Enter a valid email address");return}if(l.length>=m){d(`You can add up to ${m} emails`);return}if(l.includes(t)){d("Email already added");return}const a=l,n=[...a,t];Y(!0),g(n),d(""),await _(n,r)?(x.success("Email notifications updated"),v(""),F(!1)):g(a),Y(!1)},Z=()=>{c||(F(!1),v(""),d(""))},ue=async t=>{const a=l,n=a.filter(j=>j!==t);V(t),g(n),await _(n,r)?x.success("Email removed"):g(a),V(null)},xe=t=>{const a=t.trim();if(!a)return o("Phone number is required"),!1;const{isValid:n,errorMessage:u}=ye(C,a);return n?(o(""),!0):(o(u||"Enter a valid phone number for this country"),!1)},me=async()=>{if(!xe(A))return;if(r.length>=f){o(`You can add up to ${f} WhatsApp numbers`);return}if(r.some(j=>j.countryCode===C&&j.number===A)){o("WhatsApp number already added");return}const a=r,n=[...a,{countryCode:C,number:A}];q(!0),w(n),o(""),await _(l,n)?(x.success("WhatsApp notifications updated"),N(""),L(!1)):w(a),q(!1)},ee=()=>{p||(L(!1),N(""),o(""))},fe=async t=>{const a=`${t.countryCode}-${t.number}`,n=r,u=r.filter(te=>!(te.countryCode===t.countryCode&&te.number===t.number));J(a),w(u),await _(l,u)?x.success("WhatsApp number removed"):w(n),J(null)},he=s.useMemo(()=>c||l.length>=m,[l.length,c,m]),be=s.useMemo(()=>p||r.length>=f,[p,f,r.length]);return e.jsxs("section",{className:M?"flex h-full min-h-0 w-full flex-col":"Main-container flex h-full w-full max-w-[1500px] flex-col !px-3 !pt-4 lg:!px-12 lg:!pt-10",children:[e.jsxs("div",{className:`mb-5 flex shrink-0 flex-col gap-1.5 ${M?"mb-4":""}`,children:[e.jsx("h2",{className:"main-font text-[16px] font-[800] text-black lg:text-[24px] lg:font-[1000]",children:"Notification Settings"}),e.jsx("p",{className:`para-font text-[12px] font-[400] text-[#9ca3af] ${M?"max-w-2xl":"lg:max-w-[70%]"}`,children:"Choose where you get business updates."})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-6 lg:items-stretch",children:[e.jsxs("div",{className:"flex min-w-0 flex-col rounded-[22px] border border-[#e8eaed] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)] sm:p-5",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-[#f3f4f6]",children:e.jsx(Ce,{className:"h-4 w-4 text-[#111827]","aria-hidden":!0})}),e.jsx("h3",{className:"main-font text-[15px] font-[800] text-black sm:text-[16
1px]",children:"Email Notifications"})]}),e.jsx("p",{className:"para-font mt-2 text-[13px] text-[#6b7280]",children:"Notifications are sent to the email below."})]})}),e.jsxs("div",{className:"mt-4 flex flex-1 flex-col gap-3",children:[l.length>0?l.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-2xl border border-[#eef0f3] bg-[#fafbfc] px-3.5 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"para-font text-[11px] font-[600] uppercase tracking-wide text-[#9ca3af]",children:"Email"}),e.jsx("p",{className:"para-font mt-0.5 truncate text-[14px] font-[500] text-[#111827]",children:t})]}),e.jsx("button",{type:"button",onClick:()=>ue(t),disabled:T===t,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-[#e8eaed] bg-white text-[#6b7280] disabled:opacity-50","aria-label":`Remove ${t}`,children:e.jsx(D,{className:"h-3.5 w-3.5",strokeWidth:2.5})})]},t)):e.jsx("div",{className:"rounded-2xl border border-dashed border-[#e5e7eb] bg-[#fafbfc] px-3.5 py-4",children:e.jsx("p",{className:"para-font text-[13px] text-[#9ca3af]",children:"No email added yet"})}),e.jsxs("p",{className:"para-font text-[12px] text-[#9ca3af]",children:[l.length,"/",m," emails added"]}),e.jsxs("button",{type:"button",onClick:()=>{d(""),v(""),F(!0)},disabled:he,className:"mt-auto inline-flex min-h-[42px] w-full items-center justify-center gap-1.5 rounded-full bg-black px-4 para-font text-[13px] font-[600] text-white hover:bg-[#1f1f1f] disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(ne,{className:"h-4 w-4",strokeWidth:2.25}),"Add new email"]})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-col rounded-[22px] border border-[#e8eaed] bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)] sm:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-[#f3f4f6]",children:e.jsx(Ae,{className:"h-4 w-4 text-[#111827]","aria-hidden":!0})}),e.jsx("h3",{className:"main-font text-[15px] font-[800] text-black sm:text-[16px]",children:"WhatsApp Notifications"})]}),e.jsx("p",{className:"para-font mt-2 text-[13px] text-[#6b7280]",children:"Notifications are sent to the WhatsApp number below."}),e.jsxs("div",{className:"mt-4 flex flex-1 flex-col gap-3",children:[r.length>0?r.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-2xl border border-[#eef0f3] bg-[#fafbfc] px-3.5 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"para-font text-[11px] font-[600] uppercase tracking-wide text-[#9ca3af]",children:"WhatsApp"}),e.jsxs("p",{className:"para-font mt-0.5 truncate text-[14px] font-[500] text-[#111827]",children:[t.countryCode||$," ",t.number]})]}),e.jsx("button",{type:"button",onClick:()=>fe(t),disabled:G===`${t.countryCode}-${t.number}`,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-[#e8eaed] bg-white text-[#6b7280] disabled:opacity-50","aria-label":`Remove ${t.countryCode||$} ${t.number}`,children:e.jsx(D,{className:"h-3.5 w-3.5",strokeWidth:2.5})})]},`${t.countryCode}-${t.number}`)):e.jsx("div",{className:"rounded-2xl border border-dashed border-[#e5e7eb] bg-[#fafbfc] px-3.5 py-4",children:e.jsx("p",{className:"para-font text-[13px] text-[#9ca3af]",children:"No WhatsApp numbers added yet"})}),e.jsxs("p",{className:"para-font text-[12px] text-[#9ca3af]",children:[r.length,"/",f," WhatsApp numbers added"]}),e.jsxs("button",{type:"button",onClick:()=>{o(""),N(""),L(!0)},disabled:be,className:"mt-auto inline-flex min-h-[42px] w-full items-center justify-center gap-1.5 rounded-full bg-black px-4 para-font text-[13px] font-[600] text-white hover:bg-[#1f1f1f] disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(ne,{className:"h-4 w-4",strokeWidth:2.25}),"Add WhatsApp number"]})]})]})]}),re?e.jsxs("div",{className:"fixed inset-0 z-[140] flex items-end justify-center sm:items-center",children:[e.jsx("style",{children:`
2            @keyframes notificationSheetUp {
3              from { transform: translateY(100%); }
4              to { transform: translateY(0); }
5            }
6          `}),e.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50","aria-label":"Close add email",onClick:Z}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Add new email",className:"relative z-[1] flex w-full max-w-md flex-col overflow-hidden rounded-t-[20px] bg-white shadow-[0_-8px_30px_rgba(15,23,42,0.18)] animate-[notificationSheetUp_0.28s_ease-out] sm:rounded-2xl sm:shadow-xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"flex shrink-0 justify-center pt-2 sm:hidden",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-[#d1d5db]","aria-hidden":!0})}),e.jsxs("div",{className:"relative flex shrink-0 flex-col items-center px-5 pb-1 pt-3 text-center sm:pt-5",children:[e.jsx("button",{type:"button",onClick:Z,disabled:c,
6className:"absolute right-4 top-3 rounded-full p-1 text-[#6b7280] hover:bg-[#f3f4f6] disabled:opacity-50 sm:top-4","aria-label":"Close",children:e.jsx(D,{className:"h-5 w-5"})}),e.jsx("h3",{className:"main-font text-[18px] font-[1000] text-[#111827]",children:"Add new email"}),e.jsx("p",{className:"para-font mt-1 max-w-[18rem] text-[13px] text-[#6b7280]",children:"Enter the email address where you want to receive notifications."})]}),e.jsxs("form",{className:"flex flex-col gap-4 px-5 pb-[max(1rem,env(safe-area-inset-bottom))] pt-3",onSubmit:t=>{t.preventDefault(),pe()},children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-email-input",className:"para-font mb-2 block text-center text-[11px] font-[600] uppercase tracking-wide text-[#9ca3af]",children:"Email address"}),e.jsx("input",{id:"notification-email-input",type:"email",value:K,onChange:t=>{v(t.target.value),E&&d("")},className:`w-full min-h-[44px] rounded-[12px] border bg-white px-3 text-center para-font text-[14px] text-[#111827] outline-none placeholder:text-[#9ca3af] focus:border-black ${E?"border-red-500":"border-[#e8eaed]"}`,placeholder:"[email protected]",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",autoFocus:!0,disabled:c}),E?e.jsx("p",{className:"para-font mt-2 text-center text-[12px] text-red-600",children:E}):null]}),e.jsx("button",{type:"submit",disabled:c,className:"inline-flex min-h-[44px] w-full items-center justify-center rounded-full bg-black px-4 para-font text-[14px] font-[600] text-white disabled:opacity-60",children:c?"Saving…":"Submit"})]})]})]}):null,le?e.jsxs("div",{className:"fixed inset-0 z-[140] flex items-end justify-center sm:items-center",children:[e.jsx("style",{children:`
7            @keyframes notificationSheetUp {
8              from { transform: translateY(100%); }
9              to { transform: translateY(0); }
10            }
11          `}),e.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50","aria-label":"Close add WhatsApp",onClick:ee}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Add WhatsApp number",className:"relative z-[1] flex w-full max-w-md flex-col overflow-hidden rounded-t-[20px] bg-white shadow-[0_-8px_30px_rgba(15,23,42,0.18)] animate-[notificationSheetUp_0.28s_ease-out] sm:rounded-2xl sm:shadow-xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"flex shrink-0 justify-center pt-2 sm:hidden",children:e.jsx("span",{className:"h-1 w-10 rounded-full bg-[#d1d5db]","aria-hidden":!0})}),e.jsxs("div",{className:"relative flex shrink-0 flex-col items-center px-5 pb-1 pt-3 text-center sm:pt-5",children:[e.jsx("button",{type:"button",onClick:ee,disabled:p,className:"absolute right-4 top-3 rounded-full p-1 text-[#6b7280] hover:bg-[#f3f4f6] disabled:opacity-50 sm:top-4","aria-label":"Close",children:e.jsx(D,{className:"h-5 w-5"})}),e.jsx("h3",{className:"main-font text-[18px] font-[1000] text-[#111827]",children:"Add WhatsApp number"}),e.jsx("p",{className:"para-font mt-1 max-w-[18rem] text-[13px] text-[#6b7280]",children:"Enter the WhatsApp number where you want to receive notifications."})]}),e.jsxs("form",{className:"flex flex-col gap-4 px-5 pb-[max(1rem,env(safe-area-inset-bottom))] pt-3",onSubmit:t=>{t.preventDefault(),me()},children:[e.jsxs("div",{children:[e.jsx("label",{className:"para-font mb-2 block text-center text-[11px] font-[600] uppercase tracking-wide text-[#9ca3af]",children:"WhatsApp number"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{value:C,onChange:R,width:"w-max min-w-[104px] shrink-0",prioritizedCodes:["+91","+971"]}),e.jsx("input",{type:"text",value:A,onChange:t=>{const a=t.target.value.replace(/\D/g,"");N(a),S&&o("")},placeholder:"Phone number",className:`min-h-[44px] w-full rounded-[12px] border bg-white px-3 para-font text-[14px] text-[#111827] outline-none placeholder:text-[#9ca3af] focus:border-black ${S?"border-red-500":"border-[#e8eaed]"}`,maxLength:15,inputMode:"numeric",autoFocus:!0,disabled:p})]}),S?e.jsx("p",{className:"para-font mt-2 text-center text-[12px] text-red-600",children:S}):null]}),e.jsx("button",{type:"submit",disabled:p,className:"inline-flex min-h-[44px] w-full items-center justify-center rounded-full bg-black px-4 para-font text-[14px] font-[600] text-white disabled:opacity-60",children:p?"Saving…":"Submit"})]})]})]}):null]})};export{Ue as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.