PageSourceSearch

https://replit-create-user11028.replit.app/assets/KycPublic-DY2e_2IG.js

js replit-create-user11028.replit.app collected 2026-10-03 03:58:28 UTC 13,223 bytes, 1 lines download raw bytes

1import{r as o,j as e}from"./index-kqYmxY6V.js";import{C as i}from"./card-BXRS6EyN.js";import{B as j}from"./button-2Cw4Wmda.js";import{T as H}from"./textarea-C84qXrxX.js";import{B as J}from"./badge-DQ3Bbijr.js";import{L as R}from"./loader-circle-B-w5Rips.js";import{C as v}from"./circle-x-Dh3DmP8i.js";import{C as y}from"./circle-check-D5_dRMo-.js";import{S as P}from"./shield-DWMc6-Sd.js";import{F as O}from"./file-text-BP50_VFx.js";import{U as q}from"./user-I5zvLJCz.js";import{B as z}from"./briefcase-jC_UycRt.js";import{C as A}from"./credit-card-1u1zRYuS.js";import{S as K}from"./scale-Doe-hld_.js";import{H as W}from"./house-BAeKQQCa.js";import{B as G}from"./banknote-CV9OoHGi.js";import{T as Q}from"./triangle-alert-vuRZJuY3.js";import{M as V}from"./map-pin-x1c0KsGe.js";import{P as Z}from"./pen-DLByk1IC.js";function je(){const[h,x]=o.useState(!0),[c,m]=o.useState(""),[_,E]=o.useState(null),[r,S]=o.useState(""),[k,M]=o.useState(""),[N,C]=o.useState(!1),[F,U]=o.useState(!1),[X,$]=o.useState(!1),n=o.useRef(null),u=o.useRef(null),f=window.location.pathname.split("/kyc/")[1];o.useEffect(()=>{if(!f){m("رابط غير صالح"),x(!1);return}fetch(`/api/kyc/view/${f}`).then(async s=>{if(!s.ok){const a=await s.json();throw new Error(a.error)}return s.json()}).then(E).catch(s=>m(s.message)).finally(()=>x(!1))},[f]),o.useEffect(()=>{if(r==="approved"&&n.current){const s=n.current,a=s.getContext("2d");a&&(a.fillStyle="#ffffff",a.fillRect(0,0,s.width,s.height),a.strokeStyle="#1a1a2e",a.lineWidth=2,a.lineCap="round",a.lineJoin="round")}},[r]);const D=s=>{const a=n.current,l=a.getBoundingClientRect(),p=a.width/l.width,g=a.height/l.height;return"touches"in s?{x:(s.touches[0].clientX-l.left)*p,y:(s.touches[0].clientY-l.top)*g}:{x:(s.clientX-l.left)*p,y:(s.clientY-l.top)*g}},L=s=>{s.preventDefault(),$(!0),u.current=D(s)},T=s=>{if(!X||!n.current||!u.current)return;s.preventDefault();const a=n.current.getContext("2d");if(!a)return;const l=D(s);a.beginPath(),a.moveTo(u.current.x,u.current.y),a.lineTo(l.x,l.y),a.stroke(),u.current=l},w=()=>{$(!1),u.current=null},I=()=>{const s=n.current;if(!s)return;const a=s.getContext("2d");a&&(a.fillStyle="#ffffff",a.fillRect(0,0,s.width,s.height))},Y=async()=>{if(r){if(r==="approved"&&n.current){const s=n.current.getContext("2d");if(s&&!s.getImageData(0,0,n.current.width,n.current.height).data.some((p,g)=>g%4!==3&&p!==255)){alert("يرجى التوقيع أولاً");return}}C(!0);try{const s={decision:r,notes:k};r==="approved"&&n.current&&(s.signature_data=n.current.toDataURL("image/png"));const a=await fetch(`/api/kyc/respond/${f}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const l=await a.json();throw new Error(l.error)}U(!0)}catch(s){alert(s.message||"حدث خطأ")}finally{C(!1)}}};if(h)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center",children:e.jsx(R,{className:"w-10 h-10 animate-spin text-slate-400"})});if(c)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsxs(i,{className:"max-w-md w-full p-8 text-center",children:[e.jsx(v,{className:"w-16 h-16 text-red-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-bold text-red-600 mb-2",children:"خطأ"}),e.jsx("p",{className:"text-muted-foreground",children:c})]})});if(F)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsx(i,{className:"max-w-md w-full p-8 text-center",children:r==="approved"?e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"w-20 h-20 text-green-500 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-green-700 mb-2",children:"تمت الموافقة بنجاح"}),e.jsx("p",{className:"text-muted-foreground",children:"شكراً لك. تم تسجيل موافقتك وتوقيعك بنجاح."})]}):e.jsxs(e.Fragment,{children:[e.jsx(v,{className:"w-20 h-20 text-red-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-red-600 mb-2",children:"تم تسجيل الرفض"}),e.jsx("p",{className:"text-muted-foreground",children:"شكراً لك. تم تسجيل قرارك."})]})})});if(!_)return null;const{request:t,investor:B}=_;return B.status!=="pending"?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsxs(i,{className:"max-w-md w-full p-8 text-center",children:[e.jsx(P,{className:"w-16 h-16 text-slate-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:"تم الرد مسبقاً"}),e.jsx("p",{className:"text-muted-foreground",children:"لقد تم تسجيل ردك على هذا الطلب مسبقاً."})]})}):B.already_approved_by_other?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 flex items-center justify-center p-4",dir:"rtl",children:e.jsxs(i,{className:"max-w-md w-full p-8 text-center",children:[e.jsx(y,{className:"w-16 h-16 text-amber-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:"تمت الموافقة من تاجر آخر"}),e.jsx("p",{className:"text-muted-foreground",children:"نعتذر، تمت الموافقة على هذا الطلب من تاجر آخر."})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 py-6 px-4",dir:"rtl",children:e.jsxs("div",{className:"max-w-2xl mx-auto 
1space-y-4",children:[e.jsxs(i,{className:"p-6 text-center bg-white border-0 shadow-sm",children:[e.jsx("div",{className:"w-14 h-14 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-2xl flex items-center justify-center mx-auto mb-3",children:e.jsx(O,{className:"w-7 h-7 text-white"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:"طلب موافقة شراء"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"يرجى مراجعة البيانات واتخاذ القرار"})]}),e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsxs("h2",{className:"font-bold text-base mb-4 flex items-center gap-2 text-slate-700",children:[e.jsx(q,{className:"w-5 h-5 text-blue-500"}),"بيانات المتقدم"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(d,{label:"الاسم",value:t.applicant_name}),e.jsx(d,{label:"رقم الهوية",value:t.identity_number}),t.phone&&e.jsx(d,{label:"الجوال",value:t.phone,dir:"ltr"}),t.residence&&e.jsx(d,{label:"مكان الإقامة",value:t.residence})]})]}),(t.workplace||t.position)&&e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsxs("h2",{className:"font-bold text-base mb-4 flex items-center gap-2 text-slate-700",children:[e.jsx(z,{className:"w-5 h-5 text-blue-500"}),"بيانات العمل والدخل"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.workplace&&e.jsx(d,{label:"جهة العمل",value:t.workplace}),t.position&&e.jsx(d,{label:"المنصب",value:t.position}),t.salary&&e.jsx(d,{label:"الراتب الشهري",value:`${Number(t.salary).toLocaleString()} ريال`,highlight:!0}),t.obligations&&e.jsx(d,{label:"الالتزامات الشهرية",value:`${Number(t.obligations).toLocaleString()} ريال`}),t.remaining_salary&&e.jsx(d,{label:"المتبقي من الراتب",value:`${Number(t.remaining_salary).toLocaleString()} ريال`,highlight:!0})]})]}),e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsxs("h2",{className:"font-bold text-base mb-4 flex items-center gap-2 text-slate-700",children:[e.jsx(A,{className:"w-5 h-5 text-blue-500"}),"الالتزامات المالية"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{icon:e.jsx(K,{className:"w-4 h-4"}),label:"قضايا محكمة سابقة",value:t.has_court_case,detail:t.court_case_details}),e.jsx(b,{icon:e.jsx(W,{className:"w-4 h-4"}),label:"قرض عقاري",value:t.has_real_estate_loan,detail:t.real_estate_installment?`${Number(t.real_estate_installment).toLocaleString()} ريال/شهر`:void 0}),e.jsx(b,{icon:e.jsx(G,{className:"w-4 h-4"}),label:"قرض شخصي",value:t.has_personal_loan,detail:t.personal_loan_amount?`${Number(t.personal_loan_amount).toLocaleString()} ريال`:void 0}),e.jsx(b,{icon:e.jsx(Q,{className:"w-4 h-4"}),label:"مديونيات خارج البنك",value:t.has_external_debts,detail:t.external_debts_amount?`${Number(t.external_debts_amount).toLocaleString()} ريال`:void 0}),e.jsx(b,{icon:e.jsx(V,{className:"w-4 h-4"}),label:"مستأجر",value:t.is_renting,detail:t.rent_amount?`${Number(t.rent_amount).toLocaleString()} ريال/شهر`:void 0})]})]}),(t.prepaid_cards_count||t.product_name)&&e.jsx(i,{className:"p-5 bg-gradient-to-r from-blue-50 to-indigo-50 border-blue-200 shadow-sm",children:e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[t.prepaid_cards_count&&e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-blue-600 font-medium",children:"عدد المنتج"}),e.jsx("p",{className:"text-3xl font-bold text-blue-800 mt-1",children:t.prepaid_cards_count})]}),t.product_name&&e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-blue-600 font-medium",children:"اسم السلعة"}),e.jsx("p",{className:"text-xl font-bold text-blue-800 mt-1",children:t.product_name})]})]})}),t.notes&&e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsx("p",{className:"text-sm text-muted-foreground font-medium mb-1",children:"ملاحظات"}),e.jsx("p",{className:"text-sm",children:t.notes})]}),e.jsxs(i,{className:"p-5 bg-white border-0 shadow-sm",children:[e.jsx("h2",{className:"font-bold text-base mb-4 text-center text-slate-700",children:"اتخذ قرارك"}),e.jsxs("div",{className:"flex gap-3 mb-4",children:[e.jsxs(j,{className:`flex-1 h-14 text-base gap-2 ${r==="approved"?"bg-green-600 hover:bg-green-700 text-white":"bg-green-50 text-green-700 hover:bg-green-100 border border-green-200"}`,variant:r==="approved"?"default":"outline",onClick:()=>S("approved"),"data-testid":"btn-kyc-approve",children:[e.jsx(y,{className:"w-5 h-5"}),"موافقة"]}),e.jsxs(j,{className:`flex-1 h-14 text-base gap-2 ${r==="rejected"?"bg-red-600 hover:bg-red-700 text-white":"bg-red-50 text-red-700 hover:bg-red-100 border border-red-200"}`,variant:r==="rejected"?"default":"outline",onClick:()=>S("rejected"),"data-testid":"btn-kyc-reject",children:[e.jsx(v,{className:"w-5 h-5"}),"رفض"]})]}),r&&e.jsxs("div",{className:"space-y-4 animate-in slide-in-from-top-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-600 mb-1 block",children:"ملاحظات (اختياري)"}),e.jsx(H,{value:k,onChange:s=>M(s.target.value),placeholder:"أضف ملاحظاتك...",rows:2,"data-testid":"textarea-kyc-response-notes"})]}
1),r==="approved"&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium text-slate-600 mb-2 flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4"}),"التوقيع الإلكتروني *"]}),e.jsx("div",{className:"border-2 border-dashed border-slate-300 rounded-xl overflow-hidden bg-white",children:e.jsx("canvas",{ref:n,width:560,height:180,className:"w-full cursor-crosshair touch-none",onMouseDown:L,onMouseMove:T,onMouseUp:w,onMouseLeave:w,onTouchStart:L,onTouchMove:T,onTouchEnd:w,"data-testid":"canvas-kyc-signature"})}),e.jsx(j,{size:"sm",variant:"ghost",onClick:I,className:"mt-1 text-xs text-muted-foreground","data-testid":"btn-clear-signature",children:"مسح التوقيع"})]}),e.jsxs(j,{onClick:Y,disabled:N,className:`w-full h-12 text-base gap-2 ${r==="approved"?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700"}`,"data-testid":"btn-kyc-submit",children:[N?e.jsx(R,{className:"w-5 h-5 animate-spin"}):e.jsx(P,{className:"w-5 h-5"}),N?"جاري التسجيل...":r==="approved"?"تأكيد الموافقة والتوقيع":"تأكيد الرفض"]})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pb-4",children:"هذا الرابط صالح لمرة واحدة فقط وينتهي بعد 72 ساعة"})]})})}function d({label:h,value:x,highlight:c,dir:m}){return e.jsxs("div",{className:`p-3 rounded-lg ${c?"bg-blue-50 border border-blue-100":"bg-slate-50"}`,children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:h}),e.jsx("p",{className:`text-sm font-medium mt-0.5 ${c?"text-blue-800":""}`,dir:m,children:x})]})}function b({icon:h,label:x,value:c,detail:m}){return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg ${c?"bg-amber-50 border border-amber-100":"bg-slate-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h,e.jsx("span",{className:"text-sm",children:x})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m&&c&&e.jsx("span",{className:"text-xs font-medium text-amber-700",children:m}),e.jsx(J,{className:c?"bg-amber-100 text-amber-800 text-xs":"bg-green-100 text-green-800 text-xs",children:c?"نعم":"لا"})]})]})}export{je 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.