1 |
- import{j as f,a as n,Z as C,r as w,cS as N,u as L,F as b,B as k,L as S}from"./index-0d8158eb.js";import{l as z}from"./index-c0b93546.js";import{u as M,M as F}from"./index.esm-07f1e6d3.js";import{d as j}from"./index.modern-c903a5d6.js";import{L as E,S as v}from"./login-layout-d129ef85.js";import{S as I}from"./index-845e4de2.js";import{u as T}from"./use-notification-56391e62.js";import{g as q}from"./error-messages-d2d0bb30.js";import"./index-9af9f9f3.js";import"./index-aba65090.js";function A(r){var e={target:"confetti-holder",max:80,size:1,animate:!0,respawn:!0,props:["circle","square","triangle","line"],colors:[[165,104,246],[230,61,135],[0,199,228],[253,214,126]],clock:25,interval:null,rotate:!1,start_from_edge:!1,width:window.innerWidth,height:window.innerHeight};if(r&&(r.target&&(e.target=r.target),r.max&&(e.max=r.max),r.size&&(e.size=r.size),r.animate!==void 0&&r.animate!==null&&(e.animate=r.animate),r.respawn!==void 0&&r.respawn!==null&&(e.respawn=r.respawn),r.props&&(e.props=r.props),r.colors&&(e.colors=r.colors),r.clock&&(e.clock=r.clock),r.start_from_edge!==void 0&&r.start_from_edge!==null&&(e.start_from_edge=r.start_from_edge),r.width&&(e.width=r.width),r.height&&(e.height=r.height),r.rotate!==void 0&&r.rotate!==null&&(e.rotate=r.rotate)),typeof e.target!="object"&&typeof e.target!="string")throw new TypeError("The target parameter should be a node or string");if(typeof e.target=="object"&&(e.target===null||!e.target instanceof HTMLCanvasElement)||typeof e.target=="string"&&(document.getElementById(e.target)===null||!document.getElementById(e.target)instanceof HTMLCanvasElement))throw new ReferenceError("The target element does not exist or is not a canvas element");var l=typeof e.target=="object"?e.target:document.getElementById(e.target),a=l.getContext("2d"),c=[];function d(t,s){t||(t=1);var u=Math.random()*t;return s?Math.floor(u):u}var p=e.props.reduce(function(t,s){return t+(s.weight||1)},0);function _(){for(var t=Math.random()*p,s=0;s<e.props.length;++s){var u=e.props[s].weight||1;if(t<u)return s;t-=u}}function x(){var t=e.props[_()],s={prop:t.type?t.type:t,x:d(e.width),y:e.start_from_edge?e.clock>=0?-10:parseFloat(e.height)+10:d(e.height),src:t.src,radius:d(4)+1,size:t.size,rotate:e.rotate,line:Math.floor(d(65)-30),angles:[d(10,!0)+2,d(10,!0)+2,d(10,!0)+2,d(10,!0)+2],color:e.colors[d(e.colors.length,!0)],rotation:d(360,!0)*Math.PI/180,speed:d(e.clock/7)+e.clock/30};return s}function h(t){if(t){var s=t.radius<=3?.4:.8;switch(a.fillStyle=a.strokeStyle="rgba("+t.color+", "+s+")",a.beginPath(),t.prop){case"circle":{a.moveTo(t.x,t.y),a.arc(t.x,t.y,t.radius*e.size,0,Math.PI*2,!0),a.fill();break}case"triangle":{a.moveTo(t.x,t.y),a.lineTo(t.x+t.angles[0]*e.size,t.y+t.angles[1]*e.size),a.lineTo(t.x+t.angles[2]*e.size,t.y+t.angles[3]*e.size),a.closePath(),a.fill();break}case"line":{a.moveTo(t.x,t.y),a.lineTo(t.x+t.line*e.size,t.y+t.radius*5),a.lineWidth=2*e.size,a.stroke();break}case"square":{a.save(),a.translate(t.x+15,t.y+5),a.rotate(t.rotation),a.fillRect(-15*e.size,-5*e.size,15*e.size,5*e.size),a.restore();break}case"svg":{a.save();var u=new window.Image;u.src=t.src;var i=t.size||15;a.translate(t.x+i/2,t.y+i/2),t.rotate&&a.rotate(t.rotation),a.drawImage(u,-(i/2)*e.size,-(i/2)*e.size,i*e.size,i*e.size),a.restore();break}}}}var y=function(){e.animate=!1,clearInterval(e.interval),requestAnimationFrame(function(){a.clearRect(0,0,l.width,l.height);var t=l.width;l.width=1,l.width=t})},g=function(){l.width=e.width,l.height=e.height,c=[];for(var t=0;t<e.max;t++)c.push(x());function s(){a.clearRect(0,0,e.width,e.height);for(var i in c)h(c[i]);u(),e.animate&&requestAnimationFrame(s)}function u(){for(var i=0;i<e.max;i++){var o=c[i];o&&(e.animate&&(o.y+=o.speed),o.rotate&&(o.rotation+=o.speed/35),(o.speed>=0&&o.y>e.height||o.speed<0&&o.y<0)&&(e.respawn?(c[i]=o,c[i].x=d(e.width,!0),c[i].y=o.speed>=0?-10:parseFloat(e.height)):c[i]=void 0))}c.every(function(m){return m===void 0})&&y()}return requestAnimationFrame(s)};return{render:g,clear:y}}const P=({size:r="24",color:e="currentColor",...l})=>{const a=+r*2;return f("svg",{width:a,height:r,viewBox:"0 0 40 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l,children:[n("path",{d:"M4 9H36",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),n("path",{d:"M31 5L36 9L31 13",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})},B=({size:r="96",color:e="currentColor",...l})=>f("svg",{width:r,height:r,viewBox:"0 0 96 96",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l,children:[n("path",{d:"M75.6103 20.9859L57.5892 10.5638C51.6929 7.14539 44.4678 7.14539 38.5715 10.5638L20.4673 20.9859C14.6541 24.4044 11 30.741 11 37.4945V58.4221C11 65.259 14.6541 71.5122 20.4673 74.9307L38.4884 85.4362C44.3848 88.8546 51.6098 88.8546 57.5061 85.4362L75.5273 74.9307C81.4236 71.5122 84.9946 65.259 84.9946 58.4221V37.4945C85.1607 30.741 81.5066 24.4044 75.6103 20.9859ZM48.0388 66.593C37.8241 66.593 29.5194 58.2553 29.5194 48C29.5194 37.7447 37.8241 29.407 48.0388 29.407C58.2535 29.407 66.6413 37.7447 66.6413 48C66.6413 58.2553 58.3366 66.593 48.0388 66.593Z",fill:"url(#paint0_linear_2823_15237)"}),n("defs",{children:f("linearGradient",{id:"paint0_linear_2823_15237",x1:"11",y1:"88",x2:"100.328",y2:"63.1913",gradientUnits:"userSpaceOnUse",children:[n("stop",{stopColor:"#7C53FF"}),n("stop",{offset:"1",stopColor:"#F796FF"})]})})]}),J=()=>{const r=C(),e=z.parse(r.search.substring(1)),[l,a]=w.useState(!1);let c=null;if(e!=null&&e.token)try{c=j(e.token)}catch{c=null}const[d,p]=w.useState(!1),[_,x]=w.useState(!1);w.useEffect(()=>{const o={target:"confetti-canvas",start_from_edge:!0,size:3,clock:25,colors:[[251,146,60],[167,139,250],[251,146,60],[96,165,250],[45,212,191],[250,204,21],[232,121,249]],max:26},m=new A(o);return m.render(),()=>m.clear()},[]);const{register:h,handleSubmit:y,formState:g}=M({defaultValues:{first_name:"",last_name:"",password:"",repeat_password:""}}),t=N(),s=L(),u=T(),i=o=>{if(p(!1),o.password!==o.repeat_password){p(!0);return}t.mutate({token:e.token,user:{first_name:o.first_name,last_name:o.last_name,password:o.password}},{onSuccess:()=>{s("/login")},onError:m=>{u("Error",q(m),"error")}})};return w.useEffect(()=>{g.dirtyFields.password&&g.dirtyFields.repeat_password&&g.dirtyFields.first_name&&g.dirtyFields.last_name?x(!0):x(!1)},[g]),n(b,{children:l?f(E,{children:[n(I,{title:"Create Account"}),n("div",{className:"flex h-full w-full items-center justify-center",children:n("div",{className:"bg-grey-0 rounded-rounded flex min-h-[600px] justify-center",children:f("form",{className:"flex w-full flex-col items-center py-12 px-[120px]",onSubmit:y(i),children:[n(F,{}),c?f(b,{children:[n("span",{className:"inter-2xlarge-semibold text-grey-90 mt-4",children:"Welcome to the team!"}),n("span",{className:"inter-base-regular text-grey-50 mb-large mt-2",children:"Create your account below👇🏼"}),n(v,{placeholder:"First name",...h("first_name",{required:!0}),autoComplete:"given-name"}),n(v,{placeholder:"Last name",...h("last_name",{required:!0}),autoComplete:"family-name"}),n(v,{placeholder:"Password",type:"password",...h("password",{required:!0}),autoComplete:"new-password"}),n(v,{placeholder:"Repeat password",type:"password",...h("repeat_password",{required:!0}),autoComplete:"new-password"}),d&&n("span",{className:"inter-small-regular mt-2 w-full text-rose-50",children:"The two passwords are not the same"}),n(k,{variant:"primary",size:"large",type:"submit",className:"mt-base w-full",loading:g.isSubmitting,disabled:!_,children:"Create account"}),n(S,{to:"/login",className:"inter-small-regular text-grey-50 mt-large",children:"Already signed up? Log in"})]}):f("div",{className:"flex h-full flex-col items-center justify-center gap-y-2 text-center",children:[n("span",{className:"inter-large-semibold text-grey-90",children:"You signup link is invalid"}),n("span",{className:"inter-base-regular text-grey-50 mt-2",children:"Contact your administrator to obtain a valid signup link"})]})]})})})]}):f("div",{className:"bg-grey-90 h-screen w-full overflow-hidden",children:[f("div",{className:"absolute inset-0 z-10 mx-auto flex h-full max-w-[1080px] flex-grow flex-col items-center justify-center",children:[n(B,{className:"mb-3xlarge"}),f("div",{className:"flex max-w-3xl flex-col items-center text-center",children:[n("h1",{className:"inter-3xlarge-semibold text-grey-0 mb-base",children:"You have been invited to join the team"}),n("p",{className:"inter-xlarge-regular text-grey-50",children:"You can now join the Medusa Store team. Sign up below and get started with your Medusa Admin account right away."})]}),n("div",{className:"mt-4xlarge",children:f(k,{size:"large",variant:"primary",className:"w-[280px]",onClick:()=>a(!0),children:["Sign up",n(P,{size:20,className:"pt-1"})]})})]}),n("canvas",{id:"confetti-canvas"})]})})};export{J as default};
|