2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[954],{70575:function(e,t,a){a.d(t,{H:function(){return n},h:function(){return r}});var l=a(94159);const n=l.createContext({adultFilterMode:"hide",isAdult:!1,categories:new Set,setAdultFilterMode:()=>{},categoryMatch:"any",setCategoryMatch:()=>{},sortOrder:"random",setSortOrder:()=>{}}),r=()=>(0,l.useContext)(n)},26225:function(e,t,a){a.d(t,{l:function(){return v}});var l=a(37111),n=a(76051),r=a(12093),s=a(94159),o=a(98074),c=a(62745),i=a(50196),m=a(46975),u=a(47071),d=a(51540),g=a(70575),p=a(55875),h=a(2403),b=a(96332),f=a(93410),y=a(44144);const x=({attachment:e})=>{const t=(0,c.Q)(),[a,l]=(0,s.useState)(t.gifsStartPaused?e.previewURL:e.fileURL),[n,r]=(0,s.useState)(!t.gifsStartPaused),o=(0,i.T)(a,300,1.2);return s.createElement("div",{className:"group relative"},s.createElement("img",{src:o(1),srcSet:`\n ${o(1)} 1x,\n ${o(2)} 2x,\n ${o(3)} 3x,\n `,alt:e.altText,className:"co-border aspect-[300/250] w-full border-b object-cover"}),e.previewURL!==e.fileURL&&s.createElement(u.I,{isPlaying:n,showPlay:e.previewURL!==e.fileURL,extraClasses:"absolute bottom-3 right-3 w-12",onPlay:()=>{r(!0),l(e.fileURL)},onPause:()=>{r(!1),l(e.previewURL)}}))},E=({listing:e})=>{const t=(0,s.useContext)(y.j);return s.createElement(p.v,{as:"div",className:"relative h-6"},s.createElement(p.v.Button,{className:"co-action-button cursor-pointer text-sm font-bold hover:underline"},s.createElement(b.Z,{className:"h-6 w-6 transition-transform ui-open:rotate-90"})),s.createElement(p.v.Items,{className:"co-meatball-items absolute right-0 top-8 z-30 flex min-w-max flex-col divide-y rounded-lg p-3 focus:!outline-none"},s.createElement(p.v.Item,null,s.createElement(f.X,{disabled:!1,onClick:()=>{t.send({type:"START_REPORT",artistAlleyListingId:e.id})},ItemIcon:h.Z,text:"report"}))))},v=({listing:e,project:t})=>{const a=(0,s.useMemo)((()=>(0,l.Ml)(e.body,new Date,{disableEmbeds:!0,externalLinksInNewTab:!0,hasCohostPlus:!1,renderingContext:"artistAlley"})),[e.body]),n=(0,o.rA)();return s.createElement("div",{"data-theme":n.current,className:"co-themed-box co-artist-alley-listing flex w-full flex-col rounded-lg border"},s.createElement("div",{className:"co-border flex flex-row items-center gap-2 border-b px-2 py-3"},s.createElement(d.t,{project:t,className:"h-8"}),s.createElement("a",{href:r.ZP.public.project.mainAppProfile({projectHandle:t.handle}).toString()},"@",t.handle),s.createElement("div",{className:"flex-1"}," "),e.adultContent?s.createElement("span",{className:"co-18-plus rounded-lg p-1 text-xs "},"18+"):null,s.createElement(E,{listing:e})),e.attachment&&s.createElement(x,{attachment:e.attachment}),s.createElement("div",{className:"co-prose prose p-2"},a),s.createElement("div",{className:"mx-2 my-3"},s.createElement(m.k,{as:"a",buttonColor:"",buttonSize:"regular",href:e.cta.link,extraClasses:"co-cta-button",target:"_blank"},e.cta.text)),e.categories.length>0&&s.createElement(w,{tags:e.categories}))},w=({tags:e})=>{const{categories:t}=(0,g.h)(),a=e.filter((e=>""!=e));return a.length?s.createElement("div",{className:"w-full max-w-full p-3"},s.createElement("div",{className:n.tw`co-tags relative w-full overflow-y-hidden break-words leading-none`},s.createElement("div",null,a.map((e=>s.createElement("button",{key:e,className:"mr-2 inline-block text-sm hover:underline "+(t.has(e)?"font-bold":""),onClick:()=>{t.has(e)?t.delete(e):t.add(e)}},"#",e)))))):null}},72228:function(e,t,a){a.d(t,{F:function(){return m}});var l=a(97244),n=a(34377),r=a(65443),s=a.n(r),o=a(94159),c=a(99838);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e},i.apply(this,arguments)}const m=({style:e="light",showValidity:t=!0,name:a,control:r,rules:m,trigger:u,...d})=>{const{field:g,fieldState:p}=(0,c.bc)({name:a,control:r,rules:m}),{name:h,onChange:b}=g,[f,y]=(0,o.useState)();(0,o.useEffect)((()=>{g.ref(f)}),[f,g]);const{inputStyleClasses:x,contentDivStyleClasses:E,validityIconStyleClasses:v}=(0,o.useMemo)((()=>{switch(e){case"light":return{inputStyleClasses:"border-gray-600 text-notBlack\n placeholder:text-gray-600\n focus:border-notBlack disabled:border-gray-300",contentDivStyleClasses:"to-notWhite",validityIconStyleClasses:"bg-notWhite"};case"dynamic":return{inputStyleClasses:"co-styled-input",contentDivStyleClasses:"co-styled-input-content",validityIconStyleClasses:"co-styled-input-validity-icon"};default:return{inputStyleClasses:"border-gray-400 text-notWhite \n placeholder:text-gray-400\n focus:border-notWhite read-only:bg-gray-700",contentDivStyleClasses:"to-notBlack",validityIconStyleClasses:"bg-notBlack"}}}),[e]);return(0,o.useEffect)((()=>{f&&f.value&&f.value!==d.defaultValue&&f.value!==g.value&&!p.isTouched&&(b(f.value),u(h,{shouldFocus:!0}))}),[f,g.value,h,p.isTouched,b,d.defaultValue,u]),o.createElement("div",{className:"relative"},o.createElement("input",i({className:s()("\n w-full min-w-[15rem] rounded-lg border-2 bg-transparent\n ",x)},d,g,{ref:y})),t&&!d.readOnly&&p.isTouched?o.createElement(o.Fragment,null,o.createElement("div",{className:s()("\n absolute bottom-0 right-9 top-0 my-auto h-6 w-3 \n bg-gradient-to-r from-transparent\n ",E)}),p.invalid?o.createElement(l.Z,{className:s()("\n absolute bottom-0 right-3 top-0 my-auto h-6 \n w-6 text-red\n ",v)}):o.createElement(n.Z,{className:s()("\n absolute bottom-0 right-3 top-0 my-auto h-6\n w-6 bg-notWhite text-green\n ",v)})):null)}},37439:function(e,t,a){a.d(t,{l:function(){return o}});var l=a(76051),n=a(73969),r=a(94159),s=a(99838);const o=({options:e,...t})=>{const{field:a}=(0,s.bc)(t),o=a.value;return r.createElement("div",{className:"flex flex-row flex-wrap gap-2 px-3 py-2"},e.map((e=>r.createElement("div",{key:`selected-token-${e}`,className:"group h-max cursor-pointer select-none"},r.createElement("button",{className:l.tw`co-token flex items-center justify-start gap-1 rounded-lg px-2 py-1 leading-none ${o.includes(e)?"co-active":""}`,onClick:t=>{t.stopPropagation(),o.includes(e)?a.onChange(o.filter((t=>t!==e))):a.onChange([...o,e])},type:"button"},r.createElement(n.Z,{className:"inline-block h-3.5"}),r.createElement("span",{className:"block"},e))))))}},72764:function(e,t,a){a.r(t),a.d(t,{ArtistAlleyCreatePage:function(){return j}});var l=a(71860),n=a(38934),r=a(98074),s=a(40196),o=a(8227),c=a(12093),i=a(89109),m=a(95365),u=a(54485),d=a(49706),g=a(86036),p=a.n(g),h=a(84818),b=a.n(h),f=a(94159),y=a(90275),x=a(99838),E=a(6285),v=a(26225),w=a(51412),N=a(70496),k=a(72228),C=a(37439),S=a(4337),L=a(91884),F=a(86379),A=a(20616);function T(){return T=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e},T.apply(this,arguments)}const R=({label:e,children:t,smallLabel:a})=>f.createElement("label",{className:"flex flex-col gap-1"},f.createElement("span",{className:"font-bold"},e),t,a?f.createElement("span",{className:"text-sm"},a):null),j=()=>{(0,o.if)();const e=l.S.artistAlley.createListing.useMutation(),{control:t,register:a,handleSubmit:g,trigger:h,watch:j,setValue:D,setError:O,formState:U,clearErrors:I,getValues:P}=(0,x.cI)({defaultValues:{adult:!1,body:"",ctaLink:"",ctaText:"",attachmentFiles:void 0,attachmentAltText:"",categories:[],notes:"",numWeeks:"1"}}),[_]=l.S.artistAlley.getCategories.useSuspenseQuery(),q=j("body").length,W=(0,f.useCallback)((async t=>{let a;if(t.attachmentFiles&&t.attachmentFiles[0]){console.log(t.attachmentFiles);const e=t.attachmentFiles[0];a={filename:e.name,contentLength:e.size,contentType:e.type,altText:t.attachmentAltText??""}}const l=await e.mutateAsync({body:t.body,adult:t.adult,cta:{text:t.ctaText,link:t.ctaLink},categories:t.categories,numWeeks:parseInt(t.numWeeks),attachment:a,notes:t.notes});if(l.attachmentDetails&&t.attachmentFiles){const e=t.attachmentFiles[0],a=new FormData;for(const e in l.attachmentDetails.requiredFields)a.append(e,l.attachmentDetails.requiredFields[e]);a.append("file",e),a.append("Content-Type",e.type),await p().post(l.attachmentDetails.url,a,{withCredentials:!1})}window.location.href=l.stripeRedirectUrl}),[e]),M=j("attachmentFiles")?.[0],V=(0,n.dg)(),Z=M?URL.createObjectURL(M):"",z={adultContent:j("adult",!1),attachment:M?{altText:j("attachmentAltText")??"",fileURL:Z,previewURL:Z}:null,body:j("body"),categories:j("categories"),createdAt:(new Date).toISOString(),cta:{link:j("ctaLink"),text:j("ctaText")},expiresAt:(new Date).toISOString(),projectId:V.projectId,id:i.y1.parse("1")},B=(0,r.rA)(),$=(0,s.N)(),H=(0,n._c)()?$.limits.attachmentSize.cohostPlus:$.limits.attachmentSize.normal,Q=(0,f.useCallback)((e=>{if(void 0===e)return!0;if(console.log(e),!e.length)return!0;if(e.length>1)return"You can only choose one image!";if(e[0].size>H)return`image must be less than ${Math.round(H/1024/1024)}mb!`;const t=(0,m.Of)($,e[0].type);return!(!t.valid||"image"!==t.kind)||"must be an image!"}),[H,$]),K=(0,f.useCallback)((e=>{const t=Q(e);!0===t?(I("attachmentFiles"),D("attachmentFiles",e)):O("attachmentFiles",{message:t,type:"custom"})}),[I,O,D,Q]);return f.createElement("div",{className:"container mx-auto mt-12 grid grid-cols-1 gap-16 lg:grid-cols-4"},f.createElement(y.ql,{title:"create a listing - artist alley"}),f.createElement(A.w3,null),f.createElement(F.Z,null,f.createElement(w.r,{handleFileDrop:K,className:"col-span-1 lg:col-span-2"},f.createElement("div",{className:"co-themed-box co-settings flex flex-col gap-3 rounded-lg p-3","data-theme":B.current},f.createElement("h1",{className:"co-settings-header"},"create a listing"),f.createElement(N.v,{level:"post-box-info"},f.createElement("div",{className:"co-prose prose prose-sm"},f.createElement("p",null,"artist alley listings are subject to the"," ",f.createElement("a",{href:c.vf.public.staticContent({slug:"community-guidelines"}).toString()},"standard cohost community guidelines"),", as well as"," ",f.createElement("a",{href:"https://help.antisoftware.club/support/solutions/articles/62000231419-artist-alley-community-guidelines"},"an additional set specific to listings"),"."))),f.createElement("form",{onSubmit:g(W),className:"flex flex-col gap-3"},f.createElement(R,{label:"listing image",smallLabel:f.createElement(f.Fragment,null,"not required, but definitely recommended. this will be displayed at a resolution of 300x250. for best results on high-density screens, we recommend your image be at least 600x500.")},f.createElement(x.Qr,{control:t,name:"attachmentFiles",render:({field:e,fieldState:t})=>f.createElement(L.G,{onFilesPicked:t=>{const a=Q(Array.from(t));!0===a?(I("attachmentFiles"),e.onChange(t)):O("attachmentFiles",{message:a,type:"custom"})}},f.createElement("button",{type:"button",className:"co-filled-button flex w-max flex-row items-center gap-1 rounded-lg px-3 py-2.5"},f.createElement(d.Z,{className:"inline-block h-5 w-5"}),M?"replace image":"choose image"))}),M?f.createElement("button",{type:"button",className:"underline",onClick:e=>{D("attachmentFiles",void 0),D("attachmentAltText",void 0),I(["attachmentFiles","attachmentAltText"]),e.preventDefault()}},"remove image"):null,U.errors.attachmentFiles&&f.createElement("span",{className:"text-red"},U.errors.attachmentFiles?.message)),M?f.createElement(R,{label:"alt text",smallLabel:"required if you're uploading an image"},f.createElement(k.F,{control:t,name:"attachmentAltText",trigger:h,type:"text",style:"dynamic",placeholder:"it's a picture of eggbug",rules:{validate:{required:e=>!(!e&&P("attachmentFiles")?.length)||"alt text is required"}}}),U.errors.attachmentAltText&&f.createElement("span",{className:"text-red"},U.errors.attachmentAltText?.message)):null,f.createElement("hr",null),f.createElement(R,{label:"body"},f.createElement("div",{className:"flex flex-row items-start"},f.createElement(S.V,{control:t,name:"body",minRows:4,autoComplete:"off",placeholder:"body goes here",className:"co-styled-input rounded-lg border-2",rules:{maxLength:{message:"must be under 280 characters",value:280},required:{message:"required",value:!0}}}),q>=210?f.createElement("span",{className:"flex-shrink-0 p-2 tabular-nums "+(q>280?"text-red":"text-gray-600")},280-q):null),U.errors.body&&f.createElement("span",{className:"text-red"},U.errors.body?.message),f.createElement(N.v,{level:"post-box-info"},"supports most markdown! does not support HTML, headers, or images. max 280 characters.")),f.createElement("hr",null),f.createElement(R,{label:"button text",smallLabel:"35 characters max"},f.createElement(k.F,{control:t,name:"ctaText",trigger:h,type:"text",style:"dynamic",placeholder:"it's eggbug",rules:{minLength:1,maxLength:{message:"must be under 35 characters",value:35},required:{message:"required",value:!0}}}),U.errors.ctaText&&f.createElement("span",{className:"text-red"},U.errors.ctaText.message)),f.createElement(R,{label:"button link",smallLabel:"it's gotta be a URL"},f.createElement(k.F,{control:t,name:"ctaLink",trigger:h,type:"text",style:"dynamic",placeholder:"https://cohost.org/eggbug",rules:{required:{message:"required",value:!0},validate:e=>{try{const t=E.z.string().url().safeParse(e);return t.success&&!!(0,u.m)(b()(t.data,{stripAuthentication:!0,stripWWW:!1})).valid||"invalid URL"}catch(e){return"invalid URL"}}}}),U.errors.ctaLink&&f.createElement("span",{className:"text-red"},U.errors.ctaLink.message)),f.createElement("hr",null),f.createElement(R,{label:"listing categories"},f.createElement(N.v,{level:"post-box-info"},"these are the categories you ad will appear in. choose however many you want, but you need at least one."),f.createElement(C.l,{control:t,name:"categories",options:_,rules:{validate:e=>{if(0===(e=e).length)return"you need at least one category"}}}),U.errors.categories&&f.createElement("span",{className:"text-red"},U.errors.categories.message)),f.createElement("hr",null),f.createElement("label",{className:"flex flex-row items-center justify-between"},f.createElement("span",{className:"font-bold"},"this listing contains 18+ content"),f.createElement("input",T({type:"checkbox"},a("adult"),{className:"rounded-checkbox"}))),f.createElement("hr",null),f.createElement("label",{className:"flex flex-row items-center justify-between"},f.createElement("div",{className:"flex flex-col gap-2"},f.createElement("span",{className:"font-bold"},"how many weeks should this listing run?"),f.createElement("span",{className:"text-sm"},"listings are $10/week")),f.createElement(k.F,{type:"number",style:"dynamic",control:t,trigger:h,rules:{min:1,max:4,required:!0},name:"numWeeks",min:1,max:4,step:1})),f.createElement("hr",null),f.createElement(R,{label:"anything else to tell us?"},f.createElement(N.v,{level:"post-box-info"},f.createElement("div",{className:"co-prose prose prose-sm"},f.createElement("p",null,"you can put any notes you want us to see here. these won't be publicly visible, but can be helpful for us during review."),f.createElement("p",null,"we would especially appreciate any categories you think this listing fits in to that we don't already have! if we decide to add them, we'll apply them to your listing automatically."))),f.createElement(S.V,{minRows:3,control:t,name:"notes",autoComplete:"off",placeholder:"thank you for inventing eggbug",className:"co-styled-input rounded-lg border-2"})),f.createElement("button",{className:"co-filled-button w-max self-end rounded-lg px-3 py-2.5 font-bold",type:"submit",disabled:U.isSubmitting},"continue to payment")),null))),f.createElement("div",null,f.createElement("div",{className:"co-settings co-themed-box flex flex-col gap-4 rounded-lg p-3","data-theme":B.current},f.createElement("h2",{className:"co-settings-header"},"preview"),f.createElement(N.v,{level:"post-box-info"},"this is what your listing will look like to others!"),f.createElement("div",{className:"mx-auto w-full max-w-[300px]"},f.createElement(v.l,{listing:z,project:V})))))};t.default=j},54485:function(e,t,a){function l(e){let t;try{t=new URL(e)}catch(e){return{valid:!1}}return"https:"!==t.protocol&&"http:"!==t.protocol?{valid:!1}:{valid:!0,url:t.toString()}}a.d(t,{m:function(){return l}})}}]);
|
||
//# sourceMappingURL=preact-components-pages-artist-alley-create.fd18dd968bafb6772409.js.map
|