1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[88229],{88229:(e,a,n)=>{n.r(a),n.d(a,{ContactEditModal:()=>u});var r=n(17163),l=n(42971),t=n(15347),i=n(6940),o=n(1902),s=n(59159);let c={id:"",first_name:"",last_name:"",email:"",phone:"",position:"",linkedin_url:"",preferred_language:"nl",is_primary:!1,is_decision_maker:!1,is_active:!0,opted_out:!1},d=[{value:"nl",label:"Nederlands"},{value:"en",label:"English"},{value:"de",label:"Deutsch"},{value:"fr",label:"Fran\xe7ais"},{value:"es",label:"Espa\xf1ol"},{value:"it",label:"Italiano"}];function u(e){var a,n;let u="create"===e.mode,m="create"===e.mode&&null!=(a=e.defaultLocationId)?a:null,g=u?{...c,location_id:m}:e.contact,x=null!=(n=e.locations)?n:[],[b,h]=(0,l.useState)(g),[f,v]=(0,l.useState)(!1),[_,k]=(0,l.useState)(null),{t:j}=(0,s.q)();if((0,l.useEffect)(()=>{e.open&&(h(u?{...c,location_id:m}:e.contact),k(null))},[e.open,u,e.contact,m]),!e.open)return null;let y=e.onClose,w=e.onSaved;async function N(){v(!0),k(null);try{var a,n,r,l,t,i,s,c,d,p,m,g;if(u){if(!(null==(r=b.first_name)?void 0:r.trim())||!(null==(l=b.email)?void 0:l.trim()))return void k(j("Voornaam en email zijn vereist"));let a=await (0,o.dB)("/api/intern/sales/contacts",{company_id:e.companyId,first_name:b.first_name.trim(),last_name:b.last_name||null,email:b.email.trim(),phone:b.phone||null,position:b.position||null,linkedin_url:b.linkedin_url||null,preferred_language:b.preferred_language||null,is_primary:!!b.is_primary,is_decision_maker:!!b.is_decision_maker,...b.location_id?{location_id:b.location_id}:{}});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error&&j(e.error)||"HTTP ".concat(a.status))}w(),y();return}let x=e.contact,h={first_name:(null==(a=b.first_name)?void 0:a.trim())||x.first_name,last_name:null!=(t=b.last_name)?t:null,email:(null==(n=b.email)?void 0:n.trim())||x.email,phone:null!=(i=b.phone)?i:null,position:null!=(s=b.position)?s:null,linkedin_url:null!=(c=b.linkedin_url)?c:null,preferred_language:null!=(d=b.preferred_language)?d:null,is_primary:!!b.is_primary,is_decision_maker:!!b.is_decision_maker,is_active:!1!==b.is_active,opted_out:!!b.opted_out};(null!=(p=b.location_id)?p:null)!==(null!=(m=x.location_id)?m:null)&&(h.location_id=null!=(g=b.location_id)?g:null);let f=await (0,o.ht)("/api/intern/crm/contacts/".concat(x.id),{method:"PATCH",headers:{"Content-Type":"application/json",...x.updated_at?{"x-expected-updated-at":x.updated_at}:{}},body:JSON.stringify(h)});if(409===f.status){let e=await f.json().catch(()=>({}));k(e.hint||j("Iemand heeft dit contact net bewerkt â laad opnieuw en probeer nogmaals."));return}if(!f.ok){let e=await f.json().catch(()=>({}));throw Error(e.error&&j(e.error)||"HTTP ".concat(f.status))}w(),y()}catch(e){k((null==e?void 0:e.message)||j("Onbekende fout"))}finally{v(!1)}}return(0,r.jsx)("div",{className:"lm2 fixed inset-0 z-50 flex items-center justify-center bg-[rgba(23,20,15,0.55)] backdrop-blur-sm p-4",onClick:y,children:(0,r.jsxs)("div",{className:"w-full max-w-xl overflow-hidden rounded-xl border-[1.5px] border-[var(--ink)] bg-[var(--paper)] shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--line)] px-6 py-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-emerald-100 text-emerald-700",children:(0,r.jsx)(t.A,{className:"h-4 w-4"})}),(0,r.jsx)("h3",{className:"fd text-base font-bold text-[var(--ink)]",children:u?j("Contact toevoegen"):j("Contact bewerken")})]}),(0,r.jsx)("button",{onClick:y,className:"rounded-lg p-1 text-[var(--soft2)] transition hover:bg-[rgba(23,20,15,0.04)] hover:text-[var(--soft)]","aria-label":j("Sluit"),children:(0,r.jsx)(i.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 px-6 py-5 sm:grid-cols-2",children:[(0,r.jsx)(p,{label:j("Voornaam *"),children:(0,r.jsx)("input",{value:b.first_name||"",onChange:e=>h({...b,first_name:e.target.value}),className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]"})}),(0,r.jsx)(p,{label:j("Achternaam"),children:(0,r.jsx)("input",{value:b.last_name||"",onChange:e=>h({...b,last_name:e.target.value}),className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]"})}
1),(0,r.jsx)(p,{label:j("Email *"),className:"sm:col-span-2",children:(0,r.jsx)("input",{type:"email",value:b.email||"",onChange:e=>h({...b,email:e.target.value}),className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]"})}),(0,r.jsx)(p,{label:j("Telefoon"),children:(0,r.jsx)("input",{value:b.phone||"",onChange:e=>h({...b,phone:e.target.value}),className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]"})}),(0,r.jsx)(p,{label:j("Functie"),children:(0,r.jsx)("input",{value:b.position||"",onChange:e=>h({...b,position:e.target.value}),placeholder:j("CEO / Marketing / etc."),className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]"})}),(0,r.jsx)(p,{label:j("LinkedIn URL"),className:"sm:col-span-2",children:(0,r.jsx)("input",{value:b.linkedin_url||"",onChange:e=>h({...b,linkedin_url:e.target.value}),placeholder:"https://linkedin.com/in/â¦",className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]"})}),x.length>0&&(0,r.jsx)(p,{label:j("Vestiging"),className:"sm:col-span-2",children:(0,r.jsxs)("select",{value:b.location_id||"",onChange:e=>h({...b,location_id:e.target.value||null}),className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]",children:[(0,r.jsx)("option",{value:"",children:j("Hoofdvestiging (adres van het bedrijf)")}),x.map(e=>(0,r.jsx)("option",{value:e.id,children:e.city&&!e.name.toLowerCase().includes(e.city.toLowerCase())?"".concat(e.name," (").concat(e.city,")"):e.name},e.id))]})}),(0,r.jsx)(p,{label:j("Voorkeurstaal"),children:(0,r.jsxs)("select",{value:b.preferred_language||"",onChange:e=>h({...b,preferred_language:e.target.value}),className:"w-full rounded-lg border-[1.5px] border-[rgba(23,20,15,0.25)] bg-white px-3 py-2 text-sm text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none focus:ring-1 focus:ring-[var(--orange)]",children:[(0,r.jsx)("option",{value:"",children:"â"}),d.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))]})}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:col-span-2",children:[(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-[var(--ink)]",children:[(0,r.jsx)("input",{type:"checkbox",checked:!!b.is_primary,onChange:e=>h({...b,is_primary:e.target.checked}),className:"h-4 w-4 accent-gray-900"}),j("Primair contact voor dit bedrijf")]}),(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-[var(--ink)]",children:[(0,r.jsx)("input",{type:"checkbox",checked:!!b.is_decision_maker,onChange:e=>h({...b,is_decision_maker:e.target.checked}),className:"h-4 w-4 accent-gray-900"}),j("Beslissingsnemer (mag tekenen)")]}),(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-[var(--ink)]",children:[(0,r.jsx)("input",{type:"checkbox",checked:!1!==b.is_active,onChange:e=>h({...b,is_active:e.target.checked}),className:"h-4 w-4 accent-gray-900"}),j("Actief (zichtbaar in lijsten + bereikbaar)")]}),(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-[var(--ink)]",children:[(0,r.jsx)("input",{type:"checkbox",checked:!!b.opted_out,onChange:e=>h({...b,opted_out:e.target.checked}),className:"h-4 w-4 accent-red-600"}),j("Opted out (geen marketing mails)")]})]})]}),_&&(0,r.jsx)("div",{className:"mx-6 mb-4 rounded-lg border border-red-100 bg-red-50 px-3 py-2 text-sm text-red-700",children:_}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 border-t border-[var(--line)] bg-[rgba(23,20,15,0.04)] px-6 py-4",children:[(0,r.jsx)("button",{onClick:y,className:"rounded-lg border-[1.5px] border-[var(--ink)] px-4 py-2 text-sm font-semibold text-[var(--ink)] hover:bg-[rgba(23,20,15,0.05)]",children:j("Annuleer")}),(0,r.jsx)("button",{onClick:N,disabled:f,className:"rounded-lg bg-[var(--ink)] px-4 py-2 text-sm font-bold text-[var(--gold)] hover:opacity-90 disabled:opacity-50",children:f?j("Opslaanâ¦"):j("Bewaar")})]})]})})}function p(e){let{label:a,children:n,className:l}=e;return(0,r.jsxs)("label",{className:"flex flex-col gap-1 ".concat(null!=l?l:""),children:[(0,r.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-[var(--soft2)]",children:a}),n]})}}}]);
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.