1import{j as r}from"./jsx-runtime-D_zvdyIk.js";import{u as R,f as V,r as h}from"./createLucideIcon-CiWnlb16.js";import{d as q,c as z}from"./addLoader-p8WLB-bt.js";import{e as l,of as A,og as M,oh as O,oi as G,l7 as H,fN as a,oj as J,ok as j,ol as n,om as K,on as N,gE as Q,L as T,oo as U,op as u,oq as W,or as C,os as X,ot as Y,ou as Z,ov as $}from"./loginCallback-DUlVA6A0.js";import{B as y}from"./index-CQOuJFSK.js";import{a as w}from"./Select-YNaQnfBW.js";/* empty css */import{u as ee}from"./notistack.esm-h7EINNRQ.js";import{E as c}from"./ErrorMessage-BzkwuuEb.js";import{f as D,C as re,l as E,i as S}from"./creditor-info-readonly-C7ZbYE8m.js";import"./config.release-CKeoGYk7.js";import"./creditorTypes-B9YPhGF4.js";import"./Person-CoHVHeCH.js";const f={anchorOrigin:{vertical:"top",horizontal:"right"}};function pe(){const b=R(),{id:d}=V(),p=d==="create",s=l(A),x=l(M),P=l(O),k=l(G),g=l(H),{enqueueSnackbar:m}=ee(),o=e=>U(k,e),i=e=>{o(e)&&a(W(e))};h.useEffect(()=>{F()},[]);const F=async()=>{a(J()),a(j({})),a(n(!0));try{if(!p){const e=await a(K({id:d})).unwrap();e?.debtor?.id&&await a(N({debtorId:e.debtor.id}))}}finally{a(n(!1))}},L=e=>{i("debtor");const t=e?{id:e.value,value:e.label}:null;a(u({debtor:t})),a(C(null)),a(X()),t&&a(N({debtorId:t.id}))},I=h.useMemo(()=>Object.entries(g).sort(([e],[t])=>Number(t)-Number(e)).map(([e,t])=>({label:Number(e)===Q.Active?"ÐкÑивнÑе":"ÐавеÑÑеннÑе",options:t.map(v=>({value:v.id,label:v.value}))})),[g]),_=e=>{i("creditor"),a(C(x.find(t=>t.creditorCredentials===e)??null))},B=async()=>{const{ok:e,errors:t}=Y(s);if(a(j(t)),!e){m("ÐаполниÑе обÑзаÑелÑнÑе полÑ",{variant:"warning",...f});return}a(n(!0));try{p?await a(Z({body:s})).unwrap():await a($({id:d,body:s})).unwrap(),m("СоÑ
Ñанено ÑÑпеÑно",{variant:"success",...f}),b(-1)}catch{a(n(!1)),m("ÐÑибка ÑоÑ
ÑанениÑ",{variant:"error",...f})}};return P?r.jsx(T,{}):r.jsxs(q,{type:"section",className:"h-full grid grid-cols-1 xl:grid-cols-[20%_80%]",children:[r.jsx(z,{type:"div",toggle:null,className:"hidden xl:block h-full bg-white border-r border-[#e0e9f1] !z-20",children:r.jsx(y,{className:"page-filters-button",type:"button",value:"Ðазад",onClick:()=>b(-1)})}),r.jsx("div",{className:"min-h-screen flex justify-center py-5 px-10 text-[#334e68] overflow-y-auto",children:r.jsxs("div",{className:"w-full bg-white rounded-xl shadow-[0_4px_20px_rgba(0,0,0,0.04)] border border-[#e0e9f1] p-10",children:[r.jsx("div",{className:"flex justify-between items-center border-b-2 border-[#f7fafd] mb-8",children:r.jsx("h2",{className:"text-[22px] font-bold uppercase text-[color:var(--page-content-title)] tracking-wide m-0",children:"ÐÑоÑенÑÑ Ð¿Ð¾ ÑÑебованиÑ"})}),r.jsxs("form",{onSubmit:e=>e.preventDefault(),className:"flex flex-col gap-2",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[r.jsxs("div",{id:"field-container-debtor",className:"flex flex-col gap-1",children:[r.jsx(w,{options:I,isSearchable:!0,label:"Ðолжник",value:s.debtor?.id?{value:s.debtor.id,label:s.debtor.value}:null,placeholder:"ÐÑбеÑиÑе должника...",onChange:L}),r.jsx(c,{message:o("debtor")})]}),r.jsxs("div",{id:"field-container-creditor",className:"flex flex-col gap-1",children:[r.jsx(w,{options:x.map(e=>({value:e.creditorCredentials,label:e.creditorName})),label:"ÐÑедиÑоÑ",value:s.creditor?{value:s.creditor.creditorCredentials,label:s.creditor.creditorName}:null,placeholder:s.debtor?"ÐÑбеÑиÑе кÑедиÑоÑа...":"СнаÑала вÑбеÑиÑе должника",isSearchable:!0,isDisabled:!s.debtor,onChange:e=>_(e?e.value:null)}),r.jsx(c,{message:o("creditor")})]})]}),s.creditor&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:D.dividerClasses}),r.jsx(re,{creditor:s.creditor})]}),r.jsx("div",{className:D.dividerClasses}),r.jsxs("div",{id:"field-container-sum",children:[r.jsx("label",{className:E(o("sum")),children:"СÑмма по пÑоÑенÑам"}),r.jsx("input",{type:"number",className:S(o("sum")),value:s.sum??"",placeholder:"0.00",onChange:e=>{i("sum"),a(u({sum:e.target.value===""?null:Number(e.target.value)}))}}),r.jsx(c,{message:o("sum")})]}),r.jsxs("div",{id:"field-container-confirmationDocument",children:[r.jsx("label",{className:E(o("confirmationDocument")),children:"ÐодÑвеÑждаÑÑий докÑÐ¼ÐµÐ½Ñ (комменÑаÑий)"}),r.jsx("textarea",{rows:4,className:S(o("confirmationDocument")),value:s.confirmationDocument??"",placeholder:"ÐаннÑе док
1ÑменÑа, подÑвеÑждаÑÑего пÑоÑенÑÑ...",onChange:e=>{i("confirmationDocument"),a(u({confirmationDocument:e.target.value}))}}),r.jsx(c,{message:o("confirmationDocument")})]}),r.jsx("div",{className:"mt-8 flex justify-end",children:r.jsx(y,{type:"button",className:"cr-button cr-button--form",value:"СоÑ
ÑаниÑÑ",onClick:B})})]})]})})]})}export{pe 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.