48ea61cdcc
- Product documentation in docs/products/ - Updated MEMORY.md with product info - quiXzoom Auth Core as AAMOS Identity product
3 lines
11 KiB
JavaScript
3 lines
11 KiB
JavaScript
import{a0 as K,u as G,a as Q,r as J,j as e,v as C,y as b,z as w,ag as O,ah as F,p as Y,B as V,ao as z}from"./index-CZD3_4lD.js";import{u as P}from"./useQuery-CHKCqCt4.js";import{B as M}from"./badge-D3Mn__J4.js";import{P as W}from"./progress-BVXi0hgU.js";import{d as E,T as v}from"./differenceInDays-BjWVl97D.js";import{A as Z}from"./arrow-left-DyClWdEf.js";import{H as ee}from"./heart-Bn8C2h_q.js";import{C as te}from"./clock-CHYQgZWG.js";import{t as m,c as se,g as H,e as B,m as R,a as D,b as ne,f as I,d as ae,s as re}from"./sv-KqUX0hpM.js";import{C as ce}from"./calendar-3jVgdv6R.js";import{I as q}from"./image-CUEcTqim.js";import{U as oe}from"./upload-B_ploHV0.js";function _(s,n){const t=m(s),d=m(n),a=t.getTime()-d.getTime();return a<0?-1:a>0?1:a}function ie(s){return se(s,Date.now())}function le(s,n){const t=m(s),d=m(n),a=t.getFullYear()-d.getFullYear(),h=t.getMonth()-d.getMonth();return a*12+h}function de(s){return n=>{const d=(s?Math[s]:Math.trunc)(n);return d===0?0:d}}function me(s,n){return+m(s)-+m(n)}function ue(s){const n=m(s);return n.setHours(23,59,59,999),n}function fe(s){const n=m(s),t=n.getMonth();return n.setFullYear(n.getFullYear(),t+1,0),n.setHours(23,59,59,999),n}function he(s){const n=m(s);return+ue(n)==+fe(n)}function xe(s,n){const t=m(s),d=m(n),a=_(t,d),h=Math.abs(le(t,d));let x;if(h<1)x=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-a*h);let r=_(t,d)===-a;he(m(s))&&h===1&&_(s,d)===1&&(r=!1),x=a*(h-Number(r))}return x===0?0:x}function ge(s,n,t){const d=me(s,n)/1e3;return de(t==null?void 0:t.roundingMethod)(d)}function pe(s,n,t){const d=ne(),a=(t==null?void 0:t.locale)??d.locale??B,h=2520,x=_(s,n);if(isNaN(x))throw new RangeError("Invalid time value");const r=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:x});let l,p;x>0?(l=m(n),p=m(s)):(l=m(s),p=m(n));const i=ge(p,l),j=(H(p)-H(l))/1e3,c=Math.round((i-j)/60);let f;if(c<2)return t!=null&&t.includeSeconds?i<5?a.formatDistance("lessThanXSeconds",5,r):i<10?a.formatDistance("lessThanXSeconds",10,r):i<20?a.formatDistance("lessThanXSeconds",20,r):i<40?a.formatDistance("halfAMinute",0,r):i<60?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",1,r):c===0?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",c,r);if(c<45)return a.formatDistance("xMinutes",c,r);if(c<90)return a.formatDistance("aboutXHours",1,r);if(c<R){const u=Math.round(c/60);return a.formatDistance("aboutXHours",u,r)}else{if(c<h)return a.formatDistance("xDays",1,r);if(c<D){const u=Math.round(c/R);return a.formatDistance("xDays",u,r)}else if(c<D*2)return f=Math.round(c/D),a.formatDistance("aboutXMonths",f,r)}if(f=xe(p,l),f<12){const u=Math.round(c/D);return a.formatDistance("xMonths",u,r)}else{const u=f%12,g=Math.trunc(f/12);return u<3?a.formatDistance("aboutXYears",g,r):u<9?a.formatDistance("overXYears",g,r):a.formatDistance("almostXYears",g+1,r)}}function je(s,n){return pe(s,ie(s),n)}const Se=()=>{var X;const{contestId:s}=K(),n=G(),{t,i18n:d}=Q(),[a,h]=J.useState("info"),r=(()=>{switch(d.language){case"sv":return re;case"de":return ae;default:return B}})(),{data:l,isLoading:p}=P({queryKey:["photo-contest",s],queryFn:async()=>await z(`/photo-contests/${s}`),enabled:!!s}),{data:i}=P({queryKey:["contest-entries",s],queryFn:async()=>await z(`/contest-photos?contest_id=${s}&is_approved=true&order=votes_count.desc`)||[],enabled:!!s});if(p||!l)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary border-t-transparent rounded-full"})});const j=l.charity,c=(j==null?void 0:j.gradient_colors)||["#059669","#0D9488"],f=new Date,u=new Date(l.ends_at),g=new Date(l.starts_at),y=f>=g&&f<=u,k=f>u,S=E(u,f),$=E(u,g),U=Math.min(100,Math.max(0,($-S)/$*100)),L=(i==null?void 0:i.filter(o=>o.is_winner))||[],T=(i==null?void 0:i.slice(0,6))||[],A=(X=T==null?void 0:T[0])==null?void 0:X.photo_url;return e.jsxs("div",{className:"min-h-screen bg-background pb-32 safe-area-top safe-area-x",children:[e.jsxs("header",{className:"relative h-64 overflow-hidden",children:[A?e.jsx("img",{src:A,alt:"",className:"absolute inset-0 w-full h-full object-cover"}):e.jsx("div",{className:"absolute inset-0",style:{background:`linear-gradient(135deg, ${c[0]} 0%, ${c[1]} 100%)`}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/50 to-black/40"}),e.jsx("div",{className:"absolute inset-0 mix-blend-overlay opacity-20",style:{background:`linear-gradient(135deg, ${c[0]} 0%, ${c[1]} 100%)`}}),e.jsx(C,{variant:"ghost",size:"icon",className:"absolute top-4 left-4 z-10 bg-white/10 backdrop-blur-sm text-white hover:bg-white/20 border border-white/10",onClick:()=>n(-1),children:e.jsx(Z,{className:"w-5 h-5"})}),e.jsxs("div",{className:"absolute bottom-0 inset-x-0 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"p-2 rounded-xl bg-yellow-500/20 backdrop-blur-sm",children:e.jsx(v,{className:"w-5 h-5 text-yellow-400"})}),e.jsx("h1",{className:"text-2xl font-bold text-white tracking-tight",children:l.title})]}),j&&e.jsxs("p",{className:"text-sm text-white/80 flex items-center gap-2 pl-1",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),t("contest.supports",{charity:j.name})]})]})]}),e.jsxs("div",{className:"px-4 py-3 bg-card border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[y?e.jsx(M,{className:"bg-green-500",children:t("contest.active")}):k?e.jsx(M,{variant:"secondary",children:t("contest.ended")}):e.jsx(M,{variant:"outline",children:t("contest.upcoming")}),l.theme&&e.jsxs(M,{variant:"outline",children:[t("contest.theme"),": ",l.theme]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(te,{className:"w-4 h-4"}),y?e.jsx("span",{children:t("contest.daysLeft",{count:S})}):k?e.jsx("span",{children:t("contest.endedAgo",{time:je(u,{locale:r,addSuffix:!0})})}):e.jsx("span",{children:t("contest.startsOn",{date:I(g,"d MMM",{locale:r})})})]})]}),y&&e.jsx(W,{value:U,className:"h-1"})]}),e.jsx("div",{className:"flex gap-1 p-2 bg-muted/50 mx-4 mt-4 rounded-xl",children:[{id:"info",label:t("contest.info"),icon:ce},{id:"entries",label:`${t("contest.entries")} (${(i==null?void 0:i.length)||0})`,icon:q},{id:"winners",label:t("contest.winners"),icon:v}].map(o=>e.jsxs("button",{onClick:()=>h(o.id),className:`flex-1 flex items-center justify-center gap-1.5 py-2 px-3 rounded-lg text-sm font-medium transition-colors ${a===o.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id))}),e.jsxs("main",{className:"px-4 py-4",children:[a==="info"&&e.jsxs("div",{className:"space-y-4",children:[l.description&&e.jsx(b,{children:e.jsx(w,{className:"pt-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})})}),l.prize_description&&e.jsxs(b,{children:[e.jsx(O,{className:"pb-2",children:e.jsxs(F,{className:"text-sm flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-yellow-500"}),t("contest.prizes")]})}),e.jsx(w,{children:e.jsx("p",{className:"text-sm",children:l.prize_description})})]}),l.rules&&e.jsxs(b,{children:[e.jsx(O,{className:"pb-2",children:e.jsx(F,{className:"text-sm",children:t("contest.rules")})}),e.jsx(w,{children:e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:l.rules})})]}),e.jsx(b,{children:e.jsx(w,{className:"pt-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:t("contest.starts")}),e.jsx("p",{className:"text-sm font-medium",children:I(g,"d MMM yyyy",{locale:r})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:t("contest.ends")}),e.jsx("p",{className:"text-sm font-medium",children:I(u,"d MMM yyyy",{locale:r})})]})]})})}),y&&e.jsxs(C,{className:"w-full",style:{background:`linear-gradient(135deg, ${c[0]} 0%, ${c[1]} 100%)`},onClick:()=>n(`/submit-contest-photo/${s}`),children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),t("contest.uploadEntry")]})]}),a==="entries"&&e.jsx("div",{children:i!=null&&i.length?e.jsx("div",{className:"grid grid-cols-2 gap-3",children:i.map((o,N)=>e.jsx(Y.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:N*.05},children:e.jsx(b,{className:"overflow-hidden",children:e.jsxs("div",{className:"relative aspect-square",children:[e.jsx("img",{src:o.photo_url,alt:o.title||t("contest.contestEntry"),className:"w-full h-full object-cover"}),o.is_winner&&e.jsxs("div",{className:"absolute top-2 left-2 bg-yellow-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full flex items-center gap-1",children:[e.jsx(v,{className:"w-3 h-3"}),t("contest.winner")]}),e.jsx("div",{className:"absolute bottom-0 inset-x-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:e.jsxs("div",{className:"flex items-center justify-between text-white text-xs",children:[e.jsxs("span",{children:[o.votes_count," ",t("contest.votes")]}),e.jsxs("span",{className:"text-white/70",children:["#",N+1]})]})})]})})},o.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(q,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground",children:t("contest.noEntriesYet")}),y&&e.jsx(C,{variant:"link",onClick:()=>n(`/submit-contest-photo/${s}`),children:t("contest.beFirstToParticipate")})]})}),a==="winners"&&e.jsx("div",{children:L.length?e.jsx("div",{className:"space-y-4",children:L.map((o,N)=>e.jsx(Y.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:N*.1},children:e.jsxs(b,{className:"overflow-hidden",children:[e.jsxs("div",{className:"relative aspect-video",children:[e.jsx("img",{src:o.photo_url,alt:o.title||t("contest.untitled"),className:"w-full h-full object-cover"}),e.jsxs("div",{className:"absolute top-4 left-4 bg-yellow-500 text-white text-sm font-bold px-3 py-1 rounded-full flex items-center gap-1.5",children:[e.jsx(v,{className:"w-4 h-4"}),t(N===0?"contest.firstPlace":N===1?"contest.secondPlace":"contest.thirdPlace")]})]}),e.jsxs(w,{className:"py-3",children:[e.jsx("h3",{className:"font-medium",children:o.title||t("contest.untitled")}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.votes_count," ",t("contest.votes")]})]})]})},o.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground",children:t(k?"contest.winnersNotAnnounced":"contest.winnersAfterEnd")})]})})]}),e.jsx(V,{})]})};export{Se as default};
|
|
//# sourceMappingURL=PhotoContest-ByCNK-WJ.js.map
|