PageSourceSearch

https://cloud.linkwarden.app/_next/static/chunks/pages/admin/user-administration-dcd21e45d3996b11.js

js linkwarden.app collected 2026-09-24 09:13:02 UTC 14,118 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2836],{8685:(e,s,t)=>{"use strict";t.d(s,{A:()=>m});var a=t(6029),r=t(32764),l=t(35270),n=t(14187),i=t(84007),o=t(55729),d=t(35460),c=t(43003),u=t(36919);function m(e){var s;let{onClose:t,userId:m}=e,{t:x}=(0,n.Bd)(),[h,f]=(0,o.useState)(!1),p=(0,i.iY)(),j=async()=>{h||(f(!0),await p.mutateAsync(m,{onSuccess:()=>{t()},onSettled:(e,s)=>{f(!1)}}))},{data:b}=(0,d.useSession)(),{data:v}=(0,c.UK)(),g=(null==b||null==(s=b.user)?void 0:s.id)===((null==v?void 0:v.ADMIN)||1);return(0,a.jsxs)(r.A,{toggleModal:t,children:[(0,a.jsx)("p",{className:"text-xl font-thin text-red-500",children:x(g?"delete_user":"remove_user")}),(0,a.jsx)(u.w,{className:"my-3"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("p",{children:x("confirm_user_deletion")}),(0,a.jsx)("p",{children:x("confirm_user_removal_desc")}),g&&(0,a.jsxs)("div",{role:"alert",className:"alert alert-warning",children:[(0,a.jsx)("i",{className:"bi-exclamation-triangle text-xl"}),(0,a.jsxs)("span",{children:[(0,a.jsxs)("b",{children:[x("warning"),":"]})," ",x("irreversible_action_warning")]})]}),(0,a.jsxs)(l.$,{className:"ml-auto",variant:"destructive",onClick:j,children:[(0,a.jsx)("i",{className:"bi-trash text-xl"}),x(g?"delete_confirmation":"confirm")]})]})]})}},20667:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});var a=t(6029),r=t(55729);function l(e){let s=0;for(;e;){let t=window.getComputedStyle(e).getPropertyValue("z-index"),a=Number(t);if("auto"!==t&&!isNaN(a)){s=a;break}e=e.parentElement}return s}function n(e){let{children:s,onClickOutside:t,className:n,style:i,onMount:o}=e,d=(0,r.useRef)(null);return(0,r.useEffect)(()=>{function e(e){let s=e.target;if(!s.closest("[data-ignore-click-away]")&&d.current&&!d.current.contains(s)){let a=l(d.current);l(s)<=a&&t(e)}}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[d,t]),(0,r.useEffect)(()=>{d.current&&o&&o(d.current.getBoundingClientRect())},[]),(0,a.jsx)("div",{ref:d,className:n,style:i,children:s})}},32764:(e,s,t)=>{"use strict";t.d(s,{A:()=>c});var a=t(6029),r=t(55729),l=t(56760),n=t(20667),i=t(60087),o=t(67665),d=t(35270);function c(e){let{toggleModal:s,className:t,children:c,dismissible:u=!0,hideCloseButton:m}=e,[x,h]=r.useState(!0),{width:f}=(0,o.A)();return((0,r.useEffect)(()=>{if(f>=640)return document.body.style.overflow="hidden",document.body.style.position="relative",()=>{document.body.style.overflow="auto",document.body.style.position=""}},[]),f<640)?(0,a.jsx)(i._s.Root,{open:x,onClose:()=>u&&h(!1),onAnimationEnd:e=>!e&&s(),dismissible:u,children:(0,a.jsxs)(i._s.Portal,{children:[(0,a.jsx)(i._s.Overlay,{className:"fixed inset-0 bg-black/40 z-40"}),(0,a.jsx)(i._s.Content,{className:"flex flex-col rounded-t-xl h-[90%] mt-24 fixed bottom-0 left-0 right-0 z-50",children:(0,a.jsxs)("div",{className:"p-4 bg-base-100 rounded-t-xl flex-1 border-neutral-content border-t overflow-y-auto","data-testid":"mobile-modal-container",children:[(0,a.jsx)("div",{className:"mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-neutral mb-5","data-testid":"mobile-modal-slider"}),c]})})]})}):l.createPortal((0,a.jsx)("div",{className:"overflow-y-auto pt-2 sm:py-2 fixed top-0 bottom-0 right-0 left-0 bg-black bg-opacity-10 backdrop-blur-sm flex justify-center items-center fade-in z-40","data-testid":"modal-outer",children:(0,a.jsx)(n.A,{onClickOutside:()=>u&&s(),className:"w-full mt-auto sm:m-auto sm:w-11/12 sm:max-w-xl ".concat(t||""),children:(0,a.jsxs)("div",{className:"slide-up mt-auto sm:m-auto relative border-neutral-content rounded-t-xl sm:rounded-xl border-t sm:border shadow-xl p-5 bg-base-100 overflow-y-auto sm:overflow-y-visible","data-testid":"modal-container",children:[u&&!m&&(0,a.jsx)(d.$,{variant:"ghost",size:"icon",onClick:s,className:"absolute top-4 right-3 z-10 rounded-full",children:(0,a.jsx)("i",{className:"bi-x text-neutral text-xl","data-testid":"close-modal-button"})}),c]})})}),document.body)}},46637:(e,s,t)=>{"use strict";t.d(s,{A:()=>o});var a=t(6029),r=t(14187),l=t(57343);function n(e){let{className:s,toggleSidebar:t,sidebarIsCollapsed:n}=e,{t:i}=(0,r.Bd)();return(0,a.jsx)(l.A,{className:s,toggleSidebar:t,sidebarIsCollapsed:n,links:[{title:i("user_administration"),href:"/admin/user-a
1dministration",icon:"bi-people"},{title:i("background_jobs"),href:"/admin/background-jobs",icon:"bi-gear-wide-connected"}]})}t(55729);var i=t(62127);function o(e){let{children:s}=e,{sidebarIsCollapsed:t,toggleSidebar:r}=(0,i.A)();return(0,a.jsxs)("div",{className:"flex","data-testid":"admin-wrapper",children:[(0,a.jsx)(n,{toggleSidebar:r,sidebarIsCollapsed:t}),(0,a.jsx)("div",{className:"".concat(t?"":"lg:w-[calc(100%-288px)]"," w-[calc(100%-56px)] sm:pb-0 pb-20 flex flex-col h-screen overflow-y-auto"),children:(0,a.jsx)("div",{className:"p-5 mx-auto w-full max-w-7xl",children:s})})]})}},57343:(e,s,t)=>{"use strict";t.d(s,{A:()=>x});var a=t(6029),r=t(82203),l=t.n(r),n=t(81278),i=t(55729),o=t(14187),d=t(2871),c=t(1525),u=t(35270),m=t(45933);function x(e){let{links:s,className:t,toggleSidebar:r,sidebarIsCollapsed:x}=e,{t:h}=(0,o.Bd)(),f=(0,n.useRouter)(),[p,j]=(0,i.useState)("");return(0,i.useEffect)(()=>{j(f.asPath)},[f]),(0,a.jsx)(d.A,{className:t,toggleSidebar:r,sidebarIsCollapsed:x,children:e=>{let{collapsed:t}=e,r=(0,a.jsx)("div",{className:(0,m.cn)("flex flex-col gap-2",t&&"gap-3"),children:s.map(e=>(0,a.jsx)(c.A,{title:e.title,href:e.href,icon:e.icon,active:p===e.href,sidebarIsCollapsed:t},e.href))});return(0,a.jsxs)(a.Fragment,{children:[t?(0,a.jsx)("div",{className:"flex flex-col items-center shrink-0",children:(0,a.jsx)(d.M,{icon:"bi-chevron-left",variant:"ghost",label:h("back_to_dashboard"),tooltipSide:"right",onClick:()=>f.push("/dashboard")})}):(0,a.jsx)("div",{className:"shrink-0 pt-1 px-1",children:(0,a.jsx)(u.$,{asChild:!0,size:"sm",variant:"ghost",className:"justify-start w-full h-8",children:(0,a.jsxs)(l(),{href:"/dashboard",children:[(0,a.jsx)("i",{className:"bi-chevron-left text-md"}),(0,a.jsx)("p",{children:h("back_to_dashboard")})]})})}),t?(0,a.jsx)("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center",children:r}):(0,a.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto mt-1 p-1",children:r})]})}})}},63108:(e,s,t)=>{"use strict";t.r(s),t.d(s,{__N_SSP:()=>g,default:()=>N});var a=t(6029),r=t(58578),l=t(32764),n=t(83248),i=t(55729),o=t(14187),d=t(84007),c=t(35270),u=t(36919),m=t(43003);function x(e){let{onClose:s}=e,{t}=(0,o.Bd)(),{data:x}=(0,m.UK)(),h=null==x?void 0:x.EMAIL_PROVIDER,f=(0,d.aM)(),[p,j]=(0,i.useState)({name:"",username:"",email:h?"":void 0,password:""}),[b,v]=(0,i.useState)(!1);async function g(e){if(e.preventDefault(),!b){if(p.password.length<8)return r.Ay.error(t("password_length_error"));(h?""!==p.name&&""!==p.email&&""!==p.password:""!==p.name&&""!==p.username&&""!==p.password)?(v(!0),await f.mutateAsync(p,{onSuccess:()=>{s()},onSettled:()=>{v(!1)}})):r.Ay.error(t("fill_all_fields_error"))}}return(0,a.jsxs)(l.A,{toggleModal:s,children:[(0,a.jsx)("p",{className:"text-xl font-thin",children:t("create_new_user")}),(0,a.jsx)(u.w,{className:"my-3"}),(0,a.jsxs)("form",{onSubmit:g,children:[(0,a.jsxs)("div",{className:"grid sm:grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2",children:t("display_name")}),(0,a.jsx)(n.A,{placeholder:t("placeholder_johnny"),className:"bg-base-200",onChange:e=>j({...p,name:e.target.value}),value:p.name})]}),h&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2",children:t("email")}),(0,a.jsx)(n.A,{placeholder:t("placeholder_email"),className:"bg-base-200",onChange:e=>j({...p,email:e.target.value}),value:p.email})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"mb-2",children:[t("username")," ",h&&(0,a.jsx)("span",{className:"text-xs text-neutral",children:t("optional")})]}),(0,a.jsx)(n.A,{placeholder:t("placeholder_john"),className:"bg-base-200",onChange:e=>j({...p,username:e.target.value}),value:p.username})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"mb-2",children:t("password")}),(0,a.jsx)(n.A,{placeholder:"••••••••••••••",className:"bg-base-200",onChange:e=>j({...p,password:e.target.value}),value:p.password})]})]}),(0,a.jsxs)("div",{role:"note",className:"alert alert-note mt-5",children:[(0,a.jsx)("i",{className:"bi-exclamation-triangle text-xl"}),(0,a.jsx)("span",{children:(0,a.jsx)(o.x6,{i18nKey:"password_change_note",components:[(0,a.jsx)("b",{},0)]})})]}),(0,a.jsx)("div",{className:"flex justify-between items-center mt-5",children:(0,a.jsx)(c.$,{variant:"primary",className:"ml-auto",type:"submit",children:t("create_user")})})]})]})}var h=t(8685);let f=e=>{let{users:s,deleteUserModal:t,setDeleteUserModal:r,t:l}=e,{data:n}=(0,m.UK)();return(0,a.jsxs)("div",{className:"overflow-x-auto whitespace-nowrap w-full",children:[(0,a.jsxs)("table",{className:"table w-full",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{}),(0,a.jsx)("th",{children:l("username")}),(null==n?void 0:n.EMAIL_PROVIDER)&&(0,a.jsx)("th",{children:l("email")}),(null==n?void 0:n.STRIPE_ENABLED)&&(0,a.jsx)("th",{children:l("subscribed")}),(0,a.jsx)("th",{children:l("created_at")}),(0,a.jsx)("th",{})]})}),(0,a.jsx)("tbody",{children:s.map((e,s)=>{var t;return(0,a.jsxs)("tr",{className:"group hover:bg-neutral-content hover:bg-opacity-30 duration-100",children:[(0,a.jsx)("td",{className:"text-primary",children:s+1}),(0,a.jsx)("td",{children:e.username?e.username:(0,a.jsx)("b",{children:l("not_available")})}),(null==n?void 0:n.EMAIL_PROVIDER)&&(0,a.jsx)("td",{children:e.email}),(null==n?void 0:n.STRIPE_ENABLED)&&(0,a.jsx)("td",{children:(null==(t=e.subscriptions)?void 0:t.active)?(0,a.jsx)("i",{className:"bi bi-check text-green-500"}):(0,a.jsx)("i",{className:"bi bi-x text-red-500"})}
1),(0,a.jsx)("td",{children:new Date(e.createdAt).toLocaleString()}),(0,a.jsx)("td",{className:"relative",children:(0,a.jsx)(c.$,{variant:"ghost",size:"icon",className:"hidden group-hover:block hover:text-error absolute z-20 right-[0.35rem] top-[0.35rem]",onClick:()=>r({isOpen:!0,userId:e.id}),children:(0,a.jsx)("i",{className:"bi bi-trash"})})})]},s)})})]}),t.isOpen&&t.userId&&(0,a.jsx)(h.A,{onClose:()=>r({isOpen:!1,userId:null}),userId:t.userId})]})};var p=t(81278),j=t(38544),b=t(46637);let v=()=>{let{t:e}=(0,o.Bd)(),{data:s=[]}=(0,d.kp)(),{data:t}=(0,j.Jd)(),{data:r}=(0,m.UK)(),l=(0,p.useRouter)();(0,i.useEffect)(()=>{r&&t&&(null==t?void 0:t.id)!==((null==r?void 0:r.ADMIN)||1)&&(console.log(r,t),l.replace("/dashboard"))},[r,t]);let[n,h]=(0,i.useState)(""),[b,v]=(0,i.useState)(null),[g,N]=(0,i.useState)({isOpen:!1,userId:null}),[w,y]=(0,i.useState)(!1);return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex sm:flex-row flex-col justify-between gap-2",children:[(0,a.jsx)("div",{className:"gap-2 inline-flex items-center",children:(0,a.jsx)("p",{className:"capitalize text-3xl font-thin inline",children:e("user_administration")})}),(0,a.jsxs)("div",{className:"flex items-center relative justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"search-box",className:"inline-flex items-center w-fit absolute left-1 pointer-events-none rounded-md p-1 text-primary",children:(0,a.jsx)("i",{className:"bi-search"})}),(0,a.jsx)("input",{id:"search-box",type:"text",placeholder:e("search_users"),value:n,onChange:e=>(e=>{h(e),s?v(s.filter(s=>JSON.stringify(s).toLowerCase().includes(e.toLowerCase()))):v(null)})(e.target.value),className:"border border-neutral-content bg-base-200 focus:border-primary py-1 rounded-md pl-9 pr-2 w-full max-w-[15rem] md:w-[15rem] md:max-w-full duration-200 outline-none"})]}),(0,a.jsx)(c.$,{onClick:()=>y(!0),variant:"primary",size:"icon",className:"flex items-center px-2 aspect-square relative",children:(0,a.jsx)("i",{className:"bi-plus text-3xl absolute"})})]})]}),(0,a.jsx)(u.w,{className:"my-3"}),n&&b&&b.length>0?(0,a.jsx)(f,{users:b,deleteUserModal:g,setDeleteUserModal:N,t:e}):n?(0,a.jsx)("p",{children:e("no_user_found_in_search")}):s&&s.length>0?(0,a.jsx)(f,{users:s,deleteUserModal:g,setDeleteUserModal:N,t:e}):(0,a.jsx)("p",{children:e("no_users_found")}),w&&(0,a.jsx)(x,{onClose:()=>y(!1)})]})};v.getLayout=function(e){return(0,a.jsx)(b.A,{children:e})};var g=!0;let N=v},77525:(e,s,t)=>
1{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/user-administration",function(){return t(63108)}])},83248:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});var a=t(6029),r=t(23994);let l=(0,t(55729).forwardRef)((e,s)=>{let{className:t,type:l="text",...n}=e;return(0,a.jsx)("input",{ref:s,type:l,className:(0,r.cn)("w-full rounded-md p-2 border-neutral-content border-solid border outline-none focus:border-primary duration-100",t),...n})});l.displayName="TextInput";let n=l},84007:(e,s,t)=>{"use strict";t.d(s,{aM:()=>c,iY:()=>u,kp:()=>d});var a=t(12482),r=t(93251),l=t(16932),n=t(58578),i=t(14187),o=t(35460);let d=()=>{let{status:e}=(0,o.useSession)();return(0,a.I)({queryKey:["users"],queryFn:async()=>{let e=await fetch("/api/v1/users");if(!e.ok)throw Error("Failed to fetch users.");return(await e.json()).response},enabled:"authenticated"===e})},c=()=>{let e=(0,r.jE)(),{t:s}=(0,i.Bd)();return(0,l.n)({mutationFn:async e=>{let t=n.Ay.loading(s("creating_account")),a=await fetch("/api/v1/users",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}}),r=await a.json();if(!a.ok)throw Error(r.response);return n.Ay.dismiss(t),r.response},onSuccess:t=>{e.setQueryData(["users"],e=>[...e,t]),n.Ay.success(s("user_created"))},onError:e=>{n.Ay.error(e.message)}})},u=()=>{let e=(0,r.jE)(),{t:s}=(0,i.Bd)();return(0,l.n)({mutationFn:async e=>{let t=n.Ay.loading(s("deleting_user")),a=await fetch("/api/v1/users/".concat(e),{method:"DELETE"}),r=await a.json();if(!a.ok)throw Error(r.response);return n.Ay.dismiss(t),r.response},onSuccess:(t,a)=>{e.setQueryData(["users"],e=>e.filter(e=>e.id!==a)),n.Ay.success(s("user_deleted"))},onError:e=>{n.Ay.error(e.message)}})}}},e=>{e.O(0,[8986,2203,3458,7129,7113,87,5051,636,6593,8792],()=>e(e.s=77525)),_N_E=e.O()}]);

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.