"use strict"; (() => { var exports = {}; exports.id = 2417; exports.ids = [2417,133,4135]; exports.modules = { /***/ 9310: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (/* binding */ UserMediaPopup) /* 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 _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6729); /* harmony import */ var _general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5472); /* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5264); /* harmony import */ var _ExistingFieldEdit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9967); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {React.Dispatch>} props.setDbImage */ function UserMediaPopup({ setDbImage }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(true); /** @type {any} */ const mediaState = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null); /** @type { [ media: import("@/package-shared/types").MYSQL_MediaType[] | null, setMedia: React.Dispatch> ] } */ const [media, setMedia] = mediaState; react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{ (0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)("/api/getUserMedia").then((res)=>{ setLoading(false); setMedia(res.media); }); }, []); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .ZP, { title: "user-media-popup", children: [ loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, { width: "20px" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h4", { className: "m-0 text-lg", children: "Your Uploaded Images" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "grid grid-cols-2", children: media && media[0] && media.filter((media)=>media.media_type == "image").map((mediaObject, index)=>{ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", { className: "w-full h-44 cursor-pointer hover:opacity-70", onClick: (e)=>{ setDbImage(mediaObject.media_thumbnail_url || null); (0,_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__/* .closePopup */ .j4)(); }, children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", { src: mediaObject.media_thumbnail_url, alt: "User Media", className: "w-full h-full object-contain" }) }, index + 1); }) }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /***/ }), /***/ 4227: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { // @ts-check const fs = __webpack_require__(7147); const serverError = __webpack_require__(7023); const NO_DB_HANDLER = __webpack_require__(2020); /** * Create database from Schema Function * ============================================================================== * @param {string} queryString - Query String * @returns {Promise} */ module.exports = async function noDatabaseDbHandler(queryString) { "production"?.match(/dev/) && fs.appendFileSync("./.tmp/sqlQuery.sql", queryString + "\n" + Date() + "\n\n\n", "utf8"); /** * Declare variables * * @description Declare "results" variable */ let results; /** * Fetch from db * * @description Fetch data from db if no cache */ try { /** ********************* Run Query */ results = await NO_DB_HANDLER(queryString); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } catch (/** @type {any} */ error) { serverError({ component: "noDatabaseDbHandler", message: error.message }); console.log("ERROR in noDatabaseDbHandler =>", error.message); } /** * Return results * * @description Return results add to cache if "req" param is passed */ if (results) { return results; } else { return null; } }; /***/ }), /***/ 2020: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { // @ts-check const fs = __webpack_require__(7147); const path = __webpack_require__(1017); // const mysql = require("mysql"); // const NO_DB = mysql.createConnection({ // host: process.env.DSQL_DB_HOST, // user: process.env.DSQL_DB_USERNAME, // password: process.env.DSQL_DB_PASSWORD, // charset: "utf8mb4", // }); const mysql = __webpack_require__(2261); const SSL_DIR = "/app/ssl"; let NO_DB = mysql({ config: { host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, charset: "utf8mb4", ssl: { ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`) } } }); /** * DSQL user read-only DB handler * @param {object} params * @param {string} params.paradigm * @param {string} params.database * @param {string} params.queryString * @param {string[]} [params.queryValues] */ // @ts-ignore function NO_DB_HANDLER(...args) { try { return new Promise((resolve, reject)=>{ NO_DB.query(...args).then((results)=>{ NO_DB.end(); resolve(JSON.parse(JSON.stringify(results))); }).catch((err)=>{ NO_DB.end(); resolve({ error: err.message, sql: err.sql }); }); }); } catch (/** @type {any} */ error) { return { success: false, error: error.message }; } } module.exports = NO_DB_HANDLER; /***/ }), /***/ 1481: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "SettingsContext": () => (/* binding */ SettingsContext), "default": () => (/* binding */ Settings), "getServerSideProps": () => (/* binding */ getServerSideProps) }); // EXTERNAL MODULE: external "react/jsx-runtime" var jsx_runtime_ = __webpack_require__(997); // EXTERNAL MODULE: external "react" var external_react_ = __webpack_require__(6689); var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_); // EXTERNAL MODULE: ./layouts/AdminLayout.jsx + 2 modules var AdminLayout = __webpack_require__(4858); // EXTERNAL MODULE: ./functions/backend/userAuth.js var userAuth = __webpack_require__(370); var userAuth_default = /*#__PURE__*/__webpack_require__.n(userAuth); // EXTERNAL MODULE: ./pages/admin/[user_id]/index.jsx var _user_id_ = __webpack_require__(1457); // EXTERNAL MODULE: ./components/general/Breadcrumbs.jsx var Breadcrumbs = __webpack_require__(424); // EXTERNAL MODULE: ./components/pages/create-account/CreateAccountForm.jsx + 1 modules var CreateAccountForm = __webpack_require__(5114); // EXTERNAL MODULE: ./functions/frontend/imageInputFileToBase64.js var imageInputFileToBase64 = __webpack_require__(6718); // EXTERNAL MODULE: ./components/general/GeneralPopup.jsx var GeneralPopup = __webpack_require__(5472); // EXTERNAL MODULE: ./components/general/ui/ButtonGroup.jsx var ButtonGroup = __webpack_require__(5449); ;// CONCATENATED MODULE: ./components/admin/databases/UserImage.jsx // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ let timeout; /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {import("@/package-shared/types").UserType} [props.user] * @param {string | null | import("@/package-shared/types").ImageObjectType} props.image * @param {React.Dispatch>} props.setImage */ function UserImage({ user , image , setImage }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ const imagePreviewRef = external_react_default().useRef(); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", { className: "paper w-full items-center", children: [ /*#__PURE__*/ jsx_runtime_.jsx("h2", { className: "m-0 text-xl", children: "User Image" }), /*#__PURE__*/ jsx_runtime_.jsx("div", { className: "bg-white rounded-full overflow-hidden w-24 h-24", children: /*#__PURE__*/ jsx_runtime_.jsx("img", { src: image ? typeof image === "string" ? image : image.imageBase64Full : "/images/database-placeholder.png", alt: "User Image", width: 100, className: "w-full h-full object-cover", // @ts-ignore ref: imagePreviewRef, "data-imagepreview": "image" }) }), /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", { className: "w-full flex-col", id: "upload-user-image-options", children: [ /*#__PURE__*/ (0,jsx_runtime_.jsxs)(ButtonGroup/* default */.Z, { column: true, className: "w-full", children: [ /*#__PURE__*/ jsx_runtime_.jsx("button", { className: "outlined gray w-full whitespace-normal", onClick: (e)=>{ (0,GeneralPopup/* openPopup */.Mw)("user-media-popup"); }, children: "Choose image From your Uploads" }), /*#__PURE__*/ jsx_runtime_.jsx("button", { className: "secondary w-full whitespace-normal", onClick: (e)=>{ /** @type {HTMLButtonElement} */ // @ts-ignore const buttonEl = e.target; buttonEl.closest("#upload-user-image-options")?.querySelector("input")?.click(); }, children: /*#__PURE__*/ jsx_runtime_.jsx("span", { children: "Choose image From your Computer" }) }) ] }), /*#__PURE__*/ jsx_runtime_.jsx("input", { type: "file", accept: ".png,.jpg,.jpeg,.webp", placeholder: "Choose Image", className: "hidden", onChange: async (e)=>{ /** @type {HTMLInputElement} */ // @ts-ignore const inputEl = e.target; const inputFile = inputEl?.files?.[0]; if (inputFile) { let imageData = await (0,imageInputFileToBase64/* default */.Z)({ imageInputFile: inputFile, maxWidth: 400 }); setImage(imageData); } } }) ] }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ // EXTERNAL MODULE: ./components/general/LoadingBlock.jsx var LoadingBlock = __webpack_require__(5264); ;// CONCATENATED MODULE: ./components/admin/settings/SettingsContent.jsx // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props */ function SettingsContent(props) { /** * Get Contexts * * @abstract { React.useContext } */ const { user , image , setImage , activeUser } = external_react_default().useContext(SettingsContext); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ const [delLoading, setDelLoading] = external_react_default().useState(false); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, { children: [ /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", { className: "flex-col items-start gap-0 w-full", children: [ /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", { className: "w-full flex items-center justify-between", children: [ /*#__PURE__*/ jsx_runtime_.jsx("h1", { className: "text-3xl m-0", children: "Settings" }), /*#__PURE__*/ jsx_runtime_.jsx("div", { children: !user?.social_login && /*#__PURE__*/ jsx_runtime_.jsx("a", { href: "/send-password-reset-link", className: "button outlined", children: "Reset Password" }) }) ] }), /*#__PURE__*/ jsx_runtime_.jsx(Breadcrumbs/* default */.Z, { user: user }) ] }), /*#__PURE__*/ jsx_runtime_.jsx("section", { className: "p-0", children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", { className: "w-full grid grid-cols-1 xl:grid-cols-2 gap-8 items-stretch", children: [ /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", { className: "paper w-full", children: [ /*#__PURE__*/ jsx_runtime_.jsx("h2", { className: "m-0 text-xl", children: "Account Information" }), /*#__PURE__*/ jsx_runtime_.jsx(CreateAccountForm/* default */.Z, { user: activeUser, image: image }) ] }), /*#__PURE__*/ jsx_runtime_.jsx("div", { className: "items-stretch", children: /*#__PURE__*/ jsx_runtime_.jsx(UserImage, { image: image, setImage: setImage }) }) ] }) }), false && /*#__PURE__*/ 0 ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ // EXTERNAL MODULE: ./components/admin/databases/UserMediaPopup.jsx var UserMediaPopup = __webpack_require__(9310); // EXTERNAL MODULE: ./package-shared/functions/backend/noDatabaseDbHandler.js var noDatabaseDbHandler = __webpack_require__(4227); var noDatabaseDbHandler_default = /*#__PURE__*/__webpack_require__.n(noDatabaseDbHandler); // EXTERNAL MODULE: ./package-shared/utils/backend/global-db/DB_HANDLER.js var DB_HANDLER = __webpack_require__(9395); var DB_HANDLER_default = /*#__PURE__*/__webpack_require__.n(DB_HANDLER); ;// CONCATENATED MODULE: ./pages/admin/[user_id]/settings.jsx // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** ****************************************************************************** */ /** @type {import("@/package-shared/types").SettingsPageContextType} */ // @ts-ignore const init = {}; const SettingsContext = /*#__PURE__*/ external_react_default().createContext(init); /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {import("@/package-shared/types").UserType} props.user * @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[]} [props.databases] * @param {any} props.activeUser */ function Settings({ user , databases , activeUser }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ const pageTitle = "User Dashboard | Datasquirel"; const pageDescription = "Welcome to your data app"; let head = /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, { children: [ /*#__PURE__*/ jsx_runtime_.jsx("title", { children: pageTitle }), /*#__PURE__*/ jsx_runtime_.jsx("meta", { name: "description", content: pageDescription }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ const [image, setImage] = external_react_default().useState(activeUser.image); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ jsx_runtime_.jsx(AdminLayout/* default */.Z, { head: head, user: user, children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(SettingsContext.Provider, { value: { user, image, setImage, activeUser }, children: [ /*#__PURE__*/ jsx_runtime_.jsx(SettingsContent, {}), /*#__PURE__*/ jsx_runtime_.jsx(UserMediaPopup/* default */.Z, { setDbImage: setImage }) ] }) }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Server Side Props or Static Props * ============================================================================== * @type {import("next").GetServerSideProps} */ async function getServerSideProps({ req , res , query }) { /** * User Auth * * @description User Auth */ const user = await userAuth_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 noDatabaseDbHandler_default()(`SELECT SCHEMA_NAME AS dbFullName FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 'user_${user.id}%'`); const activeUser = await DB_HANDLER_default()(`SELECT first_name,last_name,username,email,image,image_thumbnail FROM users WHERE id='${user.id}'`); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Server props return * * @description Return data fetched on the server side */ return { props: { user: user, databases: databases, activeUser: activeUser[0] } }; //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /***/ }), /***/ 4003: /***/ ((module) => { module.exports = require("@mui/icons-material/AdminPanelSettingsTwoTone"); /***/ }), /***/ 4173: /***/ ((module) => { module.exports = require("@mui/icons-material/Close"); /***/ }), /***/ 69: /***/ ((module) => { module.exports = require("@mui/icons-material/CloudOffTwoTone"); /***/ }), /***/ 4008: /***/ ((module) => { module.exports = require("@mui/icons-material/CloudQueueRounded"); /***/ }), /***/ 7306: /***/ ((module) => { module.exports = require("@mui/icons-material/CollectionsTwoTone"); /***/ }), /***/ 5050: /***/ ((module) => { module.exports = require("@mui/icons-material/CopyAllTwoTone"); /***/ }), /***/ 386: /***/ ((module) => { module.exports = require("@mui/icons-material/CottageTwoTone"); /***/ }), /***/ 7039: /***/ ((module) => { module.exports = require("@mui/icons-material/DeleteForeverTwoTone"); /***/ }), /***/ 930: /***/ ((module) => { module.exports = require("@mui/icons-material/DifferenceTwoTone"); /***/ }), /***/ 8193: /***/ ((module) => { module.exports = require("@mui/icons-material/DriveFileRenameOutlineTwoTone"); /***/ }), /***/ 8979: /***/ ((module) => { module.exports = require("@mui/icons-material/DynamicFormTwoTone"); /***/ }), /***/ 300: /***/ ((module) => { module.exports = require("@mui/icons-material/LanguageOutlined"); /***/ }), /***/ 2814: /***/ ((module) => { module.exports = require("@mui/icons-material/LockTwoTone"); /***/ }), /***/ 5557: /***/ ((module) => { module.exports = require("@mui/icons-material/MenuBookTwoTone"); /***/ }), /***/ 9806: /***/ ((module) => { module.exports = require("@mui/icons-material/PeopleOutlineTwoTone"); /***/ }), /***/ 36: /***/ ((module) => { module.exports = require("@mui/icons-material/RefreshRounded"); /***/ }), /***/ 1799: /***/ ((module) => { module.exports = require("@mui/icons-material/SchemaTwoTone"); /***/ }), /***/ 4063: /***/ ((module) => { module.exports = require("@mui/icons-material/StorageTwoTone"); /***/ }), /***/ 6517: /***/ ((module) => { module.exports = require("lodash"); /***/ }), /***/ 2423: /***/ ((module) => { module.exports = require("lucide-react"); /***/ }), /***/ 968: /***/ ((module) => { module.exports = require("next/head"); /***/ }), /***/ 6689: /***/ ((module) => { module.exports = require("react"); /***/ }), /***/ 7849: /***/ ((module) => { module.exports = require("react-dom/client"); /***/ }), /***/ 997: /***/ ((module) => { module.exports = require("react/jsx-runtime"); /***/ }), /***/ 2261: /***/ ((module) => { module.exports = require("serverless-mysql"); /***/ }), /***/ 4300: /***/ ((module) => { module.exports = require("buffer"); /***/ }), /***/ 6113: /***/ ((module) => { module.exports = require("crypto"); /***/ }), /***/ 7147: /***/ ((module) => { module.exports = require("fs"); /***/ }), /***/ 3685: /***/ ((module) => { module.exports = require("http"); /***/ }), /***/ 1017: /***/ ((module) => { module.exports = require("path"); /***/ }) }; ; // load runtime var __webpack_require__ = require("../../../webpack-runtime.js"); __webpack_require__.C(exports); var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId)) var __webpack_exports__ = __webpack_require__.X(0, [4017,8313,5264,6729,5449,5304,913,9395,370,424,4858,5472,7023,7901,6718,9594,9471,7037,9967,7946,1500,75,9282,8374,7926,5114], () => (__webpack_exec__(1481))); module.exports = __webpack_exports__; })();