transcriptor-web/public/build/assets/UpdateProfileInformationForm-DZ00vhI3.js
2025-04-05 15:58:14 +02:00

2 lines
3.7 KiB
JavaScript

import{m as w,u as I,r as n,j as e,$ as F,W as C}from"./app-43FwoUKv.js";import{c as R}from"./index-C3aXnQRR.js";import{A as _}from"./ActionMessage-BR0zIw5R.js";import{F as A}from"./FormSection-fM5DX8Wc.js";import{I as i,T as g}from"./TextInput-CdoY_jBz.js";import{I as l}from"./InputLabel-Cl3yDvOx.js";import{P as D}from"./PrimaryButton-Gixff4KF.js";import{S as v}from"./SecondaryButton-CKdOzt0Y.js";import{u as T}from"./useTypedPage-_EZ6P4Xz.js";import"./transition-aKza8ZE9.js";import"./SectionTitle-CmR6E75W.js";function G({user:o}){const a=w({_method:"PUT",name:o.name,email:o.email,photo:null}),r=I(),[m,c]=n.useState(null),s=n.useRef(null),u=T(),[j,N]=n.useState(!1);function P(){a.post(r("user-profile-information.update"),{errorBag:"updateProfileInformation",preserveScroll:!0,onSuccess:()=>d()})}function k(){var t;(t=s.current)==null||t.click()}function y(){var f,h;const t=(h=(f=s.current)==null?void 0:f.files)==null?void 0:h[0];if(!t)return;a.setData("photo",t);const p=new FileReader;p.onload=b=>{var x;c((x=b.target)==null?void 0:x.result)},p.readAsDataURL(t)}function S(){C.delete(r("current-user-photo.destroy"),{preserveScroll:!0,onSuccess:()=>{c(null),d()}})}function d(){var t;(t=s.current)!=null&&t.value&&(s.current.value="",a.setData("photo",null))}return e.jsxs(A,{onSubmit:P,title:"Profile Information",description:"Update your account's profile information and email address.",renderActions:()=>e.jsxs(e.Fragment,{children:[e.jsx(_,{on:a.recentlySuccessful,className:"mr-3",children:"Saved."}),e.jsx(D,{className:R({"opacity-25":a.processing}),disabled:a.processing,children:"Save"})]}),children:[u.props.jetstream.managesProfilePhotos?e.jsxs("div",{className:"col-span-6 sm:col-span-4",children:[e.jsx("input",{type:"file",className:"hidden",ref:s,onChange:y}),e.jsx(l,{htmlFor:"photo",value:"Photo"}),m?e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:"block rounded-full w-20 h-20",style:{backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center center",backgroundImage:`url('${m}')`}})}):e.jsx("div",{className:"mt-2",children:e.jsx("img",{src:o.profile_photo_url,alt:o.name,className:"rounded-full h-20 w-20 object-cover"})}),e.jsx(v,{className:"mt-2 mr-2",type:"button",onClick:k,children:"Select A New Photo"}),o.profile_photo_path?e.jsx(v,{type:"button",className:"mt-2",onClick:S,children:"Remove Photo"}):null,e.jsx(i,{message:a.errors.photo,className:"mt-2"})]}):null,e.jsxs("div",{className:"col-span-6 sm:col-span-4",children:[e.jsx(l,{htmlFor:"name",value:"Name"}),e.jsx(g,{id:"name",type:"text",className:"mt-1 block w-full",value:a.data.name,onChange:t=>a.setData("name",t.currentTarget.value),autoComplete:"name"}),e.jsx(i,{message:a.errors.name,className:"mt-2"})]}),e.jsxs("div",{className:"col-span-6 sm:col-span-4",children:[e.jsx(l,{htmlFor:"email",value:"Email"}),e.jsx(g,{id:"email",type:"email",className:"mt-1 block w-full",value:a.data.email,onChange:t=>a.setData("email",t.currentTarget.value)}),e.jsx(i,{message:a.errors.email,className:"mt-2"}),u.props.jetstream.hasEmailVerification&&o.email_verified_at===null?e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm mt-2 dark:text-white",children:["Your email address is unverified.",e.jsx(F,{href:r("verification.send"),method:"post",as:"button",className:"underline text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 rounded-md focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-offset-gray-800",onClick:t=>{t.preventDefault(),N(!0)},children:"Click here to re-send the verification email."})]}),j&&e.jsx("div",{className:"mt-2 font-medium text-sm text-green-600 dark:text-green-400",children:"A new verification link has been sent to your email address."})]}):null]})]})}export{G as default};