"use strict"; exports.id = 3863; exports.ids = [3863]; exports.modules = { /***/ 3863: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (/* binding */ UserListCard) /* 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_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5472); /* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6729); /* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5264); /* harmony import */ var _general_ui_ButtonGroup__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5449); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {import("@/package-shared/types").MYSQL_user_users_table_def} props.userObject * @param {React.Dispatch>} props.setTargetUser * @param {string} [props.paradigm] */ function UserListCard({ userObject , setTargetUser , paradigm }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ const userName = (()=>{ if (paradigm?.match(/invited/)) { return `${userObject.inviteeFirstName} ${userObject.inviteeLastName} (${userObject.inviteeEmail})`; } return `${userObject.first_name} ${userObject.last_name} (${userObject.email})`; })(); const userImage = (()=>{ if (paradigm?.match(/invited/)) { return `${userObject.inviteeImage}`; } return `${userObject.image_thumbnail}`; })(); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * 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)("div", { className: "card no-hover items-center " + (paradigm?.match(/invited/) ? " green green-bg" : " primary"), children: [ loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {}), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "w-full", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", { src: userImage, className: "w-8 h-8 rounded-full object-cover bg-slate-200", onError: (e)=>{ // @ts-ignore e.target.src = "/images/user-preset-thumbnail.png"; } }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "text-sm font-semibold", children: userName }), userObject?.user_priviledge?.match(/./) && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", { className: "text-sm ml-auto text-slate-900/50", children: [ "Priviledges:", " ", /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "text-slate-600 font-semibold", children: userObject.user_priviledge.split("|").join(" | ") }) ] }), !paradigm?.match(/invited/) && /*#__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)(_general_ui_ButtonGroup__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, { children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", { className: "outlined text-xs px-3 py-1", onClick: (e)=>{ setTargetUser(userObject); setTimeout(()=>{ (0,_general_GeneralPopup__WEBPACK_IMPORTED_MODULE_2__/* .openPopup */ .Mw)("target-user-popup"); }, 200); }, children: "Edit User Access" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", { className: "outlined text-xs px-3 py-1", onClick: (e)=>{ setLoading(true); if (window.confirm("Delete this user")) { (0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)("/api/deleteUserUser", { method: "post", body: { ...userObject } }, true).then((res)=>{ setTimeout(()=>{ setLoading(false); }, 500); window.location.reload(); }); } }, children: "Delete User" }) ] }) }) ] }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /***/ }) }; ;