1import{df as N,o as j,bn as _,r as w,e as T,f as C,a8 as L,j as s,O as M,R as $,X as O,Y as V,Z as B,d as P,h as D,_ as q,$ as k,a0 as G,K as v,aa as Y,n as z,a9 as H,bJ as Q,b as J}from"./index-2c9eaafb.js";import{F as K}from"./Form-bf4d6e45.js";function X(e){const r=atob(e.split(",")[1]),u=new ArrayBuffer(r.length),d=new Uint8Array(u);for(let n=0;n<r.length;n++)d[n]=r.charCodeAt(n);return new Blob([u],{type:"image/png"})}function Z(e,r){return new Promise(async(u,d)=>{const{name:n,size:b,type:m,identifier:U=null}=e??{};try{const p=await N.post(j.MEDIA.UNAUTHINCATE_INIT,{name:n,mimeType:m||"file unknown",size:b,access:"PUBLIC",identifier:r??U}),{data:{mediaId:y,presignedUrl:f}}=p,i=new FileReader;e!=null&&e.image?i.readAsDataURL(X(e==null?void 0:e.image)):i.readAsDataURL((e==null?void 0:e.originFileObj)||e);let h;i.onload=async()=>{var F;h=await W(((F=i.result)==null?void 0:F.toString())||""),await fetch(f,{body:h,method:"PUT"}).then(async()=>{await N.post(j.MEDIA.UNAUTHINCATE_FINALLY,{id:y}),u(y)})}}catch(p){_.error("There was an error uploading your image, please try again!"),d(p)}})}const W=async e=>(await fetch(e)).blob(),{createDynamicUrl:ee}=D,se=({documentFields:e,documentId:r,loading:u,setLoading:d})=>{const[n]=K.useForm(),[b,m]=w.useState({}),U=T(),{user:p}=C(t=>t==null?void 0:t.authSliceReducer),y=Z,f=(t,a,o)=>q(t)?(t.identifier=e[o].label,m(l=>({...l,[`field_${o}`]:[...l[`field_${o}`]||[],t]})),!0):(k({file:t,fileList:a}),G.LIST_IGNORE),i=({file:t,onSuccess:a})=>{setTimeout(()=>{a("ok")},0)},h=(t,a)=>(m(o=>{var S;const l=(S=o[`field_${a}`])==null?void 0:S.filter(I=>I.name!==t.name),c={...o,[`field_${a}`]:l};return n.setFieldsValue({[`field_${a}`]:l}),n.validateFields([`field_${a}`]),c}),!0),F=ee(j.SERVICES_FORM.REQUESTED_DOCUMENT,{id:r}),g=L(F),x=async()=>{try{await n.validateFields(),d(!0);const t=[],a={},o=Object.entries(b).map(([c,S])=>S.map(I=>y(I).then(R=>{const A=parseInt(c.replace("field_","")),E=e[A].label;return a[E]||(a[E]=[]),a[E].push(R),t.push(R),R})));await Promise.all(o.flat());const l={Media:t,content:a};await g.mutateAsync(l,{onSuccess:({data:c})=>{v.success({message:c!=null&&c.message?c==null?void 0:c.message:"Documents submitted successfully"}),p?U("/my-forms"):window.location.href="https://www.giftedfinancialservices.com/"}})}catch{v.error({message:"Failed to submit documents"})}finally{d(!1)}};return s.jsxs(M,{form:n,layout:"vertical",onFinish:x,onSubmitCapture:t=>{t.preventDefault(),n.validateFields()},children:[e.map((t,a)=>s.jsx($,{label:t.label,name:`field_${a}`,rules:[{required:!0,message:""},{validator:(o,l)=>O(o,l)}],children:s.jsx(V,{name:"customFile",onRemove:o=>h(o,a),beforeUpload:(o,l)=>f(o,l,a),customRequest:i,fileList:b[`field_${a}`]||[],multiple:!0,icon:!1,btnIcon:s.jsx(B,{}),innerText:"Drop files here or click to upload.",showUploadList:!0})},a)),s.jsx(P,{type:"primary",htmlType:"submit",loading:u,children:"Submit"})]})},{createDynamicUrl:te}=D,oe=()=>{const{id:e,documentId:r}=Y(),[u,d]=w.useState(),[n,b]=w.useState([]),[m,U]=w.useState(!1),p=te(j.SERVICES_FORM.REQUESTED_DOCUMENT,{id:Number(r)}),{data:y,isLoading:f}=z(p,!0,{enabled:!!r,onSuccess:i=>{const h=Object.keys(i.content).map(F=>({label:F,files:[]}));b(h),d({...i,documentFields:h})},onError:i=>{console.log(i)}});return s.jsx("div",{className:"forms-sec additional-forms-sec",children:s.jsx("div",{className:"form-top-sec",children:s.jsxs(H,{spinning:f||m,children:[s.jsx("div",{className:"logo-container",children:s.jsx("img",{src:Q,alt:"GFS Financial Services",className:"company-logo"})}),!y&&!f?s.jsxs("div",{className:"error-state",children:[s.jsx("h1",{children:"Documents Already Submitted"}),s.jsx("p",{children:"Your documents have already been submitted and are being reviewed by our team."})]}):s.jsxs(s.Fragment,{children:[s.jsx("h1",{children:"Additional Documents Required"}),s.jsx("p",{children:"Please upload the additional documents requested by your tax preparer"}),s.jsx("div",{className:"container",children:s.jsx(J,{className:"step-form-row",children:s.jsx("div",{className:"form-content-sec",children:s.jsx(se,{viewId:e,current:0,resFormMasterId:Number(e),documentId:Number(r),formValues:u,editLoading:f,editDetailName:"edit",documentFields:n,setLoading:U,loading:m})})})})]})]})})})};export{oe 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.