2 lines
8.6 KiB
JavaScript
2 lines
8.6 KiB
JavaScript
"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[8508,9629],{2735:function(e,t,o){o.d(t,{Qj:function(){return I},zx:function(){return k}});var r=o(65443),l=o.n(r),n=o(94159),a=o(6285);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},c.apply(this,arguments)}const s=a.z.enum(["pill","roundrect","authn"]),i=a.z.enum(["cherry","strawberry","mango","not-black","red","green","accent","secondary","authn-primary","authn-other"]),d=(a.z.object({buttonStyle:s,color:i,className:a.z.string().optional()}),l()("bg-notWhite","hover:text-notWhite")),u=l()("font-atkinson","font-bold","rounded-full","border-2"),g=l()("body-2","rounded-lg"),b=l()("flex","h-12","items-center","justify-center","rounded-lg","px-6","text-lg"),p=l()("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",d),f=l()("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",d),m=l()("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",d),w=l()("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",d),h=l()("border-mango","hover:bg-mango","text-mango","bg-notBlack","hover:text-notBlack"),y=l()("border-notBlack","hover:bg-notBlack","text-notBlack","focus:outline-notBlack","focus:ring-notBlack",d),j=l()("border-accent","text-accent","bg-foreground","hover:bg-accent","hover:text-text"),x=l()("bg-secondary","text-notWhite","dark:text-notBlack","hover:bg-secondary-600"),v=l()("bg-foreground","text-text","hover:bg-foreground-600","active:bg-foreground-700","disabled:bg-foreground-200"),S=l()("border-2","border-foreground","text-foreground","hover:bg-longan-200"),E=e=>l()("leading-none","align-middle","py-2","px-4","no-select",e.className,{[u]:"pill"===e.buttonStyle,[g]:"roundrect"===e.buttonStyle,[b]:"authn"===e.buttonStyle,[p]:"cherry"===e.color,[f]:"strawberry"===e.color,[h]:"mango"===e.color,[y]:"not-black"===e.color,[m]:"red"===e.color,[j]:"accent"===e.color,[w]:"green"===e.color,[x]:"secondary"===e.color,[v]:"authn-primary"===e.color,[S]:"authn-other"===e.color}),k=n.forwardRef((({buttonStyle:e,color:t,className:o,...r},l)=>{const a=E({buttonStyle:e,color:t,className:o,...r});return n.createElement("button",c({},r,{className:a,ref:l}),r.children)}));k.displayName="Button";const I=n.forwardRef((({buttonStyle:e,color:t,...o},r)=>{const l=E({buttonStyle:e,color:t,...o});return n.createElement("a",c({},o,{className:l,ref:r}),o.children)}));I.displayName="LinkButton"},81511:function(e,t,o){o.r(t),o.d(t,{FollowRequestsContext:function(){return r}});const r=(0,o(94159).createContext)({onAction:()=>{}})},55143:function(e,t,o){o.r(t),o.d(t,{ProjectListPage:function(){return c}});var r=o(94159),l=o(6553),n=o(80752),a=o(20616);const c=({projects:e,headerLabel:t,emptyLabel:o,loadMore:c,isLastPage:s})=>r.createElement("div",{className:"container mx-auto mb-16 mt-16 grid w-full grid-cols-1 gap-16 lg:grid-cols-4"},r.createElement(a.w3,null),r.createElement("div",{"data-theme":"light",className:"co-themed-box cohost-shadow-light dark:cohost-shadow-dark col-span-2 mx-auto w-full max-w-prose rounded-lg bg-notWhite p-3 text-notBlack"},r.createElement("h1",{className:"text-2xl font-bold"},t),r.createElement("div",{className:"mt-6 flex flex-col gap-4"},e.length?e.map((e=>r.createElement(n.t,{key:e.projectId,project:e}))):r.createElement("p",null,o)),c?r.createElement(l.p,{disabled:s,onClick:c,className:"mt-8"},"load more"):null));t.default=c},64499:function(e,t,o){o.d(t,{e:function(){return p}});var r=o(71860),l=o(70769),n=o(6285);let a=function(e){return e[e.NotFollowing=0]="NotFollowing",e[e.FollowRequested=1]="FollowRequested",e[e.Following=2]="Following",e}({});n.z.nativeEnum(a);var c=o(94159),s=o(51028),i=o(8227),d=o(2735),u=o(12093),g=o(21281),b=o(91045);const p=e=>c.createElement(c.Suspense,null,c.createElement(f,e)),f=({project:e,onFollow:t,color:o})=>{const n=(0,i.Pc)(),p=r.S.useContext(),f=r.S.projects.followingState.useQuery({projectHandle:e.handle},{suspense:!0}),m=(0,g.Z3)().get("ssrUrl"),w=(0,c.useCallback)((o=>({onMutate:async()=>{await p.projects.followingState.cancel({projectHandle:e.handle});const t=p.projects.followingState.getData({projectHandle:e.handle});return p.projects.followingState.setData({projectHandle:e.handle},{readerToProject:o}),{previousState:t}},onError:(t,o,r)=>{p.projects.followingState.setData({projectHandle:e.handle},r?.previousState)},onSettled:async()=>{await p.projects.followingState.invalidate({projectHandle:e.handle})},onSuccess:e=>{t&&t(e.followingState)}})),[t,e.handle,p.projects.followingState]),h=r.S.relationships.createFollowRequest.useMutation({...w(e.privacy===l.WL.Private?a.FollowRequested:a.Following)}),y=r.S.relationships.unfollow.useMutation({...w(a.NotFollowing)}),j=r.S.relationships.declineOrCancelFollowRequest.useMutation({...w(a.NotFollowing)}),{t:x}=(0,s.$G)(),v=f.data?.readerToProject??null,[S,E]=(0,c.useState)(!1),k=(0,c.useCallback)((async()=>{if(!n.projectId)return;const t={fromProjectId:n.projectId,toProjectId:e.projectId};switch(v){case a.FollowRequested:await j.mutateAsync(t);break;case a.NotFollowing:await h.mutateAsync(t);break;case a.Following:E(!0);break;case null:return}}),[j,h,v,e.projectId,n.projectId]),I=(0,c.useCallback)((async()=>{if(!n.projectId)return;const t={fromProjectId:n.projectId,toProjectId:e.projectId};await y.mutateAsync(t),E(!1)}),[e.projectId,n.projectId,y]);let F="unknown";if(n.loggedIn)if(v===a.Following)F=x("client:page.unfollow-button","unfollow");else if(v===a.NotFollowing)F=e.privacy===l.WL.Private?x("client:page.follow-request-button","send follow request"):x("client:page.follow-button","follow");else{if(v!==a.FollowRequested)return null;F=x("client:page.cancel-follow-request-button","cancel follow request")}else F=x("common:login");return n.loggedIn?c.createElement(c.Fragment,null,c.createElement(b.w,{isOpen:S,title:x("client:unfollow-page.confirm-title","Unfollow this page?"),body:x("client:unfollow-page.confirm-body","Are you sure you want to unfollow this page?"),confirm:{label:x("common:unfollow","unfollow")},cancel:{label:x("common:cancel","cancel")},onConfirm:I,onCancel:()=>E(!1)}),c.createElement(d.zx,{buttonStyle:"pill",color:o,onClick:k},F)):c.createElement(d.Qj,{buttonStyle:"pill",color:o,href:u.ZP.public.login({originalUrl:m}).toString()},F)}},80752:function(e,t,o){o.d(t,{t:function(){return b}});var r=o(94159),l=o(83052),n=o(64499),a=o(71860),c=o(81511),s=o(51028),i=o(8227),d=o(2735);const u=({requester:e})=>{const{t:t}=(0,s.$G)(),o=(0,i.Pc)(),{onAction:l}=(0,r.useContext)(c.FollowRequestsContext),n=a.S.useContext(),u=t=>({onSettled:async()=>{l(e.projectId,t),await n.relationships.countFollowRequests.invalidate(),await n.posts.profilePosts.invalidate()}}),g=a.S.relationships.acceptFollowRequest.useMutation(u("accept")),b=(0,r.useCallback)((async()=>{o.projectId&&await g.mutateAsync({fromProjectId:e.projectId,toProjectId:o.projectId})}),[g,e.projectId,o.projectId]),p=a.S.relationships.declineOrCancelFollowRequest.useMutation(u("decline")),f=(0,r.useCallback)((async()=>{o.projectId&&await p.mutateAsync({fromProjectId:e.projectId,toProjectId:o.projectId})}),[p,e.projectId,o.projectId]);return r.createElement("div",{className:"flex flex-row justify-center gap-2"},r.createElement(d.zx,{buttonStyle:"pill",color:"green",onClick:b},t("server:relationships.accept-follow-request-button-text-short","accept")),r.createElement(d.zx,{buttonStyle:"pill",color:"red",onClick:f},t("server:relationships.decline-follow-request-button-text-short","decline")))};var g=o(51540);const b=({project:e,isFollowRequest:t=!1})=>r.createElement("div",{className:"flex flex-row items-center gap-1"},r.createElement(g.t,{project:e}),r.createElement("div",{className:"min-w-0 flex-shrink justify-center gap-0 lg:flex-row"},r.createElement("div",{className:"items-left flex flex-shrink flex-row gap-1 lg:flex-col"},r.createElement(l.H,{project:e})),r.createElement("p",null,e.dek)),r.createElement("div",{className:"flex-grow"}),t?r.createElement(u,{requester:e}):r.createElement(n.e,{project:e,color:"cherry"}))}}]);
|
|
//# sourceMappingURL=client-preact-components-pages-project-list.71fa87dbf0e911270dd9.js.map
|