PageSourceSearch

https://knokuae.ai/assets/Add-C3CkNnnG.js

js knokuae.ai collected 2026-10-05 14:01:05 UTC 7,744 bytes, 1 lines download raw bytes

1import{u as A,e as H,h as P,r as c,j as e,B as L,S as v}from"./index-DQkzoM3f.js";import"./style-DSOHQhZi.js";import{C as T,a as i}from"./CRow-zMswK_D2.js";import{C as M}from"./CForm-DTVlxaqd.js";import{C as g}from"./CFormLabel-BbzezAvw.js";import{C as f}from"./CFormInput-Drw58q1J.js";import{a as O}from"./index.esm-DWQZSujt.js";import"./CFormControlWrapper-CeLdfEzz.js";import"./CFormControlValidation-CBnlSaHn.js";const U="_form_1otaq_1",z="_error_1otaq_24",G="_input_1otaq_30",K="_note_1otaq_57",V="_btn_1otaq_61",s={"form-group":"_form-group_1otaq_1","register-guard":"_register-guard_1otaq_8",form:U,error:z,input:G,note:K,btn:V},oe=()=>{var _,$;const{user:J,loading:W,error:Z}=A(),I=H(),b=(_=I.state)==null?void 0:_.residentId,j=($=I.state)==null?void 0:$.residentName,C=P();c.useEffect(()=>{(!b||!j)&&C("/dashboard")},[b,j,C]);const k=c.useRef(null),x=c.useRef(null),N=c.useRef(null),p=c.useRef(null),q=c.useRef(null),E=c.useRef(null),[t,r]=c.useState({chequeImg:"",chequeImgError:"",name:j,nameError:"",bankName:"",bankNameError:"",date:"",dateError:"",amount:"",amountError:"",chequeNumber:"",chequeNumberError:""}),R=m=>{const n=m.target.value,u=/^[a-zA-Z0-9\s]*$/;r(a=>({...a,bankName:n})),n.trim().length===0?r(a=>({...a,bankNameError:"Bank name is required."})):u.test(n)?r(a=>({...a,bankNameError:""})):r(a=>({...a,bankNameError:"Enter only letters, numbers, or spaces."}))},y=m=>{const n=m.target.value;r(a=>({...a,chequeNumber:n}));const u=/^\d{1,9}$/;n.length===0?r(a=>({...a,chequeNumberError:"Cheque number is required."})):u.test(n)?r(a=>({...a,chequeNumberError:""})):r(a=>({...a,chequeNumberError:"Cheque numbers are numbers only and up to 9 digits long."}))},F=m=>{const n=m.target.value;r(l=>({...l,date:n}));const u=new Date(n),a=new Date;n.trim().length===0?r(l=>({...l,dateError:"Cheque date is required."})):u<=a?r(l=>({...l,dateError:"Please select future date."})):r(l=>({...l,dateError:""}))},B=m=>{const n=m.target.value;if(r(a=>({...a,amount:n})),n.length===0){r(a=>({...a,amountError:"Cheque amount is required."}));return}/^\d+(\.\d{1,2})?$/.test(n)?parseFloat(n)>5e5?r(l=>({...l,amountError:"The amount cannot exceed 500,000 AED."})):r(l=>({...l,amountError:""})):r(a=>({...a,amountError:"Invalid format. Please enter a valid Dirham amount (e.g., 1234)."}))},D=m=>{const n=m.target.files[0];r(u=>({...u,chequeImg:n})),n?n.size>2*1024*1024?r(u=>({...u,chequeImgError:"Cheque image must be under 2MB."})):r(u=>({...u,chequeImgError:""})):r(u=>({...u,chequeImgError:"Cheque image is required!"}))},w=async m=>{var n,u,a,l;if(m.preventDefault(),t.name.trim().length===0){r(o=>({...o,nameError:"Resident name is required."}));return}else{if(x.current.value===""||t.bankNameError)return r(o=>({...o,bankNameError:"Bank name is required."})),x.current.focus(),!1;if(N.current.value===""||t.chequeNumberError)return r(o=>({...o,chequeNumberError:"Cheque number is required."})),N.current.focus(),!1;if(E.current.value===""||t.dateError)return r(o=>({...o,dateError:"Cheque date is required."})),E.current.focus(),!1;if(q.current.value===""||t.amountError)return r(o=>({...o,amountError:"Cheque amount is required."})),q.current.focus(),!1;if(((u=(n=p.current)==null?void 0:n.files[0])==null?void 0:u.size)>2*1024*1024)return r(o=>({...o,chequeImgError:"Cheque image must be under 2MB."})),p.current&&p.current.focus(),!1;{const o=new FormData;p.current&&p.current.files.length>0&&o.append("chequeImage_0",p.current.files[0]),o.append("bankName",x.current.value.trim()),o.append("chequeNumber",N.current.value),o.append("date",E.current.value),o.append("amount",q.current.value),o.append("residentId",b);for(let[d,h]of o.entries())console.log(d,h);try{const h=(await L.post("/addSingleCheque",o,{headers:{"Content-Type":"multipart/form-data"}})).data;console.log("data: ",h),h.success?v.fire({title:"Success",text:h.message,icon:"success",confirmButtonText:"OK"}).then(S=>{S.isConfirmed&&C(-1)}):v.fire({title:"Error!",text:h.message,icon:"error",confirmButtonText:"OK"})}catch(d){v.fire({title:"Error!",text:((l=(a=d==null?void 0:d.response)==null?void 0:a.data)==null?void 0:l.message)||"Something went wrong.",icon:"error",confirmButtonText:"OK"}),console.error("cheque add catch error: ",d.message)}}}};return e.jsx(c.Fragment,{children:e.jsx(T,{className:`${s["register-guard"]}`,children:e.jsx(i,{xs:12,children:e.jsxs(M,{ref:k,className:`row g-3 ${s.form}`,onSubmit:w,noValidate:!0,children:[e.jsx(i,{xs:12,className:`poppins-regular ${s["form-group"]}`,children:e.jsx("h6",{className:"mt-2",children:"Upload Cheque"})}),e.jsxs(i,{xs:12,lg:6,className:`poppins-regular ${s["form-group"]}`,children:[e.jsxs(g,{className:"poppins-regular",htmlFor:"name",children:["Name",e.jsx("span",{className:"text-danger",children:e.jsx("sup",{children:"*"})})]}),e.jsx(f,{type:"text",id:"name",placeholder:"Enter Cheque Number",value:t.name,className:`poppins-regular ${s.input}`,readOnly:!0}),t.nameError&&e.jsx("p",{className:`${s.error} poppins-regular`,children:t.nameError})]}),e.jsxs(i,{xs:12,lg:6,className:`poppins-regular ${s["form-group"]}`,children:[e.jsxs(g,{className:"poppins-regular",htmlFor:"bank_name",children:["Bank Name",e.jsx("span",{className:"text-danger",children:e.jsx("sup",{children:"*"})})]}),e.jsx(f,{ref:x,type:"text",id:"bank_name",placeholder:"Enter Bank Name",value:t.bankName,onChange:R,className:`poppins-regular ${s.input}`,maxLength:80}),e.jsx("p",{className:s.note,children:"Note*: Bank name Maximum 80 characters long."}),t.bankNameError&&e.jsx("p",{className:`${s.error} poppins-regular`,children:t.bankNameError})]}),e.jsxs(i,{xs:12,lg:6,className:`poppins-regular ${s["form-group"]}`,children:[e.jsxs(g,{className:"poppins-regular",htmlFor:"cheque_number",children:["Cheque Number",e.jsx("span",{className:"text-danger",children:e.jsx("sup",{children:"*"})})]}),e.jsx(f,{ref:N,type:"text",id:"cheque_number",placeholder:"Enter Cheque Number",value:t.chequeNumber,onChange:y,className:`poppins-regular ${s.input}`,maxLength:9}),t.chequeNumberError&&e.jsx("p",{className:`${s.error} poppins-regular`,children:t.chequeNumberError})]}),e.jsxs(i,{xs:12,lg:6,className:`poppins-regular position-relative ${s["form-group"]}`,children:[e.jsxs(g,{className:"poppins-regular",htmlFor:"date",children:["Cheque Date",e.jsx("span",{className:"text-danger",children:e.jsx("sup",{children:"*"})})]}),e.jsx(f,{ref:E,type:"date",className:`poppins-regular  ${s.input}`,value:t.date,onChange:F}),t.dateError&&e.jsx("p",{className:`${s.error} poppins-regular`,children:t.dateError})]}),e.jsxs(i,{xs:12,lg:6,className:`mb-3 poppins-regular ${s["form-group"]}`,children:[e.jsxs(g,{className:"poppins-regular",htmlFor:"amount",children:["Amount (In AED)",e.jsx("span",{className:"text-danger",children:e.jsx("sup",{children:"*"})})]}),e.jsx(f,{ref:q,type:"text",id:"cheque_number",placeholder:"Enter Cheque Number",value:t.amount,onChange:B,className:`poppins-regular ${s.input}`,maxLength:8}),t.amountError&&e.jsx("p",{className:`${s.error} poppins-regular`,children:t.amountError})]}),e.jsxs(i,{xs:12,lg:6,className:`poppins-regular ${s["form-group"]}`,children:[e.jsx(g,{className:"poppins-regular",htmlFor:"chequeImag",children:"Cheque Image"}
1),e.jsx(f,{ref:p,type:"file",id:"chequeImag",onChange:D,className:`poppins-regular ${s.input}`,accept:"image/png, image/jpeg, image/jpg, image/tiff, image/heif, image/heic, image/webp"}),e.jsx("p",{className:s.note,children:"Upload a maximum of 2MB image and accept image format (PNG, JPEG, JPG, TIFF, HEIF, HEIC, and WebP)."}),t.chequeImgError&&e.jsx("p",{className:`${s.error} poppins-regular`,children:t.chequeImgError})]}),e.jsx(O,{type:"submit",color:"primary",className:`poppins-regular ${s.btn}`,children:"Submit"})]})})})})};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.