"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7538],{99928:(e,a,s)=>{s.d(a,{A:()=>u});var t=s(74848),l=s(96540),i=s(70910),n=s(45165),d=s(23698),c=s(620),r=s(60557),o=s(18453);function u(e){var a;let{database:s,setTargetDatabase:u,delegated:x,icons:m,user:p}=e,h="/admin/".concat(null==p?void 0:p.id,"/databases/").concat(s.db_slug)+(x?"?delegated=true&dbUserId=".concat(s.user_id):""),{active_clone:j,active_clone_parent_db:g}=s,[f,b]=l.useState(!1);return(0,t.jsxs)("a",{href:h,className:"card",onClick:e=>{(e.target.closest(".db-list-item-actions-block")||e.target.closest(".cancel-link"))&&e.preventDefault(),x&&(e.preventDefault(),b(!0),(0,d.A)("/api/getDelegatedDatabaseToken",{method:"post",body:{rootUserId:s.user_id,priviledges:s.user_priviledge,database:s.db_slug}},!0).then(e=>{e.success&&(window.location.href=h)}),setTimeout(()=>{b(!1)},1e3))},children:[f&&(0,t.jsx)(c.A,{width:"20px"}),(0,t.jsx)("img",{src:s.db_image?s.db_image:"/images/folder.svg",alt:"Folder Image",width:20,className:s.db_image?"avatar":"avatar opacity-50"}),(0,t.jsxs)("div",{className:"flex-col items-start grow",children:[(0,t.jsx)("span",{className:"title",children:s.db_name}),g&&(0,t.jsxs)("span",{className:"text-xs bg-emerald-100 dark:bg-emerald-100/10 text-emerald-700 dark:text-emerald-200 px-2 py-0.5 rounded-full mb-1",children:["This Database is an active Clone of"," ",(0,t.jsx)("b",{children:g.replace(/datasquirel_user_\d+_/,"")})]}),(0,t.jsx)("div",{className:"-mt-2",children:(0,t.jsx)(i.A,{slugText:s.db_slug,smaller:!0})}),(0,t.jsx)("div",{className:"-mt-1 gap-1",children:(0,t.jsx)(i.A,{slugText:s.db_full_name,smaller:!0,full:!0})}),!x&&(0,t.jsxs)("span",{className:"text-sm text-slate-400",children:["Created: ",null===(a=s.date_created)||void 0===a?void 0:a.substring(0,21)]}),x&&(0,t.jsxs)("div",{className:"flex items-center mt-2",children:[(0,t.jsx)("img",{src:s.image_thumbnail,alt:"",className:"w-8 h-8 rounded-full object-cover"}),(0,t.jsxs)("div",{className:"flex-col items-start gap-0",children:[(0,t.jsxs)("span",{className:"text-xs text-slate-600",children:[s.first_name," ",s.last_name]}),(0,t.jsx)("span",{className:"text-xs text-slate-400",children:s.email})]})]}),(0,t.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,t.jsx)("div",{className:"db-list-item-actions-block flex-wrap",children:(0,t.jsxs)(r.A,{children:[!x&&(0,t.jsx)("button",{className:"outlined light-gray small-text",onClick:e=>{window.location.pathname="/admin/".concat(null==p?void 0:p.id,"/databases/").concat(s.db_slug,"/edit-database")},children:(0,t.jsx)("span",{children:"Edit"})}),!x&&!j&&(0,t.jsx)("button",{className:"outlined light-gray small-text",onClick:e=>{window.location.href="/admin/".concat(null==p?void 0:p.id,"/databases/add-database?duplicate=").concat(s.db_full_name)},children:(0,t.jsx)("span",{children:"Duplicate"})}),!x&&(0,t.jsx)("button",{className:"outlined light-gray small-text",onClick:e=>{u&&u(s),(0,n.PB)("delete-database-confirmation")},children:(0,t.jsx)("span",{children:"Delete"})})]})}),(0,t.jsx)(o.A,{className:"text-slate-600",size:20})]})]})]})}},67720:(e,a,s)=>{s.d(a,{A:()=>o});var t=s(74848),l=s(96540),i=s(98471),n=s(4709),d=s(55624),c=s(82171),r=s(56417);function o(e){var a;let{databases:s,setTargetDatabase:o,user:u}=l.useContext(i.DatabasesContext);return(0,t.jsxs)(l.Fragment,{children:[(0,t.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,t.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,t.jsx)("h1",{className:"text-3xl m-0",children:"Databases"}),(0,t.jsxs)("a",{href:"/admin/".concat(null==u?void 0:u.id,"/databases/add-database"),className:"button flex items-center gap-2",children:[(0,t.jsx)("span",{className:"symbol",children:"+"}),(0,t.jsx)("span",{children:"Add Database"})]})]}),(0,t.jsx)(n.A,{user:u})]}),(null==u?void 0:null===(a=u.verification_status)||void 0===a?void 0:a.toString().match(/1/))?(0,t.jsxs)(l.Fragment,{children:[(0,t.jsx)(c.A,{databases:s,setTargetDatabase:o,user:u}),(0,t.jsx)(r.A,{user:u})]}):(0,t.jsx)(d.A,{})]})}},82171:(e,a,s)=>{s.d(a,{A:()=>u});var t=s(74848),l=s(96540),i=s(99928),n=s(85373),d=s(75238),c=s(53193),r=s(74315),o=s(4532);function u(e){let{databases:a,setTargetDatabase:s,title:u,more:x,user:m}=e;return(0,t.jsx)(l.Fragment,{children:(0,t.jsxs)("section",{className:"paper",children:[(0,t.jsx)("h2",{className:"text-xl m-0",children:u||"Database List"}),m&&a&&a[0]&&s&&(0,t.jsx)("div",{className:"w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6",children:a.map(e=>(0,t.jsx)(i.A,{database:e,setTargetDatabase:s,icons:{edit:n.A,duplicate:d.A,delete:c.A,copy:r.A},user:m},e.id))}),x&&a&&a[0]&&(0,t.jsx)("a",{href:"/admin/".concat(null==m?void 0:m.id,"/databases"),className:"button w-full more-padding",children:"See All Databases"}),!a||!a[0]&&(0,t.jsxs)("a",{href:"/admin/".concat(null==m?void 0:m.id,"/databases/add-database"),className:"button outlined gray dashed w-full p-10 flex-col",children:[(0,t.jsx)("span",{className:"text-slate-400",children:"No Databases Created."}),(0,t.jsx)(o.A,{color:"action",sx:{fontSize:80},className:"opacity-40"}),(0,t.jsx)("span",{className:"",children:"Add Database"})]})]})})}},56417:(e,a,s)=>{s.d(a,{A:()=>x});var t=s(74848),l=s(96540),i=s(85373),n=s(75238),d=s(53193),c=s(74315),r=s(620),o=s(23698),u=s(99928);function x(e){let{user:a}=e,[s,x]=l.useState(null),[m,p]=l.useState(!1);return l.useEffect(()=>{(0,o.A)("/api/getDelegatedDatabases").then(e=>{e.success&&(x(e.databases),p(!1))})},[]),(0,t.jsxs)("section",{className:"paper",children:[(0,t.jsx)("h2",{className:"text-xl m-0 text-left w-full",children:"Delegated Databases"}),m&&(0,t.jsx)(r.A,{}),a&&s?s[0]?(0,t.jsx)(l.Fragment,{children:(0,t.jsx)("div",{className:"w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6",children:s.map(e=>(0,t.jsx)(u.A,{database:e,delegated:!0,icons:{edit:i.A,duplicate:n.A,delete:d.A,copy:c.A},user:a},e.id))})}):(0,t.jsx)(l.Fragment,{children:(0,t.jsx)("span",{className:"info gray w-full font-normal justify-center",children:"No Delegated Databases Yet"})}):(0,t.jsx)(l.Fragment,{children:(0,t.jsx)("div",{className:"w-full justify-center",children:(0,t.jsx)(r.A,{position:"relative",width:"20px"})})})]})}},45165:(e,a,s)=>{s.d(a,{Ay:()=>n,PB:()=>d,fs:()=>c});var t=s(74848),l=s(76897),i=s(96540);function n(e){let{children:a,title:s,data:n,fullPage:d,wrapperClasses:r,closePopupDispatch:o,wrapperStyle:u,noContainer:x}=e;return d?(0,t.jsxs)("div",{className:"popup-bg overflow-hidden "+(r||""),"data-popupid":s||null,style:u,children:[x?(0,t.jsx)(i.Fragment,{children:a}):(0,t.jsx)("div",{className:"relative w-full h-full z-50","data-data":n?JSON.stringify(n):"",children:a}),(0,t.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{c(),o&&o()},children:(0,t.jsx)(l.A,{color:"white",size:20})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{c(),o&&o()}})]}):(0,t.jsxs)("div",{className:"popup-bg","data-popupid":s||null,children:[x?(0,t.jsx)(i.Fragment,{children:a}):(0,t.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":n?JSON.stringify(n):"",children:[a,(0,t.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{c(),o&&o()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})})]}),x&&(0,t.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{c(),o&&o()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{c(),o&&o()}})]})}function d(e,a){let s=document.querySelector("[data-popupid='".concat(e,"']"));s&&(s.style.display="flex",a&&a(s))}function c(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e&&e()}},55624:(e,a,s)=>{s.d(a,{A:()=>l});var t=s(74848);function l(e){return(0,t.jsxs)("a",{href:"/email-verification",className:"card w-full items-center justify-center py-4 gap-2",children:[(0,t.jsx)("img",{src:"/images/warning.png",alt:"Down Arrow",width:25,className:""}),(0,t.jsx)("span",{children:"Your Account is not verified. Please verify your account."})]})}s(96540)},94909:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(95737).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},98471:(e,a,s)=>{s.r(a),s.d(a,{DatabasesContext:()=>r,__N_SSP:()=>c,default:()=>o});var t=s(74848),l=s(96540),i=s(51187),n=s(67720),d=s(47652),c=!0;let r=l.createContext({});function o(e){let{user:a,databases:s}=e,c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("title",{children:"Databases | Datasquirel"}),(0,t.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[o,u]=l.useState(0);return(0,t.jsx)(i.A,{head:c,user:a,children:(0,t.jsxs)(r.Provider,{value:{user:a,databases:s,targetDatabase:o,setTargetDatabase:u},children:[(0,t.jsx)(n.A,{}),(0,t.jsx)(d.A,{targetDatabase:o})]})})}}}]);