1import { u as useMutation, a as useQuery, j as jsxRuntimeExports, T as Typography, C as Chip, b as TextField, B as Button, A as ARA_ID_ERROR, c as ARA_ID_PATTERN, n as normalizeAraId, d as CHANGE_USER_ROLES, U as UPDATE_USER, V as VIEW_ADMIN_USER_PAGE } from "./index-C4CHA07n.js"; 2import { d as distExports } from "./index-BxvBIHme.js"; 3import { M as MetaTags } from "./MetaTags-BAQyR9et.js"; 4import { A as AdminUserPicker, b as AdminUserApiKey } from "./AdminUserPicker-64th55f7.js"; 5import { N as NotFound } from "./NotFound-BeY5nixI.js"; 6import { A as Autocomplete } from "./Autocomplete-DiXU0F9o.js"; 7import "./x-apiKey-KXcOGzT9.js"; 8import "./logo-D1jnWoFK.js"; 9import "./Grid-BLLzrUSJ.js"; 10import "./Close-GGPuanMX.js"; 11import "./Popper-Dd3Hvd48.js"; 12const USER_ROLES = [{ 13 role: "PLAYER", 14 displayName: "Player" 15}, { 16 role: "GAME_ADMIN", 17 displayName: "Game Admin" 18}, { 19 role: "SITE_ADMIN", 20 displayName: "Site Admin", 21 disabled: true 22}]; 23const AdminUserPage = ({ 24 userId 25}) => { 26 var _a, _b, _c, _d, _e, _f, _g; 27 const [changeUserRoles] = useMutation(CHANGE_USER_ROLES, { 28 refetchQueries: ["ViewUserAdminPage"] 29 }); 30 const [updateUser] = useMutation(UPDATE_USER, { 31 refetchQueries: ["ViewUserAdminPage"] 32 }); 33 const changePasswordFormMethods = distExports.useForm({ 34 mode: "onBlur" 35 }); 36 const { 37 register: changePasswordFormRegister, 38 formState: { 39 errors: changePasswordFormErrors 40 } 41 } = changePasswordFormMethods; 42 const changeUsernameFormMethods = distExports.useForm({ 43 mode: "onBlur" 44 }); 45 const { 46 register: changeUsernameFormRegister, 47 formState: { 48 errors: changeUsernameFormErrors 49 } 50 } = changeUsernameFormMethods; 51 const changeEmailFormMethods = distExports.useForm({ 52 mode: "onBlur" 53 }); 54 const { 55 register: changeEmailFormRegister, 56 formState: { 57 errors: changeEmailFormErrors 58 } 59 } = changeEmailFormMethods; 60 const changeFirstNameFormMethods = distExports.useForm({ 61 mode: "onBlur" 62 }); 63 const { 64 register: changeFirstNameFormRegister, 65 formState: { 66 errors: changeFirstNameFormErrors 67 } 68 } = changeFirstNameFormMethods; 69 const changeLastNameFormMethods = distExports.useForm({ 70 mode: "onBlur" 71 }); 72 const { 73 register: changeLastNameFormRegister, 74 formState: { 75 errors: changeLastNameFormErrors 76 } 77 } = changeLastNameFormMethods; 78 const changeAraIdFormMethods = distExports.useForm({ 79 mode: "onBlur" 80 }); 81 const { 82 register: changeAraIdFormRegister, 83 formState: { 84 errors: changeAraIdFormErrors 85 } 86 } = changeAraIdFormMethods; 87 const onUserUpdateSubmit = async (data2) => { 88 await updateUser({ 89 variables: { 90 input: { 91 userId, 92 ...data2.password && { 93 newPassword: data2.password 94 }, 95 ...data2.username && { 96 newUsername: data2.username 97 }, 98 ...data2.email && { 99 newEmail: data2.email 100 }, 101 ...data2.firstName && { 102 newFirstName: data2.firstName 103 }, 104 ...data2.lastName && { 105 newLastName: data2.lastName 106 }, 107 ...data2.araId !== void 0 && { 108 newAraId: data2.araId 109 } 110 } 111 } 112 }); 113 }; 114 const { 115 data, 116 error, 117 loading 118 } = useQuery(VIEW_ADMIN_USER_PAGE, { 119 variables: { 120 userId 121 } 122 }); 123 if (error || loading) return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}); 124 const user = data.user; 125 if (!user) { 126 return /* @__PURE__ */ jsxRuntimeExports.jsx(NotFound, {}); 127 } 128 const userRoles = user.userRoles; 129 if (userRoles && !userRoles.includes("SITE_ADMIN")) { 130 if (USER_ROLES.find((role) => role.role === "SITE_ADMIN")) { 131 USER_ROLES.pop(); 132 } 133 } 134 function handleUserRolesChange() { 135 return async (e, userRoles2) => { 136 await changeUserRoles({ 137 variables: { 138 input: { 139 userId, 140 userRoles: userRoles2.map((role) => role.role) 141 } 142 } 143 }); 144 }; 145 } 146 return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
147 /* @__PURE__ */ jsxRuntimeExports.jsx(MetaTags, { title: `${user.username} | Administration` }), 148 /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "h4", children: "User:" }), 149 /* @__PURE__ */ jsxRuntimeExports.jsx(AdminUserPicker, { selectedUserId: userId }), 150 /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "h4", children: "User Roles:" }), 151 /* @__PURE__ */ jsxRuntimeExports.jsx(Autocomplete, { multiple: true, onChange: handleUserRolesChange(), options: USER_ROLES, value: USER_ROLES.filter((role) => userRoles.includes(role.role)), getOptionLabel: (option) => option.displayName, sx: { 152 minWidth: "300px", 153 width: "50%", 154 marginBottom: "10px" 155 }, renderInput: (params) => /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { ...params, label: "Assign Roles" }), renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(Chip, { label: option.displayName, ...getTagProps({ 156 index 157 }), disabled: option.disabled }, index)) }), 158 /* @__PURE__ */ jsxRuntimeExports.jsxs(distExports.Form, { formMethods: changePasswordFormMethods, onSubmit: onUserUpdateSubmit, children: [
159 /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { ...changePasswordFormRegister("password", { 160 required: true 161 }), label: "Password", type: "password", variant: "filled", error: changePasswordFormErrors.password ? true : false, helperText: (_a = changePasswordFormErrors == null ? void 0 : changePasswordFormErrors.password) == null ? void 0 : _a.message.toString(), required: true }), 162 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "large", variant: "contained", color: "primary", children: "Change Password" }) 163 ] }), 164 /* @__PURE__ */ jsxRuntimeExports.jsxs(distExports.Form, { formMethods: changeUsernameFormMethods, onSubmit: onUserUpdateSubmit, children: [ 165 /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { ...changeUsernameFormRegister("username", { 166 required: true 167 }), label: "Username", variant: "filled", error: changeUsernameFormErrors.username ? true : false, helperText: (_b = changeUsernameFormErrors == null ? void 0 : changeUsernameFormErrors.username) == null ? void 0 : _b.message.toString(), required: true }),
168 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "large", variant: "contained", color: "primary", children: "Change Username" }), 169 /* @__PURE__ */ jsxRuntimeExports.jsxs(Typography, { display: "inline", children: [ 170 " Currently ", 171 user.username 172 ] }) 173 ] }), 174 /* @__PURE__ */ jsxRuntimeExports.jsxs(distExports.Form, { formMethods: changeEmailFormMethods, onSubmit: onUserUpdateSubmit, children: [ 175 /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { ...changeEmailFormRegister("email", { 176 required: true 177 }), label: "Email", variant: "filled", error: changeEmailFormErrors.email ? true : false, helperText: (_c = changeEmailFormErrors == null ? void 0 : changeEmailFormErrors.email) == null ? void 0 : _c.message.toString(), required: true }), 178 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "large", variant: "contained", color: "primary", children: "Change Email" }), 179 /* @__PURE__ */ jsxRuntimeExports.jsxs(Typography, { display: "inline", children: [ 180 " Currently ", 181 user.email 182 ] }) 183 ] }), 184 /* @__PURE__ */ jsxRuntimeExports.jsxs(distExports.Form, { formMethods: changeFirstNameFormMethods, onSubmit: onUserUpdateSubmit, children: [
185 /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { ...changeFirstNameFormRegister("firstName", { 186 required: true 187 }), label: "First Name", variant: "filled", error: changeFirstNameFormErrors.firstName ? true : false, helperText: (_d = changeFirstNameFormErrors == null ? void 0 : changeFirstNameFormErrors.firstName) == null ? void 0 : _d.message.toString(), required: true }), 188 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "large", variant: "contained", color: "primary", children: "Change First Name" }), 189 /* @__PURE__ */ jsxRuntimeExports.jsxs(Typography, { display: "inline", children: [ 190 " Currently ", 191 user.firstName 192 ] }) 193 ] }), 194 /* @__PURE__ */ jsxRuntimeExports.jsxs(distExports.Form, { formMethods: changeLastNameFormMethods, onSubmit: onUserUpdateSubmit, children: [ 195 /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { ...changeLastNameFormRegister("lastName", { 196 required: true 197 }), label: "Last Name", variant: "filled", error: changeLastNameFormErrors.lastName ? true : false, helperText: (_e = changeLastNameFormErrors == null ? void 0 : changeLastNameFormErrors.lastName) == null ? void 0 : _e.message.toString(), required: true }),
198 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "large", variant: "contained", color: "primary", children: "Change Last Name" }), 199 /* @__PURE__ */ jsxRuntimeExports.jsxs(Typography, { display: "inline", children: [ 200 " Currently ", 201 user.fullLastName 202 ] }) 203 ] }), 204 /* @__PURE__ */ jsxRuntimeExports.jsxs(distExports.Form, { formMethods: changeAraIdFormMethods, onSubmit: onUserUpdateSubmit, children: [ 205 /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { ...changeAraIdFormRegister("araId", { 206 required: true, 207 setValueAs: normalizeAraId, 208 pattern: { 209 value: ARA_ID_PATTERN, 210 message: ARA_ID_ERROR 211 } 212 }), label: "ARA ID", variant: "filled", error: changeAraIdFormErrors.araId ? true : false, helperText: (_g = (_f = changeAraIdFormErrors == null ? void 0 : changeAraIdFormErrors.araId) == null ? void 0 : _f.message) == null ? void 0 : _g.toString(), inputProps: { 213 maxLength: 5 214 }, required: true }),
215 /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "large", variant: "contained", color: "primary", children: "Change ARA ID" }), 216 /* @__PURE__ */ jsxRuntimeExports.jsxs(Typography, { display: "inline", children: [ 217 " ", 218 "Currently ", 219 user.araId || "Not set" 220 ] }) 221 ] }), 222 /* @__PURE__ */ jsxRuntimeExports.jsx(AdminUserApiKey, { userId }) 223 ] }); 224}; 225export { 226 AdminUserPage as default 227};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.