1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
|
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3293],{14589:(e,a,t)=>{t.d(a,{A:()=>c});var l=t(74848),s=t(96540),i=t(620),d=t(87810);t(97711),t(45165);var n=t(97157),r=t(42543);function c(e){let{user:a,dbImage:t,setDbImage:c,query:o}=s.useContext(d.AddDatabaseContext);if(!a)return(0,l.jsx)(s.Fragment,{});let[u,m]=s.useState(null),[h,p]=s.useState(!1);return(0,l.jsx)("section",{className:"card",children:(0,l.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-2 gap-6 items-stretch",children:[h&&(0,l.jsx)(i.A,{}),(0,l.jsxs)("div",{className:"flex-col items-start",children:[(0,l.jsx)("h2",{className:"text-xl m-0 text-left w-full",children:"New Database Information"}),a&&t&&c&&(0,l.jsx)(n.A,{user:a,dbImage:t,setDbImage:c,setLoading:p,query:o})]}),a&&t&&c&&(0,l.jsx)(r.A,{user:a,dbImage:t,setDbImage:c})]})})}},97157:(e,a,t)=>{let l;t.d(a,{A:()=>h});var s=t(74848),i=t(96540),d=t(97711),n=t(41696);t(40961);var r=t(23698),c=t(17531);async function o(e){var a,t,l,s,i,d,n;let{e:o,setLoading:u,dbImage:m,database:h,user:p}=e;u(!0);let g={db_description:(null===(t=o.target.database_description)||void 0===t?void 0:null===(a=t.value)||void 0===a?void 0:a.match(/./))?o.target.database_description.value:null,db_name:(null===(s=o.target.database_name)||void 0===s?void 0:null===(l=s.value)||void 0===l?void 0:l.match(/./))?o.target.database_name.value:null,db_slug:(null===(d=o.target.database_slug)||void 0===d?void 0:null===(i=d.value)||void 0===i?void 0:i.match(/./))?o.target.database_slug.value:null,db_full_name:h.db_full_name,id:h.id,active_clone:h.active_clone,active_clone_parent_db:h.active_clone_parent_db};if(m){if("string"==typeof m)g.db_image=m;else if("object"==typeof m){let e=await (0,r.A)("/api/addUserMedia",{method:"post",body:{media:[m],folder:g.db_slug.replace(/_/g,"-"),type:"image"}},!0);g.db_image=(null==e?void 0:null===(n=e.mediaData[0])||void 0===n?void 0:n.media_thumbnail_url)?e.mediaData[0].media_thumbnail_url:"/images/database-placeholder.png"}}else g.db_image="/images/database-placeholder.png";(0,r.A)("/api/updateUserDatabase",{method:"post",body:g},!0).then(e=>{e.success?(0,c.A)().then(()=>{window.location.pathname="/admin/".concat(null==p?void 0:p.id,"/databases"),setTimeout(()=>{u(!1)},1e3)}):(alert("Error! Please Try Again"),setTimeout(()=>{u(!1)},1e3))})}async function u(e){var a,t,l;let{e:s,setLoading:i,dbImage:d,keepUpdated:n,keepDataUpdated:o,query:u,user:m}=e;i(!0);let h={db_name:s.target.database_name.value,db_slug:s.target.database_slug.value,db_description:(null===(t=s.target.database_description)||void 0===t?void 0:null===(a=t.value)||void 0===a?void 0:a.match(/./))?s.target.database_description.value:null};if(d){if("string"==typeof d)h.db_image=d;else if("object"==typeof d){let e=await (0,r.A)("/api/addUserMedia",{method:"post",body:{media:[d],folder:h.db_slug.replace(/_/g,"-"),type:"image"}},!0);h.db_image=(null==e?void 0:null===(l=e.mediaData[0])||void 0===l?void 0:l.media_thumbnail_url)?e.mediaData[0].media_thumbnail_url:"/images/database-placeholder.png"}}(null==u?void 0:u.duplicate)&&(h.duplicate=u.duplicate,h.keepUpdated=!!n&&n,h.keepDataUpdated=!!o&&o),(0,r.A)("/api/createUserDatabase",{method:"post",body:h},!0).then(e=>{e.success?(0,c.A)().then(()=>{window.location.pathname="/admin/".concat(null==m?void 0:m.id,"/databases/").concat(h.db_slug)}):setTimeout(()=>{i(!1)},1e3)})}var m=t(21458);function h(e){let{user:a,dbImage:t,setDbImage:r,database:c,setLoading:h,query:p}=e;async function g(e){return(null==c?void 0:c.db_slug)===e?null:await (0,d.A)({tableName:"user_databases",columnName:"db_slug",value:e,userId:a.id})}let[b,x]=i.useState(null),[v,f]=i.useState(!1),[y,w]=i.useState(!1);return(0,s.jsxs)("form",{className:"w-full max-w-none xl:max-w-lg flex flex-col items-start gap-4 relative",onSubmit:e=>{e.preventDefault(),c?o({e,setLoading:h,dbImage:t,database:c,user:a}):u({e,setLoading:h,dbImage:t,keepUpdated:v,keepDataUpdated:y,query:p,user:a})},children:[b&&(0,s.jsx)(n.A,{message:b}),(0,s.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,
|