Files
ambersplace.net/cohost-archive/static/client-preact-components-pages-moderation-bulk-activate.1c2204147bb871923837.js

2 lines
7.9 KiB
JavaScript

"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[3701],{2735:function(e,t,r){r.d(t,{Qj:function(){return j},zx:function(){return N}});var n=r(65443),a=r.n(n),l=r(94159),o=r(6285);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}const s=o.z.enum(["pill","roundrect","authn"]),u=o.z.enum(["cherry","strawberry","mango","not-black","red","green","accent","secondary","authn-primary","authn-other"]),i=(o.z.object({buttonStyle:s,color:u,className:o.z.string().optional()}),a()("bg-notWhite","hover:text-notWhite")),d=a()("font-atkinson","font-bold","rounded-full","border-2"),m=a()("body-2","rounded-lg"),b=a()("flex","h-12","items-center","justify-center","rounded-lg","px-6","text-lg"),h=a()("border-cherry","hover:bg-cherry","text-cherry","active:bg-cherry-600","active:border-cherry-600","disabled:text-cherry-300","disabled:border-cherry-300","focus:outline-cherry","focus:ring-cherry",i),g=a()("border-strawberry","hover:bg-strawberry","text-strawberry","active:bg-strawberry-600","active:border-strawberry-600","disabled:text-strawberry-300","disabled:border-strawberry-300","focus:outline-strawberry","focus:ring-strawberry",i),f=a()("border-red","hover:bg-red","text-red","active:bg-red-600","active:border-red-600","disabled:text-red-300","disabled:border-red-300","focus:outline-red",i),y=a()("border-green","hover:bg-green","text-green","active:bg-green-600","active:border-green-600","disabled:text-green-300","disabled:border-green-300","focus:outline-green",i),p=a()("border-mango","hover:bg-mango","text-mango","bg-notBlack","hover:text-notBlack"),v=a()("border-notBlack","hover:bg-notBlack","text-notBlack","focus:outline-notBlack","focus:ring-notBlack",i),E=a()("border-accent","text-accent","bg-foreground","hover:bg-accent","hover:text-text"),x=a()("bg-secondary","text-notWhite","dark:text-notBlack","hover:bg-secondary-600"),k=a()("bg-foreground","text-text","hover:bg-foreground-600","active:bg-foreground-700","disabled:bg-foreground-200"),w=a()("border-2","border-foreground","text-foreground","hover:bg-longan-200"),S=e=>a()("leading-none","align-middle","py-2","px-4","no-select",e.className,{[d]:"pill"===e.buttonStyle,[m]:"roundrect"===e.buttonStyle,[b]:"authn"===e.buttonStyle,[h]:"cherry"===e.color,[g]:"strawberry"===e.color,[p]:"mango"===e.color,[v]:"not-black"===e.color,[f]:"red"===e.color,[E]:"accent"===e.color,[y]:"green"===e.color,[x]:"secondary"===e.color,[k]:"authn-primary"===e.color,[w]:"authn-other"===e.color}),N=l.forwardRef((({buttonStyle:e,color:t,className:r,...n},a)=>{const o=S({buttonStyle:e,color:t,className:r,...n});return l.createElement("button",c({},n,{className:o,ref:a}),n.children)}));N.displayName="Button";const j=l.forwardRef((({buttonStyle:e,color:t,...r},n)=>{const a=S({buttonStyle:e,color:t,...r});return l.createElement("a",c({},r,{className:a,ref:n}),r.children)}));j.displayName="LinkButton"},27028:function(e,t,r){r.r(t);var n=r(12093),a=r(46202),l=r(84879),o=r(94159),c=r(90275),s=r(6553),u=r(58397),i=r(2735),d=r(71860),m=r(81150),b=r(99838);function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h.apply(this,arguments)}const g=()=>{const e=d.S.moderation.user.unactivatedUsers.useInfiniteQuery({limit:50},{suspense:!0,getNextPageParam:e=>e.nextCursor}),t=d.S.moderation.user.activateMany.useMutation(),r=d.S.moderation.user.banMany.useMutation(),{register:a,handleSubmit:l,watch:c}=(0,b.cI)(),s=c("users",[]);let u=!1;for(const e of s)if(e?.selected){u=!0;break}const m=(0,o.useCallback)((async e=>{const r=e.users.map(((e,t)=>({userId:t,selected:e.selected}))).filter((e=>e.selected)).map((e=>e.userId));await t.mutateAsync({userIds:r}),location.reload()}),[t]),g=(0,o.useCallback)((async e=>{const t=e.users.map(((e,t)=>({userId:t,selected:e.selected}))).filter((e=>e.selected)).map((e=>e.userId));await r.mutateAsync({userIds:t,reason:e.banReason}),location.reload()}),[r]);return o.createElement(o.Fragment,null,o.createElement("table",null,o.createElement("thead",null,o.createElement("tr",null,o.createElement("th",null,"select"),o.createElement("th",null,"e-mail"),o.createElement("th",null,"self-project handle"),o.createElement("th",null,"actions"))),o.createElement("tbody",null,e.data?.pages.map((e=>e.users.map((e=>o.createElement("tr",{key:e.userId},o.createElement("td",null,o.createElement("input",h({type:"checkbox"},a(`users.${e.userId}.selected`)))),o.createElement("td",null,e.email),o.createElement("td",null,e.selfProject.handle),o.createElement("td",null,o.createElement("ul",null,o.createElement("li",null,o.createElement("a",{href:n.ZP.public.moderation.manageUser({userId:e.userId}).toString()},"manage user")),o.createElement("li",null,o.createElement("a",{href:n.ZP.public.moderation.manageProject({projectHandle:e.selfProject.handle}).toString()},"manage project"))))))))))),e.hasNextPage&&o.createElement(i.zx,{buttonStyle:"authn",color:"authn-other",onClick:()=>e.fetchNextPage(),disabled:e.isFetchingNextPage},"load more"),o.createElement(i.zx,{buttonStyle:"authn",color:"authn-other",disabled:!u,onClick:l(m)},"activate selected users"),o.createElement("div",{className:"mt-3 flex max-w-fit flex-col gap-2 rounded-lg border border-accent p-3"},o.createElement("label",null,"reason for banning users:"),o.createElement("textarea",a("banReason")),o.createElement(i.zx,{buttonStyle:"authn",color:"authn-other",disabled:!u,onClick:l(g)},"ban selected users")))};t.default=({numUnactivated:e,numUnactivatable:t,mostRecentInviteDate:r})=>{const b=(0,o.useId)(),h=d.S.useContext();return(0,o.useEffect)((()=>{h.moderation.user.unactivatedUsers.prefetchInfinite({limit:50})}),[h.moderation.user.unactivatedUsers]),o.createElement(o.Fragment,null,o.createElement(c.ql,{title:"bulk activate"}),o.createElement("div",null,o.createElement("h1",null,"Bulk user activation"),o.createElement("a",{href:n.ZP.public.moderation.home().toString()},o.createElement(a.Z,{className:"inline h-6 w-6"}),"back to moderation home"),o.createElement("p",null,"There are currently ",e," unactivated users. (",t," without verified email)"),o.createElement("p",null,"Last invite generated"," ",l.ou.fromISO(r).toRelative({style:"long"})),o.createElement("form",{method:"post",className:"my-3 flex flex-col gap-3 rounded-lg border border-accent p-3"},o.createElement("input",{type:"hidden",value:0,name:"numToActivate"}),o.createElement(s.p,{as:"button",type:"submit"},"activate all users")),o.createElement("form",{method:"post",className:"my-3 flex flex-col gap-3 rounded-lg border border-accent p-3"},o.createElement("fieldset",{className:"flex flex-col gap-1"},o.createElement("label",{htmlFor:`${b}:numToActivate`},"number to activate"),o.createElement("input",{type:"number",min:1,max:Math.min(e,999),step:1,id:`${b}:numToActivate`,name:"numToActivate",defaultValue:Math.min(e,999)})),o.createElement(s.p,{as:"button",type:"submit"},"activate users"))),o.createElement("hr",null),o.createElement("div",null,o.createElement(u.p,null,o.createElement(u.p.Button,{as:i.zx,buttonStyle:"authn",color:"authn-primary"},"show unactivated users"),o.createElement(u.p.Panel,null,o.createElement(o.Suspense,{fallback:o.createElement(m.g,null)},o.createElement(g,null))))))}},46202:function(e,t,r){var n=r(94159);const a=n.forwardRef((function({title:e,titleId:t,...r},a){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",ref:a,"aria-labelledby":t},r),e?n.createElement("title",{id:t},e):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"}))}));t.Z=a}}]);
//# sourceMappingURL=client-preact-components-pages-moderation-bulk-activate.1c2204147bb871923837.js.map