"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[207],{207:(t,e,a)=>{a.d(e,{DataProvider:()=>i,E:()=>l});var n=a(95155),s=a(12115),o=a(70689);let c=(0,s.createContext)();function i(t){let{children:e}=t,{token:a}=(0,o.A)(),[i,l]=(0,s.useState)([null,null]),u=(0,s.useMemo)(()=>{let t=new URLSearchParams;if(null!==i[0]&&null!==i[1]){console.log("Start date (before formatting): "+i[0]),console.log("End date (before formatting): "+i[1]);let e=new Date(i[0]),a=new Date(i[1]),n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0).toISOString(),s=new Date(a.getFullYear(),a.getMonth(),a.getDate(),23,59,59).toISOString();console.log("Start date: "+n),console.log("End date: "+s),t.append("startDate",n),t.append("endDate",s)}return t},[i]),[r,f]=(0,s.useState)(null),[d,h]=(0,s.useState)(!0),[p,g]=(0,s.useState)(null),[y,S]=(0,s.useState)([]),[m,w]=(0,s.useState)(!0),[E,j]=(0,s.useState)(null),[T,v]=(0,s.useState)([]),[C,A]=(0,s.useState)(!0),[F,B]=(0,s.useState)(null),[z,G]=(0,s.useState)(null),[_,D]=(0,s.useState)(!0),[O,b]=(0,s.useState)(null),[M,k]=(0,s.useState)([]),[x,P]=(0,s.useState)(!0),[I,N]=(0,s.useState)(null),[R,Y]=(0,s.useState)([]),[q,L]=(0,s.useState)(!0),[U,H]=(0,s.useState)(null),[J,K]=(0,s.useState)([]),[Q,V]=(0,s.useState)(!0),[W,X]=(0,s.useState)(null),[Z,$]=(0,s.useState)([]),[tt,te]=(0,s.useState)(!0),[ta,tn]=(0,s.useState)(null),[ts,to]=(0,s.useState)([]),[tc,ti]=(0,s.useState)(!0),[tl,tu]=(0,s.useState)(null),[tr,tf]=(0,s.useState)(null),[td,th]=(0,s.useState)([]),[tp,tg]=(0,s.useState)(!0),[ty,tS]=(0,s.useState)(null),[tm,tw]=(0,s.useState)(null),[tE,tj]=(0,s.useState)(!0),[tT,tv]=(0,s.useState)(null),[tC,tA]=(0,s.useState)(null),[tF,tB]=(0,s.useState)(!0),[tz,tG]=(0,s.useState)(null),[t_,tD]=(0,s.useState)(null),[tO,tb]=(0,s.useState)(!0),[tM,tk]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/overview-page-endpoints/stats-overview-dashboard-main-page",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(f(e.data),console.log(e.data)):g("Failed to fetch data")}catch(t){g(t.message)}finally{h(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/overview-page-endpoints/latest-conversations",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(S(e.data),console.log(e.data)):j("Failed to fetch data")}catch(t){j(t.message)}finally{w(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/overview-page-endpoints/traffic-overview",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(v(e.data),console.log(e.data)):B("Failed to fetch data")}catch(t){B(t.message)}finally{A(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/ooc-page-endpoints/stats-overview",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(G(e.data),console.log(e.data)):b("Failed to fetch OOC data")}catch(t){b(t.message)}finally{D(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/ooc-page-endpoints/ooc-trends",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(k(e.data),console.log(e.data)):N("Failed to fetch OOC data")}catch(t){N(t.message)}finally{P(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/ooc-page-endpoints/ooc-queries",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(Y(e.data),console.log(e.data)):H("Failed to fetch OOC data")}catch(t){H(t.message)}finally{L(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/traffic-page/stats-overview",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(K(e.data),console.log(e.data)):X("Failed to fetch traffic stats data")}catch(t){X(t.message)}finally{V(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/traffic-page/messages-traffic?".concat(u.toString()),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?($(e.data),console.log(e.data)):tn("Failed to fetch traffic stats data")}catch(t){tn(t.message)}finally{te(!1)}})()},[a,i,u]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/traffic-page/user-traffic?".concat(u.toString()),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(to(e.data),console.log(e.data)):tu("Failed to fetch traffic stats data")}catch(t){tu(t.message)}finally{ti(!1)}})()},[a,i,u]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/sentiment-page-endpoints/stats-overview?".concat(u.toString()),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(tf(e.data.sentiment_summary),th(e.data.all_conversations),console.log(e.data)):tS("Failed to fetch sentiment data")}catch(t){tS(t.message)}finally{tg(!1)}})()},[a,u]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/settings-endpoints/change-ooc-notification",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(tw(e.ooc_email_preference),console.log(e.ooc_email_preference)):tv("Failed to fetch traffic stats data")}catch(t){tv(t.message)}finally{tj(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/settings-endpoints/get-members",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(tA(e.data),console.log("MEMBERS: ",e.data)):tG("Failed to fetch traffic stats data")}catch(t){tG(t.message)}finally{tB(!1)}})()},[a]),(0,s.useEffect)(()=>{(async function(){if(a)try{let t=await fetch("/api/appointment-page-endpoints?".concat(u.toString()),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)}}),e=await t.json();e.success?(tD(e.data),console.log("Appointments: ",e.data)):tk("Failed to fetch traffic stats data")}catch(t){tk(t.message)}finally{tb(!1)}})()},[a,i,u]),(0,n.jsx)(c.Provider,{value:{dateRange:i,setDateRange:l,topCardData:r,loading:d,error:p,latestConversations:y,loadingLatestConversations:m,errorLatestConversations:E,trafficOverviewData:T,loadingTrafficOverviewData:C,errorTrafficOverviewData:F,oocOverviewData:z,loadingOocOverviewData:_,errorOocOverviewData:O,oocTrendData:M,loadingOocTrendData:x,errorOocTrendData:I,oocQueriesData:R,loadingOocQueriesData:q,errorOocQueriesData:U,trafficStatsData:J,loadingTrafficStatsData:Q,errorTrafficStatsData:W,trafficTrendData:Z,loadingTrafficTrendData:tt,errorTrafficTrendData:ta,userTrafficTrendData:ts,loadingUserTrafficTrendData:tc,errorUserTrafficTrendData:tl,sentimentStatsData:tr,sentimentTrendData:td,loadingSentimentData:tp,errorSentimentTrendData:ty,oocEmailPreference:tm,loadingOOCEmailPreference:tE,members:tC,loadingMembers:tF,appointmentsBooked:t_,loadingAppointmentsBooked:tO},children:e})}function l(){return(0,s.useContext)(c)}}}]);