3 lines
15 KiB
JavaScript
3 lines
15 KiB
JavaScript
import{s as Be,o as Me,n as ae,r as qe}from"../chunks/DHedsUi_.js";import{S as Oe,i as Se,d as h,k as ne,l as L,m as j,q as de,a as X,b as o,n as oe,r as K,u as d,c as m,e as w,o as ie,g as C,v as W,f as Y,w as Ue,h as p,p as ue,j as E,t as Z,s as fe,x as Fe,y as me,z as le,D as He}from"../chunks/G8UKEBBn.js";import{e as Ie,u as Re,o as Xe}from"../chunks/C1tDbyYL.js";import{a as De}from"../chunks/DjUyxgK6.js";import{U as Ge}from"../chunks/BYJWe3D5.js";import{P as Je}from"../chunks/CLS07P5K.js";import{C as Le}from"../chunks/zQrtb5Kq.js";import{X as Ke}from"../chunks/C_l6I72z.js";import{A as Qe}from"../chunks/eC_GsYA7.js";import{T as We}from"../chunks/7MWtQ_HQ.js";function Ae(u,e,t){const s=u.slice();return s[22]=e[t],s[24]=t,s}function Ye(u,e,t){const s=u.slice();return s[19]=e[t],s}function je(u){let e,t,s,a,f;return t=new Le({props:{size:14}}),{c(){e=p("div"),ue(t.$$.fragment),s=E(),a=Z(u[4]),this.h()},l(n){e=m(n,"DIV",{class:!0});var r=w(e);ie(t.$$.fragment,r),s=C(r),a=Y(r,u[4]),r.forEach(h),this.h()},h(){d(e,"class","flex items-center gap-2 text-sm px-4 py-3 rounded-lg mb-4 bg-green-50 dark:bg-green-950/30 text-green-700 dark:text-green-300")},m(n,r){X(n,e,r),oe(t,e,null),o(e,s),o(e,a),f=!0},p(n,r){(!f||r&16)&&fe(a,n[4])},i(n){f||(j(t.$$.fragment,n),f=!0)},o(n){L(t.$$.fragment,n),f=!1},d(n){n&&h(e),ne(t)}}}function Ze(u){let e,t=[],s=new Map,a,f=Ie(u[0]);const n=r=>r[22].id;for(let r=0;r<f.length;r+=1){let l=Ae(u,f,r),g=n(l);s.set(g,t[r]=Ne(g,l))}return{c(){e=p("div");for(let r=0;r<t.length;r+=1)t[r].c();this.h()},l(r){e=m(r,"DIV",{class:!0});var l=w(e);for(let g=0;g<t.length;g+=1)t[g].l(l);l.forEach(h),this.h()},h(){d(e,"class","bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 overflow-hidden")},m(r,l){X(r,e,l);for(let g=0;g<t.length;g+=1)t[g]&&t[g].m(e,null);a=!0},p(r,l){l&769&&(f=Ie(r[0]),me(),t=Re(t,l,n,1,r,f,s,e,Xe,Ne,null,Ae),de())},i(r){if(!a){for(let l=0;l<f.length;l+=1)j(t[l]);a=!0}},o(r){for(let l=0;l<t.length;l+=1)L(t[l]);a=!1},d(r){r&&h(e);for(let l=0;l<t.length;l+=1)t[l].d()}}}function et(u){let e,t=Ie([1,2]),s=[];for(let a=0;a<2;a+=1)s[a]=lt(Ye(u,t,a));return{c(){e=p("div");for(let a=0;a<2;a+=1)s[a].c();this.h()},l(a){e=m(a,"DIV",{class:!0});var f=w(e);for(let n=0;n<2;n+=1)s[n].l(f);f.forEach(h),this.h()},h(){d(e,"class","space-y-2")},m(a,f){X(a,e,f);for(let n=0;n<2;n+=1)s[n]&&s[n].m(e,null)},p:ae,i:ae,o:ae,d(a){a&&h(e),Fe(s,a)}}}function tt(u){let e,t,s,a,f;t=new We({props:{size:15}});function n(){return u[10](u[22])}return{c(){e=p("button"),ue(t.$$.fragment),this.h()},l(r){e=m(r,"BUTTON",{class:!0});var l=w(e);ie(t.$$.fragment,l),l.forEach(h),this.h()},h(){d(e,"class","p-2 text-gray-300 hover:text-red-500 rounded-lg hover:bg-red-50 dark:hover:bg-red-950 transition-colors shrink-0")},m(r,l){X(r,e,l),oe(t,e,null),s=!0,a||(f=K(e,"click",n),a=!0)},p(r,l){u=r},i(r){s||(j(t.$$.fragment,r),s=!0)},o(r){L(t.$$.fragment,r),s=!1},d(r){r&&h(e),ne(t),a=!1,f()}}}function rt(u){let e,t="Admin";return{c(){e=p("span"),e.textContent=t,this.h()},l(s){e=m(s,"SPAN",{class:!0,"data-svelte-h":!0}),W(e)!=="svelte-1n9oi26"&&(e.textContent=t),this.h()},h(){d(e,"class","text-xs px-2 py-0.5 rounded-full bg-blue-50 dark:bg-blue-950 text-blue-700 dark:text-blue-300 font-medium shrink-0")},m(s,a){X(s,e,a)},p:ae,i:ae,o:ae,d(s){s&&h(e)}}}function Ne(u,e){var Q,b;let t,s,a=(((b=(Q=e[22].name)==null?void 0:Q[0])==null?void 0:b.toUpperCase())??"?")+"",f,n,r,l,g=e[22].name+"",v,M,D,I=e[22].email+"",R,F,A=e[9](e[22].created_at)+"",$,x,y,V,q,k,P;const _=[rt,tt],z=[];function O(c,i){return c[24]===0?0:1}return y=O(e),V=z[y]=_[y](e),{key:u,first:null,c(){t=p("div"),s=p("div"),f=Z(a),n=E(),r=p("div"),l=p("p"),v=Z(g),M=E(),D=p("p"),R=Z(I),F=Z(" · Depuis le "),$=Z(A),x=E(),V.c(),q=E(),this.h()},l(c){t=m(c,"DIV",{class:!0});var i=w(t);s=m(i,"DIV",{class:!0});var T=w(s);f=Y(T,a),T.forEach(h),n=C(i),r=m(i,"DIV",{class:!0});var B=w(r);l=m(B,"P",{class:!0});var H=w(l);v=Y(H,g),H.forEach(h),M=C(B),D=m(B,"P",{class:!0});var S=w(D);R=Y(S,I),F=Y(S," · Depuis le "),$=Y(S,A),S.forEach(h),B.forEach(h),x=C(i),V.l(i),q=C(i),i.forEach(h),this.h()},h(){d(s,"class","w-9 h-9 rounded-full bg-blue-100 dark:bg-blue-900 flex items-center justify-center text-sm font-semibold text-blue-700 dark:text-blue-300 shrink-0"),d(l,"class","text-sm font-medium text-gray-900 dark:text-white"),d(D,"class","text-xs text-gray-400 dark:text-gray-500"),d(r,"class","flex-1 min-w-0"),d(t,"class",k="flex items-center gap-4 px-5 py-4 "+(e[24]>0?"border-t border-gray-50 dark:border-gray-800":"")),this.first=t},m(c,i){X(c,t,i),o(t,s),o(s,f),o(t,n),o(t,r),o(r,l),o(l,v),o(r,M),o(r,D),o(D,R),o(D,F),o(D,$),o(t,x),z[y].m(t,null),o(t,q),P=!0},p(c,i){var B,H;e=c,(!P||i&1)&&a!==(a=(((H=(B=e[22].name)==null?void 0:B[0])==null?void 0:H.toUpperCase())??"?")+"")&&fe(f,a),(!P||i&1)&&g!==(g=e[22].name+"")&&fe(v,g),(!P||i&1)&&I!==(I=e[22].email+"")&&fe(R,I),(!P||i&1)&&A!==(A=e[9](e[22].created_at)+"")&&fe($,A);let T=y;y=O(e),y===T?z[y].p(e,i):(me(),L(z[T],1,1,()=>{z[T]=null}),de(),V=z[y],V?V.p(e,i):(V=z[y]=_[y](e),V.c()),j(V,1),V.m(t,q)),(!P||i&1&&k!==(k="flex items-center gap-4 px-5 py-4 "+(e[24]>0?"border-t border-gray-50 dark:border-gray-800":"")))&&d(t,"class",k)},i(c){P||(j(V),P=!0)},o(c){L(V),P=!1},d(c){c&&h(t),z[y].d()}}}function lt(u){let e;return{c(){e=p("div"),this.h()},l(t){e=m(t,"DIV",{class:!0}),w(e).forEach(h),this.h()},h(){d(e,"class","h-16 bg-gray-100 dark:bg-gray-800 rounded-xl animate-pulse")},m(t,s){X(t,e,s)},p:ae,d(t){t&&h(e)}}}function ze(u){let e,t,s,a,f="Ajouter un membre",n,r,l,g,v,M,D,I,R="Nom affiché",F,A,$,x,y,V="Email",q,k,P,_,z,O="Mot de passe",Q,b,c,i,T,B="Confirmer le mot de passe",H,S,ye,ee,te,$e="Annuler",xe,re,se,we,pe,Ce,Ve;l=new Ke({props:{size:18}});let N=u[3]&&Pe(u);return se=new Le({props:{size:15}}),{c(){e=p("div"),t=p("div"),s=p("div"),a=p("h2"),a.textContent=f,n=E(),r=p("button"),ue(l.$$.fragment),g=E(),v=p("div"),N&&N.c(),M=E(),D=p("div"),I=p("label"),I.textContent=R,F=E(),A=p("input"),$=E(),x=p("div"),y=p("label"),y.textContent=V,q=E(),k=p("input"),P=E(),_=p("div"),z=p("label"),z.textContent=O,Q=E(),b=p("input"),c=E(),i=p("div"),T=p("label"),T.textContent=B,H=E(),S=p("input"),ye=E(),ee=p("div"),te=p("button"),te.textContent=$e,xe=E(),re=p("button"),ue(se.$$.fragment),we=Z(" Créer le compte"),this.h()},l(U){e=m(U,"DIV",{class:!0});var G=w(e);t=m(G,"DIV",{class:!0});var ce=w(t);s=m(ce,"DIV",{class:!0});var he=w(s);a=m(he,"H2",{class:!0,"data-svelte-h":!0}),W(a)!=="svelte-vs62sb"&&(a.textContent=f),n=C(he),r=m(he,"BUTTON",{class:!0});var Te=w(r);ie(l.$$.fragment,Te),Te.forEach(h),he.forEach(h),g=C(ce),v=m(ce,"DIV",{class:!0});var J=w(v);N&&N.l(J),M=C(J),D=m(J,"DIV",{});var ge=w(D);I=m(ge,"LABEL",{class:!0,"data-svelte-h":!0}),W(I)!=="svelte-1rnibbg"&&(I.textContent=R),F=C(ge),A=m(ge,"INPUT",{placeholder:!0,class:!0}),ge.forEach(h),$=C(J),x=m(J,"DIV",{});var _e=w(x);y=m(_e,"LABEL",{class:!0,"data-svelte-h":!0}),W(y)!=="svelte-1hqydf6"&&(y.textContent=V),q=C(_e),k=m(_e,"INPUT",{type:!0,placeholder:!0,class:!0}),_e.forEach(h),P=C(J),_=m(J,"DIV",{});var be=w(_);z=m(be,"LABEL",{class:!0,"data-svelte-h":!0}),W(z)!=="svelte-1apo42j"&&(z.textContent=O),Q=C(be),b=m(be,"INPUT",{type:!0,class:!0}),be.forEach(h),c=C(J),i=m(J,"DIV",{});var ve=w(i);T=m(ve,"LABEL",{class:!0,"data-svelte-h":!0}),W(T)!=="svelte-1g2vdt3"&&(T.textContent=B),H=C(ve),S=m(ve,"INPUT",{type:!0,class:!0}),ve.forEach(h),J.forEach(h),ye=C(ce),ee=m(ce,"DIV",{class:!0});var ke=w(ee);te=m(ke,"BUTTON",{class:!0,"data-svelte-h":!0}),W(te)!=="svelte-tj1z1u"&&(te.textContent=$e),xe=C(ke),re=m(ke,"BUTTON",{class:!0});var Ee=w(re);ie(se.$$.fragment,Ee),we=Y(Ee," Créer le compte"),Ee.forEach(h),ke.forEach(h),ce.forEach(h),G.forEach(h),this.h()},h(){d(a,"class","font-semibold text-gray-900 dark:text-white"),d(r,"class","text-gray-400 hover:text-gray-600"),d(s,"class","flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-gray-800"),d(I,"class","block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1"),d(A,"placeholder","Ex: Marie Dupont"),d(A,"class","w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),d(y,"class","block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1"),d(k,"type","email"),d(k,"placeholder","[email protected]"),d(k,"class","w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),d(z,"class","block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1"),d(b,"type","password"),d(b,"class","w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),d(T,"class","block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1"),d(S,"type","password"),d(S,"class","w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),d(v,"class","px-6 py-5 space-y-4"),d(te,"class","px-4 py-2 text-sm text-gray-600 dark:text-gray-400"),d(re,"class","flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition-colors"),d(ee,"class","flex justify-end gap-3 px-6 py-4 border-t border-gray-100 dark:border-gray-800"),d(t,"class","bg-white dark:bg-gray-900 rounded-2xl w-full max-w-md shadow-xl border border-gray-100 dark:border-gray-800"),d(e,"class","fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4")},m(U,G){X(U,e,G),o(e,t),o(t,s),o(s,a),o(s,n),o(s,r),oe(l,r,null),o(t,g),o(t,v),N&&N.m(v,null),o(v,M),o(v,D),o(D,I),o(D,F),o(D,A),le(A,u[5].name),o(v,$),o(v,x),o(x,y),o(x,q),o(x,k),le(k,u[5].email),o(v,P),o(v,_),o(_,z),o(_,Q),o(_,b),le(b,u[5].password),o(v,c),o(v,i),o(i,T),o(i,H),o(i,S),le(S,u[5].confirm),o(t,ye),o(t,ee),o(ee,te),o(ee,xe),o(ee,re),oe(se,re,null),o(re,we),pe=!0,Ce||(Ve=[K(r,"click",u[11]),K(A,"input",u[12]),K(k,"input",u[13]),K(b,"input",u[14]),K(S,"input",u[15]),K(te,"click",u[16]),K(re,"click",u[7]),K(e,"click",He(u[17]))],Ce=!0)},p(U,G){U[3]?N?(N.p(U,G),G&8&&j(N,1)):(N=Pe(U),N.c(),j(N,1),N.m(v,M)):N&&(me(),L(N,1,1,()=>{N=null}),de()),G&32&&A.value!==U[5].name&&le(A,U[5].name),G&32&&k.value!==U[5].email&&le(k,U[5].email),G&32&&b.value!==U[5].password&&le(b,U[5].password),G&32&&S.value!==U[5].confirm&&le(S,U[5].confirm)},i(U){pe||(j(l.$$.fragment,U),j(N),j(se.$$.fragment,U),pe=!0)},o(U){L(l.$$.fragment,U),L(N),L(se.$$.fragment,U),pe=!1},d(U){U&&h(e),ne(l),N&&N.d(),ne(se),Ce=!1,qe(Ve)}}}function Pe(u){let e,t,s,a,f;return t=new Qe({props:{size:13}}),{c(){e=p("div"),ue(t.$$.fragment),s=E(),a=Z(u[3]),this.h()},l(n){e=m(n,"DIV",{class:!0});var r=w(e);ie(t.$$.fragment,r),s=C(r),a=Y(r,u[3]),r.forEach(h),this.h()},h(){d(e,"class","flex items-center gap-2 text-sm px-3 py-2 rounded-lg bg-red-50 dark:bg-red-950/30 text-red-600 dark:text-red-400")},m(n,r){X(n,e,r),oe(t,e,null),o(e,s),o(e,a),f=!0},p(n,r){(!f||r&8)&&fe(a,n[3])},i(n){f||(j(t.$$.fragment,n),f=!0)},o(n){L(t.$$.fragment,n),f=!1},d(n){n&&h(e),ne(t)}}}function st(u){let e,t,s,a,f,n,r="Utilisateurs",l,g,v,M,D,I,R=`Ajoutez les membres de votre famille qui peuvent accéder à l'application.
|
|
Chacun a son propre compte et mot de passe.`,F,A,$,x,y,V,q,k,P;a=new Ge({props:{size:22,class:"text-gray-400"}}),v=new Je({props:{size:16}});let _=u[4]&&je(u);const z=[et,Ze],O=[];function Q(c,i){return c[1]?0:1}$=Q(u),x=O[$]=z[$](u);let b=u[2]&&ze(u);return{c(){e=p("div"),t=p("div"),s=p("div"),ue(a.$$.fragment),f=E(),n=p("h1"),n.textContent=r,l=E(),g=p("button"),ue(v.$$.fragment),M=Z(" Ajouter un membre"),D=E(),I=p("p"),I.textContent=R,F=E(),_&&_.c(),A=E(),x.c(),y=E(),b&&b.c(),V=Ue(),this.h()},l(c){e=m(c,"DIV",{class:!0});var i=w(e);t=m(i,"DIV",{class:!0});var T=w(t);s=m(T,"DIV",{class:!0});var B=w(s);ie(a.$$.fragment,B),f=C(B),n=m(B,"H1",{class:!0,"data-svelte-h":!0}),W(n)!=="svelte-1ot16rk"&&(n.textContent=r),B.forEach(h),l=C(T),g=m(T,"BUTTON",{class:!0});var H=w(g);ie(v.$$.fragment,H),M=Y(H," Ajouter un membre"),H.forEach(h),T.forEach(h),D=C(i),I=m(i,"P",{class:!0,"data-svelte-h":!0}),W(I)!=="svelte-csgthk"&&(I.textContent=R),F=C(i),_&&_.l(i),A=C(i),x.l(i),i.forEach(h),y=C(c),b&&b.l(c),V=Ue(),this.h()},h(){d(n,"class","text-2xl font-semibold text-gray-900 dark:text-white"),d(s,"class","flex items-center gap-3"),d(g,"class","flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition-colors"),d(t,"class","flex items-center justify-between mb-6"),d(I,"class","text-sm text-gray-500 dark:text-gray-400 mb-5"),d(e,"class","p-6 max-w-2xl mx-auto")},m(c,i){X(c,e,i),o(e,t),o(t,s),oe(a,s,null),o(s,f),o(s,n),o(t,l),o(t,g),oe(v,g,null),o(g,M),o(e,D),o(e,I),o(e,F),_&&_.m(e,null),o(e,A),O[$].m(e,null),X(c,y,i),b&&b.m(c,i),X(c,V,i),q=!0,k||(P=K(g,"click",u[6]),k=!0)},p(c,[i]){c[4]?_?(_.p(c,i),i&16&&j(_,1)):(_=je(c),_.c(),j(_,1),_.m(e,A)):_&&(me(),L(_,1,1,()=>{_=null}),de());let T=$;$=Q(c),$===T?O[$].p(c,i):(me(),L(O[T],1,1,()=>{O[T]=null}),de(),x=O[$],x?x.p(c,i):(x=O[$]=z[$](c),x.c()),j(x,1),x.m(e,null)),c[2]?b?(b.p(c,i),i&4&&j(b,1)):(b=ze(c),b.c(),j(b,1),b.m(V.parentNode,V)):b&&(me(),L(b,1,1,()=>{b=null}),de())},i(c){q||(j(a.$$.fragment,c),j(v.$$.fragment,c),j(_),j(x),j(b),q=!0)},o(c){L(a.$$.fragment,c),L(v.$$.fragment,c),L(_),L(x),L(b),q=!1},d(c){c&&(h(e),h(y),h(V)),ne(a),ne(v),_&&_.d(),O[$].d(),b&&b.d(c),k=!1,P()}}}function at(u,e,t){let s=[],a=!0,f=!1,n="",r="",l={email:"",name:"",password:"",confirm:""};Me(g);async function g(){t(1,a=!0),t(0,s=await De.users.list()||[]),t(1,a=!1)}function v(){t(5,l={email:"",name:"",password:"",confirm:""}),t(3,n=""),t(2,f=!0)}async function M(){if(t(3,n=""),!l.email||!l.name||!l.password){t(3,n="Tous les champs sont requis.");return}if(l.password!==l.confirm){t(3,n="Les mots de passe ne correspondent pas.");return}if(l.password.length<6){t(3,n="Minimum 6 caractères.");return}try{await De.auth.register({email:l.email,name:l.name,password:l.password}),t(2,f=!1),t(4,r=`Compte "${l.name}" créé avec succès.`),setTimeout(()=>t(4,r=""),4e3),await g()}catch(k){t(3,n=k.message)}}async function D(k,P){if(confirm(`Supprimer le compte de "${P}" ?`))try{await De.users.delete(k),await g()}catch(_){alert(_.message)}}const I=k=>new Date(k).toLocaleDateString("fr-FR",{day:"2-digit",month:"long",year:"numeric"}),R=k=>D(k.id,k.name),F=()=>t(2,f=!1);function A(){l.name=this.value,t(5,l)}function $(){l.email=this.value,t(5,l)}function x(){l.password=this.value,t(5,l)}function y(){l.confirm=this.value,t(5,l)}return[s,a,f,n,r,l,v,M,D,I,R,F,A,$,x,y,()=>t(2,f=!1),()=>t(2,f=!1)]}class gt extends Oe{constructor(e){super(),Se(this,e,at,st,Be,{})}}export{gt as component};
|