"use strict"; exports.id = 9282; exports.ids = [9282]; exports.modules = { /***/ 2184: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (/* binding */ DatabaseListCard) /* harmony export */ }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _general_DatabaseSlugCopy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4739); /* harmony import */ var _general_GeneralPopup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5472); /* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6729); /* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5264); /* harmony import */ var _general_ui_ButtonGroup__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5449); /* harmony import */ var lucide_react__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2423); /* harmony import */ var lucide_react__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(lucide_react__WEBPACK_IMPORTED_MODULE_6__); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type} props.database * @param {React.Dispatch>} [props.setTargetDatabase] * @param {boolean} [props.delegated] * @param {any} [props.icons] * @param {import("@/package-shared/types").UserType} props.user */ function DatabaseListCard({ database , setTargetDatabase , delegated , icons , user , }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ const url = `/admin/${user?.id}/databases/${database.db_slug}` + (delegated ? `?delegated=true&dbUserId=${database.user_id}` : ""); const { active_clone , active_clone_parent_db } = database; //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("a", { href: url, className: "card", onClick: (e)=>{ if (// @ts-ignore e.target.closest(".db-list-item-actions-block") || // @ts-ignore e.target.closest(".cancel-link")) { e.preventDefault(); } if (delegated) { e.preventDefault(); setLoading(true); (0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z)("/api/getDelegatedDatabaseToken", { method: "post", body: { rootUserId: database.user_id, priviledges: database.user_priviledge, database: database.db_slug } }, true).then((res)=>{ if (res.success) { window.location.href = url; } }); setTimeout(()=>{ setLoading(false); }, 1000); } }, children: [ loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, { width: "20px" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", { src: database.db_image ? database.db_image : "/images/folder.svg", alt: "Folder Image", width: 20, className: database.db_image ? "avatar" : "avatar opacity-50" }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "flex-col items-start grow", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "title", children: database.db_name }), active_clone_parent_db && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.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", " ", /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", { children: active_clone_parent_db.replace(/datasquirel_user_\d+_/, "") }) ] }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "-mt-2", children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_DatabaseSlugCopy__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, { slugText: database.db_slug, smaller: true }) }), true && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "-mt-1 gap-1", children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_DatabaseSlugCopy__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, { slugText: database.db_full_name, smaller: true, full: true }) }), !delegated && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", { className: "text-sm text-slate-400", children: [ "Created: ", database.date_created?.substring(0, 21) ] }), delegated && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "flex items-center mt-2", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", { src: database.image_thumbnail, alt: "", className: "w-8 h-8 rounded-full object-cover" }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "flex-col items-start gap-0", children: [ /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", { className: "text-xs text-slate-600", children: [ database.first_name, " ", database.last_name ] }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "text-xs text-slate-400", children: database.email }) ] }) ] }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "w-full justify-between flex-wrap", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "db-list-item-actions-block flex-wrap", children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_general_ui_ButtonGroup__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, { children: [ !delegated && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", { className: "outlined light-gray small-text", onClick: (e)=>{ window.location.pathname = `/admin/${user?.id}/databases/${database.db_slug}/edit-database`; }, children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { children: "Edit" }) }), !delegated && !active_clone && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", { className: "outlined light-gray small-text", onClick: (e)=>{ window.location.href = `/admin/${user?.id}/databases/add-database?duplicate=${database.db_full_name}`; }, children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { children: "Duplicate" }) }), !delegated && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", { className: "outlined light-gray small-text", onClick: (e)=>{ if (setTargetDatabase) setTargetDatabase(database); (0,_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_3__/* .openPopup */ .Mw)("delete-database-confirmation"); }, children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { children: "Delete" }) }) ] }) }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(lucide_react__WEBPACK_IMPORTED_MODULE_6__.ChevronRight, { className: "text-slate-600", size: 20 }) ] }) ] }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /***/ }), /***/ 8744: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (/* binding */ DatabasesContent) /* harmony export */ }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _pages_admin_user_id_databases__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2109); /* harmony import */ var _general_Breadcrumbs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(424); /* harmony import */ var _general_VerificationBanner__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7946); /* harmony import */ var _DatabasesList__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6891); /* harmony import */ var _DelegatedDatabasesSection__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5592); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props */ function DatabasesContent(props) { /** * Get Contexts * * @abstract { React.useContext } */ const { databases , setTargetDatabase , user } = react__WEBPACK_IMPORTED_MODULE_1___default().useContext(_pages_admin_user_id_databases__WEBPACK_IMPORTED_MODULE_2__.DatabasesContext); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: [ /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "flex-col items-start gap-0 w-full", children: [ /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "w-full justify-between flex-wrap", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h1", { className: "text-3xl m-0", children: "Databases" }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("a", { href: `/admin/${user?.id}/databases/add-database`, className: "button flex items-center gap-2", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "symbol", children: "+" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { children: "Add Database" }) ] }) ] }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_Breadcrumbs__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, { user: user }) ] }), user?.verification_status?.toString().match(/1/) ? /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_DatabasesList__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, { databases: databases, setTargetDatabase: setTargetDatabase, user: user }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_DelegatedDatabasesSection__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, { user: user }) ] }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_VerificationBanner__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {}) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /***/ }), /***/ 6891: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (/* binding */ DatabasesList) /* harmony export */ }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _DatabaseListCard__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2184); /* harmony import */ var _mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8193); /* harmony import */ var _mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(930); /* harmony import */ var _mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_4__); /* harmony import */ var _mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7039); /* harmony import */ var _mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_5__); /* harmony import */ var _mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5050); /* harmony import */ var _mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_6__); /* harmony import */ var _mui_icons_material_StorageTwoTone__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4063); /* harmony import */ var _mui_icons_material_StorageTwoTone__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_StorageTwoTone__WEBPACK_IMPORTED_MODULE_7__); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[]} [props.databases] - Server props * @param {React.Dispatch>} [props.setTargetDatabase] - Section Title * @param {string} [props.title] - Section Title * @param {boolean} [props.more] - More button * @param {import("@/package-shared/types").UserType} [props.user] */ function DatabasesList({ databases , setTargetDatabase , title , more , user , }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", { className: "paper", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", { className: "text-xl m-0", children: title ? title : "Database List" }), user && databases && databases[0] && setTargetDatabase && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6", children: databases.map((database)=>{ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_DatabaseListCard__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, { database: database, setTargetDatabase: setTargetDatabase, icons: { edit: (_mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_3___default()), duplicate: (_mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_4___default()), delete: (_mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_5___default()), copy: (_mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_6___default()) }, user: user }, database.id); }) }), more && databases && databases[0] && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("a", { href: `/admin/${user?.id}/databases`, className: "button w-full more-padding", children: "See All Databases" }), !databases || !databases[0] && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("a", { href: `/admin/${user?.id}/databases/add-database`, className: "button outlined gray dashed w-full p-10 flex-col", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "text-slate-400", children: "No Databases Created." }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_icons_material_StorageTwoTone__WEBPACK_IMPORTED_MODULE_7___default()), { color: "action", sx: { fontSize: 80 }, className: "opacity-40" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "", children: "Add Database" }) ] }) ] }) }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /***/ }), /***/ 5592: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (/* binding */ DelegatedDatabasesSection) /* harmony export */ }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8193); /* harmony import */ var _mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var _mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(930); /* harmony import */ var _mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7039); /* harmony import */ var _mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_4__); /* harmony import */ var _mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5050); /* harmony import */ var _mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_5__); /* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5264); /* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6729); /* harmony import */ var _DatabaseListCard__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2184); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ let timeout; /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {import("@/package-shared/types").UserType} [props.user] */ function DelegatedDatabasesSection({ user }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ /** @type {any} */ const databasesState = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null); /** @type { [databases: import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[] | null, setDatabases: React.Dispatch>] } */ const [databases, setDatabases] = databasesState; const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false); react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{ (0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z)("/api/getDelegatedDatabases").then((res)=>{ if (res.success) { setDatabases(res.databases); setLoading(false); } }); }, []); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", { className: "paper", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", { className: "text-xl m-0 text-left w-full", children: "Delegated Databases" }), loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {}), user && databases ? databases[0] ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6", children: databases.map((database)=>{ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_DatabaseListCard__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { database: database, delegated: true, icons: { edit: (_mui_icons_material_DriveFileRenameOutlineTwoTone__WEBPACK_IMPORTED_MODULE_2___default()), duplicate: (_mui_icons_material_DifferenceTwoTone__WEBPACK_IMPORTED_MODULE_3___default()), delete: (_mui_icons_material_DeleteForeverTwoTone__WEBPACK_IMPORTED_MODULE_4___default()), copy: (_mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_5___default()) }, user: user }, database.id); }) }) }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "info gray w-full font-normal justify-center", children: "No Delegated Databases Yet" }) }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "w-full justify-center", children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, { position: "relative", width: "20px" }) }) }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /***/ }), /***/ 2109: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "DatabasesContext": () => (/* binding */ DatabasesContext), /* harmony export */ "default": () => (/* binding */ Databases), /* harmony export */ "getServerSideProps": () => (/* binding */ getServerSideProps) /* harmony export */ }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _layouts_AdminLayout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4858); /* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(370); /* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _components_admin_databases_DatabasesContent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8744); /* harmony import */ var _components_admin_databases_DeleteDatabaseConfirmationPopup__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5012); /* harmony import */ var _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9395); /* harmony import */ var _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6__); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** ****************************************************************************** */ /** @type {import("@/package-shared/types").DbContextType} */ let databaseContextObject = {}; const DatabasesContext = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1___default().createContext(databaseContextObject); /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {import("@/package-shared/types").UserType} props.user - User Object * @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[]} props.databases - Databases */ function Databases({ user , databases }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ const pageTitle = "Databases | Datasquirel"; const pageDescription = "Welcome to your data app"; let head = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, { children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("title", { children: pageTitle }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", { name: "description", content: pageDescription }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ /** @type {any} */ const targetDatabaseState = react__WEBPACK_IMPORTED_MODULE_1___default().useState(0); /** @type {[ dbTables: import("@/package-shared/types").DSQL_MYSQL_user_databases_Type | undefined, setDbTables: React.Dispatch> ]} */ const [targetDatabase, setTargetDatabase] = targetDatabaseState; //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_layouts_AdminLayout__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, { head: head, user: user, children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(DatabasesContext.Provider, { value: { user, databases, targetDatabase, setTargetDatabase }, children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_admin_databases_DatabasesContent__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {}), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_admin_databases_DeleteDatabaseConfirmationPopup__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, { targetDatabase: targetDatabase }) ] }) }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Server Side Props or Static Props * ============================================================================== * @type {import("next").GetServerSideProps} */ async function getServerSideProps({ req , res , query }) { /** * User Auth * * @description User Auth */ const user = await _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3___default()(req, res); if (!user?.logged_in_status) { return { redirect: { destination: "/login", permanent: false } }; } /** * Page/Site Data Data Fetching * * @description Fetch data on the server before returning */ const databases = await _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6___default()(`SELECT * FROM user_databases WHERE user_id=? ORDER BY id DESC`, [ user.id ]); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Server props return * * @description Return data fetched on the server side */ return { props: { user: user, databases: databases } }; //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /***/ }) }; ;