1import{u as e,r as a,aa as l,y as s,f as t,i as n,h as i,ci as o,cj as r,a2 as c,J as u,j as d,G as p,n as m,H as b,m as x,d as j,a9 as h,a4 as v,a0 as f,Q as N,U as S,z as C,ck as g,aE as D,a as _,ch as y}from"./index.js";import{B as A}from"./Box.js";import{B as P}from"./Breadcrumb.js";import{P as z}from"./Page.js";import{S as E}from"./SummaryCard.js";import{u as I}from"./usePDFModal.js";import"./Dealers.module.js";const M=()=>{const{t:M}=e(),[k,L]=a.useState(!1),[B,O]=l(C),Y=s(g),{isBankStaff:w}=t(),R=n(),{setModal:K,closeModal:T}=i(),{showPDF:F}=I(),{data:V}=o({applicationNumber:null==B?void 0:B.applicationNumber}),{data:G}=r({applicationNumber:null==B?void 0:B.applicationNumber}),H=c({defaultValues:{}}),{control:J,handleSubmit:Q,setValue:q,watch:W,reset:X}=H,{mutate:Z,isLoading:$}=u(y,{onSuccess:(e,a)=>{const l="ONAY"===a.result?"text.become_supplier_success":"text.become_supplier_reject";O((e=>({...e,successMessage:l}))),Y({step:D.SUCCESS}),R.push(_.APPLICATIONS_SUPPLIER_SUCCESS)},onError:e=>{var a,l,s;const t=null==(s=null==(l=null==(a=null==e?void 0:e.error)?void 0:a.response)?void 0:l.data)?void 0:s.errorMessage;O((e=>({...e,errorMessage:t}))),R.push(_.APPLICATIONS_SUPPLIER_SUCCESS)}}),ee=(e,a)=>{const l=e.target.checked;if(q("contract",l),!l)return void L(!1);if(!(null==a?void 0:a.content))return void e.preventDefault();const s=(e=>{const a=e.replace(/^data:application\/pdf;base64,/,"");try{const e=atob(a),l=new Array(e.length);for(let a=0;a<e.length;a++)l[a]=e.charCodeAt(a);const s=new Uint8Array(l),t=new Blob([s],{type:"application/pdf"});return URL.createObjectURL(t)}catch(l){return""}})(a.content);s?F(s,{onClose(){L(!0)}}):e.preventDefault()},ae=a.useMemo((()=>{const e=W();return!k||!e.contract}),[W,k]);return a.useEffect((()=>{if(null==V?void 0:V.documents){const e=V.documents.reduce(((e,a)=>(e[a.content]=!1,e)),{});X({...e,contract:k})}}),[V,X,k]),a.useEffect((()=>{G&&O(G)}),[G,O]),"DOA"===(null==B?void 0:B.applicationStatusCode)||null==B||B.applicationIsDraft,d.jsx(z,{children:d.jsxs(A,{children:[d.jsx(p,{className:"mb-4",children:d.jsxs(m,{size:12,children:[d.jsx(b,{level:1,children:M("title.digital_supplier_applications")}),d.jsx(P,{})]})}),d.jsx(p,{className:"mb-4",children:d.jsx(m,{children:d.jsx(x,{i18nKey:"text.supplier_application_detail",components:{tag:d.jsx("b",{})}})})}),d.jsxs(p,{className:"mb-4",children:[d.jsx(m,{size:12,xl:6,className:"mb-3 mb-xl-0",children:d.jsx(E,{items:[{label:M("label.supplier_name"),value:null==B?void 0:B.supplierName},{label:M("label.companyCode"),value:String(null==B?void 0:B.companyCode)},{label:M("label.companySubCode"),value:String(null==B?void 0:B.companySubCode)}]})}),d.jsx(m,{size:12,xl:6,children:d.jsx(E,{items:[{label:M("label.applicationNumber"),value:String(null==B?void 0:B.applicationNumber)},{label:M("label.applicationDate"),value:j(null==B?void 0:B.applicationDate).format("DD.MM.YYYY")},{label:M("label.applicationStatus"),value:null==B?void 0:B.applicationStatus}]})})]}),d.jsx(p,{children:d.jsx(m,{size:12,children:d.jsx(h,{...H,children:d.jsxs("form",{onSubmit:Q((e=>{V&&Z({applicationNumber:null==B?void 0:B.applicationNumber,digitalDocumentNumber:V.digitalDocumentNumber,result:"ONAY"})})),children:[d.jsx(p,{children:d.jsx(m,{size:12,children:d.jsx(v,{name:"contract",control:J,render:e=>d.jsx(f,{...e,checked:e.value,label:d.jsx(x,{i18nKey:"label.contract_text",values:{agreement:null==V?void 0:V.digitalDocumentNumber},components:{tag:d.jsx("b",{})}}),onChange:e=>{var a;return ee(e,null==(a=null==V?void 0:V.documents)?void 0:a[0])}})})})}),d.jsxs(p,{className:"mt-4",children:[d.jsx(m,{size:12,xl:6,className:"mb-3 mb-xl-0",children:d.jsx(N,{onClick:()=>{K({noCloseIcon:!0,content:d.jsx(U,{onConfirm:()=>{V&&Z({applicationNumber:null==B?void 0:B.applicationNumber,digitalDocumentNumber:V.digitalDocumentNumber,result:"RED"})}})})},appearance:S.INK,isDisabled:ae||$,type:"button",children:M("btn.reject_contract")})}),d.jsx(m,{size:12,xl:6,children:d.jsx(N,{type:"submit",appearance:S.CTA,isDisabled:ae||$,isLoading:$,children:M("btn.approve_contract")})})]})]})})})})]})})},U=({onConfirm:a})=>{const{t:l}=e(),{closeModal:s}=i();return d.jsxs("div",{children:[d.jsx(p,{children:d.jsx(m,{children:d.jsx("p",{children:l("text.reject_contract_confirmation")})})}),d.jsxs(p,{children:[d.jsx(m,{size:6,children:d.jsx(N,{onClick:s,appearance:S.INK,type:"button",children:l("btn.cancel")})}),d.jsx(m,{size:6,children:d.jsx(N,{onClick:()=>{a()},appearance:S.CTA,type:"button",children:l("btn.ok")})})]})]})};export{M 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.