1import{g as I,d as E,v as j,r as y,s as b,j as e,B as R,h as N,a as K,X as Y,F as T}from"./index-BDkIXZro.js";import{r as i}from"./vendor-DaxRCwWg.js";import{q,t as O,w as U,x as V,l as X,u as B}from"./firebase-Cv3R1fLt.js";import{D as F}from"./DropdownMenu-r0Y_tSjS.js";import{S as M}from"./search-B0Zyaqcg.js";import{X as G}from"./x-circle-C0F7ZDCW.js";import"./i18n-ZJY9W6Px.js";/** 2 * @license lucide-react v0.344.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const v=I("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);function se(){const[z,w]=i.useState([]),[A,_]=i.useState(!0),[t,u]=i.useState(null),[d,k]=i.useState(!1),[S,g]=i.useState(null),[c,o]=i.useState("all"),[h,$]=i.useState("");i.useEffect(()=>{L()},[]);const L=async()=>{try{const s=q(E,"users");let a=[];const m=["pending","approved","rejected"];for(const n of m)try{const l=O(s,U("kycStatus","==",n)),p=await V(l);for(const r of p.docs){const x=r.data();try{const f={id_front:await j(y(b,`users/${r.id}/kyc/id_front`)),id_back:await j(y(b,`users/${r.id}/kyc/id_back`)),selfie:await j(y(b,`users/${r.id}/kyc/selfie`))};a.push({id:r.id,userId:r.id,userEmail:x.email,status:x.kycStatus,submittedAt:x.kycSubmittedAt?.toDate().toISOString()||new Date().toISOString(),kycData:x.kycData||{},documents:f})}catch(f){console.error(`Error loading documents for user ${r.id}:`,f);continue}}}catch(l){console.error(`Error loading submissions for status ${n}:`,l);continue}a.sort((n,l)=>new Date(l.submittedAt).getTime()-new Date(n.submittedAt).getTime()),w(a),g(null)}catch(s){console.error("Error loading KYC submissions:",s),g("Une erreur est survenue lors du chargement des soumissions KYC")}finally{_(!1)}},D=async(s,a,m)=>{if(s){k(!0);try{const n=X(E,"users",s),l={kycStatus:a,kycReviewedAt:new Date().toISOString()};a==="rejected"&&m?l.kycRejectionReason=m:l.kycRejectionReason=null,await B(n,l),w(p=>p.map(r=>r.userId===s?{...r,status:a}:r)),u(null)}catch(n){console.error("Error updating KYC status:",n),g("Une erreur est survenue lors de la mise à jour du statut")}finally{k(!1)}}},C=z.filter(s=>c==="all"||s.status===c).filter(s=>{if(!h)return!0;const a=h.toLowerCase();return s.userEmail.toLowerCase().includes(a)||s.kycData.firstName&&s.kycData.firstName.toLowerCase().includes(a)||s.kycData.lastName&&s.kycData.lastName.toLowerCase().includes(a)});return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"bg-gray-800 rounded-lg p-4",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{}),e.jsx("h2",{className:"text-lg font-semibold",children:"Gestion des KYC"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(M,{size:20,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Rechercher par email, nom...",value:h,onChange:s=>$(s.target.value),className:"w-full bg-gray-700 rounded-lg pl-10 pr-4 py-2 text-white placeholder-gray-400"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>o("all"),className:`px-4 py-2 rounded-lg ${c==="all"?"bg-blue-600 text-white":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,children:"Tous"}),e.jsx("button",{onClick:()=>o("pending"),className:`px-4 py-2 rounded-lg ${c==="pending"?"bg-yellow-600 text-white":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,children:"En attente"}),e.jsx("button",{onClick:()=>o("approved"),className:`px-4 py-2 rounded-lg ${c==="approved"?"bg-green-600 text-white":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,children:"Approuvés"}),e.jsx("button",{onClick:()=>o("rejected"),className:`px-4 py-2 rounded-lg ${c==="rejected"?"bg-red-600 text-white":"bg-gray-700 text-gray-300 hover:bg-gray-600"}`,children:"Refusés"})]})]}),S&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500 rounded-lg p-4 mb-6 flex items-start gap-3",children:[e.jsx(R,{size:24,className:"text-red-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-red-500",children:"Erreur"}),e.jsx("p",{className:"text-sm text-red-400",children:S})]})]}),A?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(N,{size:32,className:"animate-spin text-blue-500"})}):C.length>0?e.jsx("div",{className:"space-y-4",children:C.map(s=>e.jsxs("div",{className:"bg-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium",children:[s.kycData.firstName," ",s.kycData.lastName]}),e.jsx("p",{className:"text-sm text-gray-400",children:s.userEmail})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-3 py-1 rounded-full text-sm ${s.status==="pending"?"bg-yellow-500/20 text-yellow-500":s.status==="approved"?"bg-green-500/20 text-green-500":"bg-red-500/20 text-red-500"}`,children:s.status==="pending"?"En attente":s.status==="approved"?"Approuvé":"Refusé"}),e.jsx("button",{onClick:()=>u(s),className:"p-2 hover:bg-gray-600 rounded-lg transition-colors",children:e.jsx(K,{size:20})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("a",{href:s.documents.id_front,target:"_blank",rel:"noopener noreferrer",className:"bg-gray-800 rounded-lg p-3 flex items-center justify-between hover:bg-gray-700 transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Recto du document"}),e.jsx(v,{size:16})]}),e.jsxs("a",{href:s.documents.id_back,target:"_blank",rel:"noopener noreferrer",className:"bg-gray-800 rounded-lg p-3 flex items-center justify-between hover:bg-gray-700 transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Verso du document"}),e.jsx(v,{size:16})]}),e.jsxs("a",{href:s.documents.selfie,target:"_blank",rel:"noopener noreferrer",className:"bg-gray-800 rounded-lg p-3 flex items-center justify-between hover:bg-gray-700 transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Selfie"}),e.jsx(v,{size:16})]})]})]},s.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(R,{size:48,className:"mx-auto mb-4 text-gray-500"}),e.jsx("p",{className:"text-gray-400",children:"Aucune soumission KYC trouvée"})]})]}),t&&e.jsx("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-gray-800 rounded-lg p-4 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Détails de la soumission KYC"}),e.jsx("button",{onClick:()=>u(null),className:"text-gray-400 hover:text-white",children:e.jsx(Y,{size:24})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-400 mb-2",children:"Informations personnelles"}),e.jsxs("div",{className:"bg-gray-700 rounded-lg p-3 grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400",children:"Nom complet"}),e.jsxs("p",{className:"font-medium",children:[t.kycData.firstName," ",t.kycData.lastName]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400",children:"Email"}),e.jsx("p",{className:"font-medium",children:t.userEmail})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400",children:"Date de naissance"}),e.jsx("p",{className:"font-medium",children:t.kycData.dateOfBirth})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400",children:"Nationalité"}),e.jsx("p",{className:"font-medium",children:t.kycData.nationality})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-400 mb-2",children:"Documents"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"aspect-[3/2] bg-gray-900 rounded-lg overflow-hidden mb-1",children:e.jsx("img",{src:t.documents.id_front,alt:"Recto du document",className:"w-full h-full object-contain"})}),e.jsx("p",{className:"text-xs text-center text-gray-400",children:"Recto"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"aspect-[3/2] bg-gray-900 rounded-lg overflow-hidden mb-1",children:e.jsx("img",{src:t.documents.id_back,alt:"Verso du document",className:"w-full h-full object-contain"})}),e.jsx("p",{className:"text-xs text-center text-gray-400",children:"Verso"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"aspect-[3/2] bg-gray-900 rounded-lg overflow-hidden mb-1",children:e.jsx("img",{src:t.documents.selfie,alt:"Selfie",className:"w-full h-full object-contain"})}),e.jsx("p",{className:"text-xs text-center text-gray-400",children:"Selfie"})]})]})]}),t.status==="pending"&&e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>D(t.userId,"approved"),disabled:d,className:"flex-1 bg-green-600 hover:bg-green-700 disabled:opacity-50 text-white rounded-lg py-3 font-medium flex items-center justify-center gap-2",children:[d?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(T,{size:16}),e.jsx("span",{children:"Approuver"})]}),e.jsxs("button",{onClick:()=>{const s=window.prompt("Raison du refus:");s&&D(t.userId,"rejected",s)},disabled:d,className:"flex-1 bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white rounded-lg py-3 font-medium flex items-center justify-center gap-2",children:[d?e.jsx(N,{size:16,className:"animate-spin"}):e.jsx(G,{size:16}),e.jsx("span",{children:"Refuser"})]})]})]})]})})]})}export{se as AdminKYC};
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.