PageSourceSearch

https://naijabarrister.com/_next/static/chunks/pages/dashboard/admin-6d6c70457dfe6d85.js

js naijabarrister.com collected 2026-10-02 16:03:59 UTC 7,201 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9950],{41169:function(e,r,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/admin",function(){return n(92854)}])},88362:function(e,r,n){"use strict";var t=n(85893),a=(n(67294),n(80471));r.Z=function(){return(0,t.jsx)("div",{className:"py-8 px-4 border border-slate-300 rounded-lg bg-white",children:(0,t.jsx)(a.frZ,{size:"1.5em",className:"animate animate-spin mx-auto"})})}},92854:function(e,r,n){"use strict";n.r(r),n.d(r,{default:function(){return g}});var t=n(85893),a=n(11163),s=n(67294),i=n(80575),o=n(34051),u=n.n(o),c=n(74931),l=n(89583),d=n(88767),f=n(40611),h=n(88362),m=n(4319);function p(e,r,n,t,a,s,i){try{var o=e[s](i),u=o.value}catch(c){return void n(c)}o.done?r(u):Promise.resolve(u).then(t,a)}function x(e){return function(){var r=this,n=arguments;return new Promise((function(t,a){var s=e.apply(r,n);function i(e){p(s,t,a,i,o,"next",e)}function o(e){p(s,t,a,i,o,"throw",e)}i(void 0)}))}}function v(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function b(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},t=Object.keys(n);"function"===typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),t.forEach((function(r){v(e,r,n[r])}))}return e}var j=function(){var e=(0,a.useRouter)(),r=(0,d.useQueryClient)(),n=(0,d.useQuery)("admin.users",x(u().mark((function r(){return u().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,f.Z.get("/api/users/admin-list",{params:b({},e.query)}).then((function(e){return e.data})).catch((function(e){console.log(e)}));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),r)}))),{enabled:e.isReady}),s=n.data,i=n.isLoading,o=(n.isError,(0,d.useMutation)(function(){var e=x(u().mark((function e(r){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f.Z.patch("/api/users/".concat(r.id),{role:r.role}).then((function(e){return e.data})).catch((function(e){console.log(e),c.ZP.error("Error updating user")}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{onMutate:function(){var e=x(u().mark((function e(n){var t;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.cancelQueries("admin.users");case 2:return t=r.getQueryData("admin.users"),console.log(n),r.setQueryData("admin.users",(function(e){return e.map((function(e){if(e.id===n.id){var r=b({},e,{role:n.role});return console.log("Updated: ",r.role),r}return e}))})),e.abrupt("return",{prevData:t});case 6:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),onSettled:function(e){r.invalidateQueries("admin.users"),console.log("Settled: ",e.role),c.ZP.success("User role updated successsfully")},onError:function(e,n,t){r.setQueryData("admin.users",t.prevData)}})),p=function(){var e=x(u().mark((function e(r){var n;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!window.confirm("Are you sure you want to delete ".concat(r.first_name,"'s account? This action CANNOT be undone"))){e.next=15;break}return e.prev=1,e.next=4,f.Z.delete("/api/users/".concat(r.id));case 4:e.sent.data,(n=Array.from(s)).splice(n.indexOf(r),1),setUsers(n),c.ZP.success("User deleted successfully"),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(1),c.ZP.error("Error deleteing user, please try again"),console.log(e.t0);case 15:case"end":return e.stop()}}),e,null,[[1,11]])})));return function(r){return e.apply(this,arguments)}}();return i?(0,t.jsx)(h.Z,{}):(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"pb-4",children:(0,t.jsxs)("form",{action:"",className:"flex space-x-4",children:[(0,t.jsx)("div",{className:"field grow",children:(0,t.jsx)("input",{type:"search",name:"query",placeholder:"Search name or email address...",className:"input",defaultValue:e.query.query})}),(0,t.jsx)("div",{className:"field",children:(0,t.jsxs)("select",{name:"state",className:"input",defaultValue:e.query.state,children:[(0,t.jsx)("option",{value:"",children:"State"}),m&&m.map((function(e){return(0,t.jsx)("option",{value:e,children:e},e)}))]})}),(0,t.jsx)("div",{className:"field",children:(0,t.jsxs)("button",{type:"submit",className:"button primary flex items-center space-x-3",children:[(0,t.jsx)(l.U41,{})," ",(0,t.jsx)("span",{children:"Search"})]})})]})}),s&&s.length>0?(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:"bg-white rounded-md border border-slate-300 overflow-hidden ",children:(0,t.jsxs)("table",{className:"layout-auto w-full",cellPadding:10,
1children:[(0,t.jsx)("thead",{className:"border-b-4 border-slate-300",children:(0,t.jsxs)("tr",{className:"text-left",children:[(0,t.jsx)("th",{children:"#"}),(0,t.jsx)("th",{children:"Name"}),(0,t.jsx)("th",{children:"Email"}),(0,t.jsx)("th",{children:"SCN"}),(0,t.jsx)("th",{className:"text-right",children:"Action"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-slate-300",children:s.map((function(e,r){var n;return(0,t.jsxs)("tr",{className:"hover:bg-red-50 odd:bg-slate-50",children:[(0,t.jsx)("td",{children:r+1}),(0,t.jsx)("td",{children:"".concat(e.first_name," ").concat(e.last_name)}),(0,t.jsx)("td",{children:e.email}),(0,t.jsx)("td",{children:null===e||void 0===e||null===(n=e.supreme_court_number)||void 0===n?void 0:n.toUpperCase()}),(0,t.jsx)("td",{className:"text-right",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3 justify-end",children:[(0,t.jsx)("button",{className:"text-xl hover:scale-105 block transition-all duration-300 group",onClick:function(){return function(e){window.confirm("Are you sure you want to update this user role?")&&(console.log("Current",e.role),o.mutate({id:e.id,role:"admin"===e.role?"user":"admin"}))}(e)},children:"admin"===e.role?(0,t.jsx)(l.QJe,{className:"text-yellow-400 group-hover:text-yellow-600"}):(0,t.jsx)(l.QJe,{className:"text-slate-200 group-hover:text-slate-400"})}),(0,t.jsx)("button",{onClick:function(){return p(e)},className:"p-2 hover:bg-red-400 hover:text-white rounded-lg",children:(0,t.jsx)(l.AMf,{})})]})})]},e.id)}))})]})})}):(0,t.jsx)("div",{className:"p-6 rounded-lg bg-white border border-slate-300",children:"We didn't find any profiles that matches your search query, please try again"})]})},y=n(2282);function g(){var e=(0,y.a)(),r=e.user,n=e.loading,o=(0,a.useRouter)();return(0,s.useEffect)((function(){n||r&&"admin"!==r.role&&o.push("/dashboard")}),[n]),(0,t.jsx)(i.Z,{title:"Admin",children:(0,t.jsx)(j,{})})}},4319:function(e){"use strict";e.exports=JSON.parse('["Abia","Adamawa","Akwa Ibom","Anambra","Bauchi","Bayelsa","Benue","Borno","Cross River","Delta","Ebonyi","Edo","Ekiti","Enugu","FCT - Abuja","Gombe","Imo","Jigawa","Kaduna","Kano","Katsina","Kebbi","Kogi","Kwara","Lagos","Nasarawa","Niger","Ogun","Ondo","Osun","Oyo","Plateau","Rivers","Sokoto","Taraba","Yobe","Zamfara"]')}},function(e){e.O(0,[5445,2013,9866,955,3874,4617,3276,6653,575,9774,2888,179],(function(){return r=41169,e(e.s=r);var r}));var r=e.O();_N_E=r}]);

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.