"use strict"; (() => { var exports = {}; exports.id = 3400; exports.ids = [3400]; exports.modules = { /***/ 8333: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "MediaContext": () => (/* binding */ MediaContext), "default": () => (/* binding */ Dashboard), "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: ./components/general/Breadcrumbs.jsx var Breadcrumbs = __webpack_require__(424); // EXTERNAL MODULE: ./components/general/GeneralPopup.jsx var GeneralPopup = __webpack_require__(5472); // EXTERNAL MODULE: ./components/general/VerificationBanner.jsx var VerificationBanner = __webpack_require__(7946); // EXTERNAL MODULE: ./components/admin/media/MediaList.jsx + 5 modules var MediaList = __webpack_require__(7604); // EXTERNAL MODULE: ./components/general/ui/ButtonGroup.jsx var ButtonGroup = __webpack_require__(5449); ;// CONCATENATED MODULE: ./components/admin/media/MediaContent.jsx // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props */ function MediaContent(props) { /** * Get Contexts * * @abstract { React.useContext } */ const { media , setTargetMedia , user , folders , staticHost } = external_react_default().useContext(MediaContext); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * 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 justify-between flex-wrap", children: [ /*#__PURE__*/ jsx_runtime_.jsx("h1", { className: "text-3xl m-0", children: "Media" }), /*#__PURE__*/ (0,jsx_runtime_.jsxs)(ButtonGroup/* default */.Z, { children: [ /*#__PURE__*/ (0,jsx_runtime_.jsxs)("button", { className: "flex items-center gap-2", onClick: (e)=>{ (0,GeneralPopup/* openPopup */.Mw)("choose-media-type-popoup"); }, children: [ /*#__PURE__*/ jsx_runtime_.jsx("span", { className: "symbol", children: "+" }), /*#__PURE__*/ jsx_runtime_.jsx("span", { children: "Add Media" }) ] }), /*#__PURE__*/ (0,jsx_runtime_.jsxs)("button", { className: "flex items-center gap-2 outlined gray", onClick: (e)=>{ (0,GeneralPopup/* openPopup */.Mw)("add-folder-popoup"); }, children: [ /*#__PURE__*/ jsx_runtime_.jsx("span", { className: "symbol", children: "+" }), /*#__PURE__*/ jsx_runtime_.jsx("span", { children: "Add Folder" }) ] }) ] }) ] }), /*#__PURE__*/ jsx_runtime_.jsx(Breadcrumbs/* default */.Z, { user: user }) ] }), user?.verification_status?.toString().match(/1/) ? /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, { children: [ /*#__PURE__*/ jsx_runtime_.jsx(MediaList/* default */.Z, { media: media, setTargetMedia: setTargetMedia, folders: folders, staticHost: staticHost, user: user }), media && media[0] && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("a", { className: "border-dotted border-slate-400 border-2 px-4 py-3 w-full rounded flex items-center hover:border-primary/50 gap-2 cursor-pointer justify-center", onClick: (e)=>{ (0,GeneralPopup/* openPopup */.Mw)("choose-media-type-popoup"); }, children: [ /*#__PURE__*/ jsx_runtime_.jsx("span", { className: "symbol", children: "+" }), /*#__PURE__*/ jsx_runtime_.jsx("span", { className: "", children: "Add Media" }) ] }) ] }) : /*#__PURE__*/ jsx_runtime_.jsx(VerificationBanner/* default */.Z, {}) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ // EXTERNAL MODULE: ./components/general/UploadImageComponent.jsx var UploadImageComponent = __webpack_require__(3770); // EXTERNAL MODULE: ./components/admin/media/NewMediaPopup.jsx + 3 modules var NewMediaPopup = __webpack_require__(4891); // EXTERNAL MODULE: ./components/admin/media/TargetMediaPreviewPopup.jsx var TargetMediaPreviewPopup = __webpack_require__(3428); // EXTERNAL MODULE: ./components/admin/media/NewFolderPopup.jsx var NewFolderPopup = __webpack_require__(1597); // EXTERNAL MODULE: ./components/general/UploadFileComponent.jsx var UploadFileComponent = __webpack_require__(8916); // EXTERNAL MODULE: ./components/admin/media/ChooseMediaTypePopup.jsx var ChooseMediaTypePopup = __webpack_require__(9201); // EXTERNAL MODULE: ./components/general/LoadingBlock.jsx var LoadingBlock = __webpack_require__(5264); // 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); // EXTERNAL MODULE: external "path" var external_path_ = __webpack_require__(1017); var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_); // EXTERNAL MODULE: ./components/general/UploadVideoComponent.jsx var UploadVideoComponent = __webpack_require__(7525); ;// CONCATENATED MODULE: ./pages/admin/[user_id]/media/index.jsx // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ const fs = __webpack_require__(7147); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** ****************************************************************************** */ /** @type {import("@/package-shared/types").MediaContextType} */ // @ts-ignore const init = {}; const MediaContext = /*#__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").MYSQL_user_media_table_def[]} props.media * @param {string[]} props.folders * @param {string} props.staticHost */ function Dashboard({ user , media , folders , staticHost }) { /** * 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 ... } */ /** @type {[ newMedia: import("@/package-shared/types").ImageObjectType[] | null, setNewMedia: React.Dispatch> ]} */ // @ts-ignore const [newMedia, setNewMedia] = external_react_default().useState(null); /** @type {[ newFile: any | null, setNewFile: React.Dispatch> ]} */ // @ts-ignore const [newFile, setNewFile] = external_react_default().useState(null); /** @type {[ newFile: any | null, setNewFile: React.Dispatch> ]} */ // @ts-ignore const [newVideo, setNewVideo] = external_react_default().useState(null); const [loading, setLoading] = external_react_default().useState(false); /** @type {[ targetMedia: import("@/package-shared/types").MYSQL_user_media_table_def | null, setTargetMedia: React.Dispatch> ]} */ // @ts-ignore const [targetMedia, setTargetMedia] = external_react_default().useState(null); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ jsx_runtime_.jsx(AdminLayout/* default */.Z, { head: head, user: user, children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(MediaContext.Provider, { value: { user, media, targetMedia, setTargetMedia, folders, staticHost }, children: [ loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, { screen: true, title: "Processing Files ..." }), /*#__PURE__*/ jsx_runtime_.jsx(MediaContent, {}), /*#__PURE__*/ jsx_runtime_.jsx(UploadImageComponent/* default */.Z, { setNewMedia: setNewMedia, setLoading: setLoading }), /*#__PURE__*/ jsx_runtime_.jsx(UploadFileComponent/* default */.Z, { setNewFile: setNewFile, setLoading: setLoading }), /*#__PURE__*/ jsx_runtime_.jsx(UploadVideoComponent/* default */.Z, { setNewVideo: setNewVideo, setLoading: setLoading }), /*#__PURE__*/ jsx_runtime_.jsx(NewMediaPopup/* default */.Z, { newMedia: newMedia, setNewMedia: setNewMedia, newFile: newFile, setNewFile: setNewFile, newVideo: newVideo, setNewVideo: setNewVideo }), /*#__PURE__*/ jsx_runtime_.jsx(TargetMediaPreviewPopup/* default */.Z, { targetMedia: targetMedia, setTargetMedia: setTargetMedia, staticHost: staticHost, media: media }), /*#__PURE__*/ jsx_runtime_.jsx(NewFolderPopup/* default */.Z, {}), /*#__PURE__*/ jsx_runtime_.jsx(ChooseMediaTypePopup/* default */.Z, { user: user }) ] }) }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * 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 media = await DB_HANDLER_default()(`SELECT * FROM user_media WHERE user_id='${user.id}' AND folder IS NULL`); const STATIC_ROOT = process.env.DSQL_STATIC_SERVER_DIR; if (!STATIC_ROOT) { console.log("Static File ENV not Found!"); return { redirect: { destination: "/admin", permanent: false } }; } const folderPath = external_path_default().join(STATIC_ROOT, `images/user-images/user-${user.id}/`); if (!fs.existsSync(folderPath)) { return { redirect: { destination: "/admin", permanent: false } }; } const folders = fs.readdirSync(folderPath).filter((name)=>!name.match(/\..{3,4}$/)); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Server props return * * @description Return data fetched on the server side */ return { props: { user: user, media: media, folders: folders, staticHost: process.env.DSQL_STATIC_HOST || "" } }; //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /***/ }), /***/ 4003: /***/ ((module) => { module.exports = require("@mui/icons-material/AdminPanelSettingsTwoTone"); /***/ }), /***/ 9765: /***/ ((module) => { module.exports = require("@mui/icons-material/AssignmentTwoTone"); /***/ }), /***/ 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"); /***/ }), /***/ 386: /***/ ((module) => { module.exports = require("@mui/icons-material/CottageTwoTone"); /***/ }), /***/ 8757: /***/ ((module) => { module.exports = require("@mui/icons-material/DeleteOutlineOutlined"); /***/ }), /***/ 8979: /***/ ((module) => { module.exports = require("@mui/icons-material/DynamicFormTwoTone"); /***/ }), /***/ 8398: /***/ ((module) => { module.exports = require("@mui/icons-material/FolderCopyTwoTone"); /***/ }), /***/ 300: /***/ ((module) => { module.exports = require("@mui/icons-material/LanguageOutlined"); /***/ }), /***/ 8083: /***/ ((module) => { module.exports = require("@mui/icons-material/LockOpenOutlined"); /***/ }), /***/ 4624: /***/ ((module) => { module.exports = require("@mui/icons-material/LockPersonRounded"); /***/ }), /***/ 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"); /***/ }), /***/ 5580: /***/ ((module) => { module.exports = require("@mui/icons-material/PermMediaTwoTone"); /***/ }), /***/ 36: /***/ ((module) => { module.exports = require("@mui/icons-material/RefreshRounded"); /***/ }), /***/ 1799: /***/ ((module) => { module.exports = require("@mui/icons-material/SchemaTwoTone"); /***/ }), /***/ 871: /***/ ((module) => { module.exports = require("@mui/icons-material/VideoCameraBackTwoTone"); /***/ }), /***/ 2423: /***/ ((module) => { module.exports = require("lucide-react"); /***/ }), /***/ 968: /***/ ((module) => { module.exports = require("next/head"); /***/ }), /***/ 6689: /***/ ((module) => { module.exports = require("react"); /***/ }), /***/ 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,913,4480,370,424,4858,5472,8345,6718,7946,6390], () => (__webpack_exec__(8333))); module.exports = __webpack_exports__; })();