1import{j as e}from"./vendor-maps-BkFXKbVz.js";import{t as q,v as A,O as w,w as P,x as z,y as U,z as E,B as I,D as L,E as R,G as g}from"./index-BlFipuMK.js";import{c as $,a as l,F as M,b as V,d as c,E as m}from"./vendor-forms-j-705dr2.js";import{r as h}from"./vendor-react-iB9ODP_1.js";import{U as D}from"./vendor-phone-VSINlmNE.js";import{u as k}from"./vendor-i18n-Cw8D5MCt.js";import{S as B}from"./vendor-antd-CuXAe93C.js";import"./vendor-utils-iY4jI3ms.js";import"./vendor-state-BcIU6khZ.js";import"./vendor-animation-DsbV8uj4.js";import"./vendor-realtime-ByZp_ck7.js";function W(s){return s.map(r=>{if(!r||typeof r!="object")return null;const n=r,_=String(n.value??n.code??"").trim().toUpperCase(),f=String(n.label??n.name_fr??n.name??_).trim();return _.length!==2?null:{value:_,label:f||_}}).filter(r=>r!==null)}const G=s=>{const r=s.trim();return r?/^https?:\/\//i.test(r)?r:`https://${r}`:null},T=s=>s.startsWith("+")?s:`+${s.replace(/^\+/,"")}`,se=({embedded:s=!1})=>{const{t:r}=k(),{user:n}=q(),_=A({navigateOnSuccess:!1}),[f,C]=h.useState([]),[F,x]=h.useState(!0),i=n?.profile;h.useEffect(()=>{let t=!1;return(async()=>{x(!0);try{const a=await R(),d=Array.isArray(a)?a:a?.data;!t&&Array.isArray(d)&&C(W(d))}catch{t||g.error(r("common.enterprise_register.country_error"))}finally{t||x(!1)}})(),()=>{t=!0}},[r]);const j=h.useMemo(()=>({email:n?.email??i?.email??"",company_name:i?.company_name??"",full_name_contact:i?.full_name_contact??"",role_contact:i?.role_contact??"",phone:i?.phone??n?.phone_number??"",address:i?.address??"",country:(i?.country??"FR").toUpperCase().slice(0,2),website:i?.website??"",num_id_company:i?.num_id_company??"",vat_number:i?.vat_number??""}),[i,n?.email,n?.phone_number]),O=h.useMemo(()=>$({email:l().trim().email(r("form.invalid_email")).max(255,r("form.max_length",{max:255})).required(r("form.field_required")),company_name:l().trim().max(255,r("form.max_length",{max:255})).required(r("form.field_required")),full_name_contact:l().trim().max(255,r("form.max_length",{max:255})).required(r("form.field_required")),role_contact:l().max(255,r("form.max_length",{max:255})),phone:l().required(r("form.field_required")),address:l().max(500,r("form.max_length",{max:500})),country:l().length(2,r("organization.country_iso")).required(r("form.field_required")),website:l().transform(t=>typeof t=="string"&&t.trim()===""?void 0:t).optional().test("website-url",r("organization.website_invalid"),t=>{if(!t||t.trim()==="")return!0;const p=/^https?:\/\//i.test(t)?t:`https://${t}`;try{const a=new URL(p);return a.protocol==="http:"||a.protocol==="https:"}catch{return!1}}),num_id_company:l().max(100,r("form.max_length",{max:100})),vat_number:l().max(50,r("form.max_length",{max:50}))}),[r]),S=async(t,{setErrors:p,setSubmitting:a})=>{const d={email:t.email.trim(),company_name:t.company_name.trim(),full_name_contact:t.full_name_contact.trim(),phone:T(t.phone),address:t.address.trim()||void 0,country:t.country.toUpperCase(),website:G(t.website),num_id_company:t.num_id_company.trim()||void 0,vat_number:t.vat_number.trim()||void 0,role_contact:t.role_contact.trim()||void 0};try{const o=await _.mutateAsync(d);if(!o.success){g.error(o.message??r("organization.profile_save_error"));return}g.success(r("organization.profile_saved"))}catch(o){const u=o.response?.data;if(u?.errors){const y={};for(const[b,v]of Object.entries(u.errors))v?.[0]&&b in j&&(y[b]=v[0]);p(y)}else u?.message?g.error(u.message):g.error(r("organization.profile_save_error"))}finally{a(!1)}};return e.jsxs("div",{className:s?"org-profile org-profile--embedded":"org-profile",children:[s?null:e.jsx("header",{className:"org-profile__header",children:e.jsx("p",{className:"org-profile__lead",children:r("organization.profile_page_lead")})}),e.jsxs("section",{className:"org-profile__section org-profile__section--form","aria-labelledby":s?"org-settings-profile-heading":"org-profile-form-heading",children:[s?null:e.jsx("h2",{id:"org-profile-form-heading",className:"org-profile__section-title",children:r("organization.profile_section_editable")}),e.jsx(M,{initialValues:j,validationSchema:O,onSubmit:S,enableReinitialize:!0,children:({handleSubmit:t,isSubmitting:p})=>e.jsx(V,{onSubmit:t,noValidate:!0,children:e.jsxs("div",{className:"ent-register__fields",children:[e.jsxs("div",{className:"ent-register__fields-top org-profile__grid",children:[e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-company",children:r("organization.company_name")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:w,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-company",name:"company_name",type:"text",className:"ent-register__input",autoComplete:"organization",placeholder:r("organization.placeholder_company_name")})]}),e.jsx(m,{name:"company_name",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-country",children:r("organization.country_label")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:P,alt:"",width:22,height:22})}),e.jsx(c,{name:"country",children:({field:a,form:d})=>e.jsx(B,{id:"org-profile-country",showSearch:!0,optionFilterProp:"label",loading:F,className:"ent-register__country-select ent-register__country-select--inlined",popupClassName:"ent-register__country-dropdown",value:a.value||void 0,onChange:o=>d.setFieldValue(a.name,o),filterOption:(o,N)=>(N?.label||"").toLowerCase().includes(o.toLowerCase()),options:f,placeholder:r("common.enterprise_register.country_placeholder")})})]}),e.jsx(m,{name:"country",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-num-id",children:r("organization.num_id_company")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:z,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-num-id",name:"num_id_company",type:"text",className:"ent-register__input",placeholder:r("organization.placeholder_num_id_company")})]}),e.jsx(m,{name:"num_id_company",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-vat",children:r("organization.vat_number")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:z,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-vat",name:"vat_number",type:"text",className:"ent-register__input",placeholder:r("organization.placeholder_vat_number")})]}),e.jsx(m,{name:"vat_number",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-address",children:r("organization.address")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:U,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-address",name:"address",type:"text",className:"ent-register__input",autoComplete:"street-address",placeholder:r("organization.placeholder_address")})]}),e.jsx(m,{name:"address",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-website",children:r("organization.website")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:w,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-website",name:"website",type:"text",className:"ent-register__input",placeholder:r("organization.placeholder_website"),autoComplete:"url"})]}),e.jsx(m,{name:"website",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-contact-name",children:r("organization.full_name_contact")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:E,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-contact-name",name:"full_name_contact",type:"text",className:"ent-register__input",autoComplete:"name",placeholder:r("organization.placeholder_full_name_contact")})]}),e.jsx(m,{name:"full_name_contact",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-role",children:r("organization.role_c
1ontact")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:I,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-role",name:"role_contact",type:"text",className:"ent-register__input",placeholder:r("organization.placeholder_role_contact")})]}),e.jsx(m,{name:"role_contact",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-phone",children:r("organization.phone")}),e.jsx("div",{className:"ent-register__phone-wrapper",children:e.jsx(c,{name:"phone",children:({field:a,form:d})=>e.jsx(D,{defaultCountry:"fr",value:a.value??"",onChange:o=>d.setFieldValue("phone",o),inputProps:{id:"org-profile-phone",autoComplete:"tel",placeholder:r("organization.placeholder_phone")}})})}),e.jsx(m,{name:"phone",component:"p",className:"ent-register__error"})]}),e.jsxs("div",{className:"ent-register__field",children:[e.jsx("label",{className:"ent-register__label",htmlFor:"org-profile-email",children:r("organization.email_label")}),e.jsxs("div",{className:"ent-register__input-wrap",children:[e.jsx("span",{className:"ent-register__icon",children:e.jsx("img",{src:L,alt:"",width:22,height:22})}),e.jsx(c,{id:"org-profile-email",name:"email",type:"email",className:"ent-register__input",autoComplete:"email",placeholder:r("organization.placeholder_email")})]}),e.jsx(m,{name:"email",component:"p",className:"ent-register__error"})]})]}),e.jsx("div",{className:"ent-register__buttons",children:e.jsx("button",{type:"submit",className:"ent-register__btn-continue",disabled:p||_.isPending,children:p||_.isPending?r("common.loading"):r("organization.profile_save")})})]})})})]})]})};export{se as default};
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.