"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6460],{6919:(e,t,l)=>{l.d(t,{A:()=>c});vara=l(4848),s=l(6540),n=l(620),i=l(5896),d=l(3698);functionr(e){let{paradigm:t,payload:l,setLoading:a,table:s,database:n}=e;a(!0),(0,d.A)("/api/exportTableData",{method:"POST",body:{paradigm:t,dbName:n.db_slug,tableName:s.tableName,payload:l}},!0).then(e=>{if(e.success){if("export"==t){lett=newBlob([JSON.stringify(e.data||[],null,4)],{type:"application/json"}),l=URL.createObjectURL(t),a=document.createElement("a");a.href=l,a.style.display="none",a.download="".concat(n.db_slug,"-").concat(s.tableName,"-").concat(Date.now(),".json"),document.body.appendChild(a),a.click(),document.body.removeChild(a)}else"import"==t&&(window.alert("Data Imported Successfully"),window.location.reload())}elsee.msg&&window.alert(e.msg)}).catch(e=>{console.log(e)}).finally(()=>{a(!1)})}functionc(e){let{database:t,table:l}=e,[d,c]=s.useState(!1),[o,u]=s.useState(!0),m=s.useRef(null);returns.useRef(null),(0,a.jsxs)("div",{className:"relative",children:[d&&(0,a.jsx)(n.A,{width:"15px"}),(0,a.jsx)("div",{className:"button outlined gray",onClick:e=>{r({paradigm:"export",database:t,setLoading:c,table:l})},children:"Export"}),(0,a.jsx)("div",{className:"button outlined gray",onClick:e=>{vara,s;null===(a=m.current)||void0===a||a.addEventListener("change",e=>{vara;c(!0);lets=e.target;if(!(null===(a=s.files)||void0===a?void0:a[0])){window.alert("No FIles selected"),c(!1);return}(0,i.A)({inputFile:s.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))?r({paradigm:"import",payload:e.fileBase64,database:t,setLoading:c,table:l}):c(!1),u(!1),setTimeout(()=>{u(!0)},200)})}),null===(s=m.current)||void0===s||s.click()},children:"Import"}),o&&(0,a.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:m})]})}},1627:(e,t,l)=>{l.d(t,{A:()=>x});vara=l(4848),s=l(6540),n=l(5143),i=l(3238),d=l(637),r=l(1301),c=l(620),o=l(4500),u=l(3698),m=l(2543),h=l.n(m);functionp(e){let{database:t,table:l,setOpenPopover:n,dbSchemaData:i,query:d}=e,[r,c]=s.useState(!1);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"ghost p-3 justify-start",onClick:()=>{c(!0),setTimeout(()=>{n&&n(!1)},200)},children:"Sync Data"}),(0,a.jsx)(o.A,{open:r,setOpen:c,children:(0,a.jsx)(f,{database:t,table:l,dbSchemaData:i,query:d})})]})}functionf(e){let{database:t,table:l,query:n,dbSchemaData:i}=e,[o,m]=s.useState(i),[p,f]=s.useState("Push"),[x,b]=s.useState(null==o?void0:o[0]),[v,g]=s.useState(null==x?void0:x.tables),[j,N]=s.useState(null==v?void0:v[0]),[y,w]=s.useState(!1),[T,S]=s.useState(!1);returns.useEffect(()=>{h().isEqual(null==l?void0:l.fields,null==j?void0:j.fields)?S(!0):S(!1)},[j,b]),s.useEffect(()=>{n.delegated&&(0,u.A)("/api/get-authorized-databases").then(e=>{e.success&&e.payload&&m(e.payload)})},[]),(0,a.jsxs)("div",{className:"stack gap-2 relative w-full",children:[y||!o&&(0,a.jsx)(c.A,{width:"20px"}),(0,a.jsx)("h3",{className:"m-0 text-lg",children:"Sync Data with another table"}),T?(0,a.jsxs)("span",{className:"info green inline",children:["The selected table matches ",(0,a.jsx)("b",{children:l.tableFullName})," ","schema"]}):(0,a.jsxs)("span",{className:"info warning inline",children:["The selected table is not compatible with"," ",(0,a.jsx)("b",{children:l.tableFullName})]}),o&&(0,a.jsxs)("form",{onSubmit:e=>{!function(e){vart,l,a;let{e:s,setLoading:n,database:i,table:d,query:r}=e;s.preventDefault(),n(!0);letc=s.target,o=null===(t=c.paradigm)||void0===t?void0:t.value,m=null===(l=c.database)||void0===l?void0:l.value,h=null===(a=c.table)||void0===a?void0:a.value,p={paradigm:o,src:{db:i.db_slug,table:d.tableName},dst:{db:m,table:h},delegated:r.delegated};if(!window.confirm("Pull"==o?"NOTE: This operation will override the current database entries. Continue?":"NOTE: This operation will override the selected database entries. Continue?")){setTimeout(()=>{n(!1)},1e3);return}(0,u.A)("/api/sync-table-data",{method:"POST",body:{...p}},!0).