PageSourceSearch

https://www.tracklib.com/assets/CreateLicenseModal-WbefKxPE.js

js tracklib.com collected 2026-09-24 20:24:54 UTC 5,131 bytes, 1 lines download raw bytes

1import{r as m,j as t}from"./react-B62KX_yh.js";import{u as I}from"./tanstack-form-lkgzurao.js";import{u as w}from"./tanstack-router-kwsmQtzq.js";import{aP as C,aO as E,d4 as R,c6 as B,ay as L,M as T,am as A,bC as N}from"./tanstack-start-N_noiGjL.js";import{Modal as V}from"./Modal-D0Ed0mc5.js";import{t as k}from"./sonner-Cuj23odt.js";import{A as d}from"./animated-error-DE34AS3h.js";import{S as M}from"./SampledSongSelect-BTmsmBFX.js";import{S as D}from"./SampleLengthRadios-AQIKoW0V.js";import{F as U,a as u,b as p,c as g,d as z}from"./field-BgOhl6Wn.js";import{u as P}from"./use-save-success-Bea9l1Xv.js";import{u as Y}from"./license-versions-fdq05EsR.js";import{a as q}from"./mutations-DcV41vTE.js";import{c as h}from"./schemas-CguOJgHx.js";import"./tanstack-c3473pde.js";import"./radix-accordion-BojWFHKe.js";import"./radix-dialog-0ISVFfye.js";import"./radix-menu-BWvfNzDR.js";import"./radix-select-CoJcTNwl.js";import"./radix-navigation-menu-BMIVaaWL.js";import"./lucide-3XnZ2Rrp.js";import"./tanstack-query-C282WS1z.js";import"./ui-utils-DwKoTZwY.js";import"./unpic-CvTVdNXZ.js";import"./dialog-CqkYEGBX.js";import"./popover-FPRxthXv.js";import"./radix-popover-qsQbp31u.js";import"./ComboboxTriggerButton-Coo1GKHT.js";import"./radio-group-D_cgSDt0.js";import"./zod-fields-DFrE2nWx.js";import"./schemas-Bgel29Ne.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"[email protected]"};var o=new r.Error().stack;o&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[o]="56399e83-69b5-4751-bbec-3cb0f0396d74",r._sentryDebugIdIdentifier="sentry-dbid-56399e83-69b5-4751-bbec-3cb0f0396d74")}catch{}})();const je=({onClose:r})=>{const o=w(),b=q(),S=Y(),{isSuccess:x,triggerSuccess:j}=P(r),l=C(),_=E(),{data:y}=R(_),n=y?.song,[F,f]=m.useState(),v=m.useRef(null);m.useEffect(()=>{if(!l)return;const e=requestAnimationFrame(()=>v.current?.focus());return()=>cancelAnimationFrame(e)},[l]);const i=I({defaultValues:{song_id:l?String(l):"",license_sample_type:"",song_title:"",sampled_title:n?.title??""},validators:{onMount:h,onChange:h,onSubmit:h},onSubmit:async({value:e})=>{const s=await b.mutateAsync({song_title:e.song_title,license_version_id:S?.id,samples:[{song:Number(e.song_id),license_sample_type:Number(e.license_sample_type)}]}),a=s.samples?.[0]?.song;k("License started",{description:s.song_title?`"${s.song_title}" - finish the steps to activate it`:"Finish the steps to activate your license",icon:a?.cover?t.jsx("img",{alt:"",className:"size-7 shrink-0 rounded-sm object-cover",src:B(a.cover,56)}):t.jsx(L,{name:"check",size:20})}),j(()=>o({to:T({name:"license-detail",userSongId:s.id}),replace:!0}))}});return m.useEffect(()=>{if(!n)return;const e=n.licenseinfo?.license_price_category;e!=null&&f(e),i.setFieldValue("sampled_title",n.title)},[n,i]),t.jsx(V,{description:"Register a song you've sampled to start the licensing flow.",onClose:r,open:!0,title:"License new sample",variant:"form-wide",children:t.jsx("form",{onSubmit:e=>{e.preventDefault(),i.handleSubmit()},children:t.jsxs(U,{children:[t.jsx(i.Field,{name:"song_id",children:e=>{const s=e.state.meta.isBlurred&&!e.state.meta.isValid;return t.jsxs(u,{"data-invalid":s,children:[t.jsx(p,{children:"Sampled song"}),t.jsx(M,{initialSong:n,invalid:s,onChange:(a,c)=>{e.handleChange(a),e.handleBlur(),f(c?.licenseinfo?.license_price_category),i.setFieldValue("sampled_title",c?.title??"")},value:e.state.value}),t.jsx(d,{visible:s,children:t.jsx(g,{errors:e.state.meta.errors})})]})}}),t.jsx(i.Field,{name:"song_title",children:e=>{const s=e.state.meta.isBlurred&&!e.state.meta.isValid;return t.jsxs(u,{"data-invalid":s,children:[t.jsx(p,{htmlFor:e.name,children:"Your song title"}),t.jsx(A,{"aria-invalid":s,"data-testid":"create-license-song-title",id:e.name,name:e.name,onBlur:e.handleBlur,onChange:a=>e.handleChange(a.target.value),ref:v,value:e.state.value}),t.jsx(z,{children:"Can not be too similar to the name of the song you sampled."}),t.jsx(d,{visible:s,children:t.jsx(g,{errors:e.state.meta.errors})})]})}}),t.jsx(i.Subscribe,{selector:e=>!!e.values.song_id,children:e=>t.jsx("div",{className:"grid transition-[grid-template-rows,opacity,margin] duration-200 ease-out",inert:!e,style:{gridTemplateRows:e?"1fr":"0fr",opacity:e?1:0,marginBottom:e?0:"-1.25rem"},children:t.jsx("div",{className:"overflow-hidden",children:t.jsx(i.Field,{name:"license_sample_type",children:s=>{const a=s.state.meta.isBlurred&&!s.state.meta.isValid;return t.jsxs(u,{"data-invalid":a,children:[t.jsx(p,{children:"Sample length"}),t.jsx(D,{category:F,onChange:c=>{s.handleChange(String(c)),s.handleBlur()},value:s.state.value?Number(s.state.value):null}),t.jsx(d,{visible:a,children:t.jsx(g,{errors:s.state.meta.errors})})]})}})})})}),t.jsx(i.Subscribe,{selector:e=>({canSubmit:e.canSubmit,isSubmitting:e.isSubmitting}),children:({canSubmit:e,isSubmitting:s})=>t.jsx(N,{color:"primary","data-testid":"register-song-button",disabled:!e,isLoading:s,isSuccess:x,successText:"Registered",type:"submit",children:"Register"})})]})})})};export{je as CreateLicenseModal};

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.