48ea61cdcc
- Product documentation in docs/products/ - Updated MEMORY.md with product info - quiXzoom Auth Core as AAMOS Identity product
13 lines
16 KiB
JavaScript
13 lines
16 KiB
JavaScript
var ie=a=>{throw TypeError(a)};var Q=(a,t,s)=>t.has(a)||ie("Cannot "+s);var o=(a,t,s)=>(Q(a,t,"read from private field"),s?s.call(a):t.get(a)),C=(a,t,s)=>t.has(a)?ie("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),E=(a,t,s,r)=>(Q(a,t,"write to private field"),r?r.call(a,s):t.set(a,s),s),k=(a,t,s)=>(Q(a,t,"access private method"),s);import{x as he,a$ as Ce,b0 as Ee,b1 as ae,b2 as ke,b3 as xe,b4 as pe,r as m,b5 as Me,b6 as Se,a0 as Ie,u as Pe,a as _e,o as Le,a3 as Oe,j as e,L as _,y as R,z as K,v as d,B as re,p as L,X as qe,b7 as ze,F as Re,ag as ne,ah as oe,C as Ke,q as M,I as Te,M as Ue,aS as le,aZ as $,w as S,E as ce,ao as Fe}from"./index-CZD3_4lD.js";import{B as T}from"./badge-D3Mn__J4.js";import{u as Be}from"./useMissionExamples-k-4yLF0Z.js";import{u as Ae}from"./useQuery-CHKCqCt4.js";import{C as Qe}from"./circle-alert-DFiBooaQ.js";import{A as $e}from"./arrow-left-DyClWdEf.js";import{S as Ge}from"./save-CMkrLPh2.js";import{E as He}from"./eye-IKrhkOAd.js";import{I as G}from"./image-CUEcTqim.js";import{T as Ve}from"./trending-up-CVyK6WFK.js";import{C as We}from"./clock-CHYQgZWG.js";import{U as Xe}from"./upload-B_ploHV0.js";import{T as de}from"./trash-2-DRcoDJkq.js";/**
|
|
* @license lucide-react v0.462.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const Ze=he("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
* @license lucide-react v0.462.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const Je=he("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);var g,v,l,j,f,U,H,ue,Ye=(ue=class extends Ce{constructor(t,s){super();C(this,f);C(this,g);C(this,v);C(this,l);C(this,j);E(this,g,t),this.setOptions(s),this.bindMethods(),k(this,f,U).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const s=this.options;this.options=o(this,g).defaultMutationOptions(t),Ee(this.options,s)||o(this,g).getMutationCache().notify({type:"observerOptionsUpdated",mutation:o(this,l),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&ae(s.mutationKey)!==ae(this.options.mutationKey)?this.reset():((r=o(this,l))==null?void 0:r.state.status)==="pending"&&o(this,l).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=o(this,l))==null||t.removeObserver(this)}onMutationUpdate(t){k(this,f,U).call(this),k(this,f,H).call(this,t)}getCurrentResult(){return o(this,v)}reset(){var t;(t=o(this,l))==null||t.removeObserver(this),E(this,l,void 0),k(this,f,U).call(this),k(this,f,H).call(this)}mutate(t,s){var r;return E(this,j,s),(r=o(this,l))==null||r.removeObserver(this),E(this,l,o(this,g).getMutationCache().build(o(this,g),this.options)),o(this,l).addObserver(this),o(this,l).execute(t)}},g=new WeakMap,v=new WeakMap,l=new WeakMap,j=new WeakMap,f=new WeakSet,U=function(){var s;const t=((s=o(this,l))==null?void 0:s.state)??ke();E(this,v,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},H=function(t){xe.batch(()=>{var s,r,c,n,N,w,O,q;if(o(this,j)&&this.hasListeners()){const b=o(this,v).variables,u=o(this,v).context,D={client:o(this,g),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(s=o(this,j)).onSuccess)==null||r.call(s,t.data,b,u,D)}catch(x){Promise.reject(x)}try{(n=(c=o(this,j)).onSettled)==null||n.call(c,t.data,null,b,u,D)}catch(x){Promise.reject(x)}}else if((t==null?void 0:t.type)==="error"){try{(w=(N=o(this,j)).onError)==null||w.call(N,t.error,b,u,D)}catch(x){Promise.reject(x)}try{(q=(O=o(this,j)).onSettled)==null||q.call(O,void 0,t.error,b,u,D)}catch(x){Promise.reject(x)}}}this.listeners.forEach(b=>{b(o(this,v))})})},ue);function me(a,t){const s=pe(),[r]=m.useState(()=>new Ye(s,a));m.useEffect(()=>{r.setOptions(a)},[r,a]);const c=m.useSyncExternalStore(m.useCallback(N=>r.subscribe(xe.batchCalls(N)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),n=m.useCallback((N,w)=>{r.mutate(N,w).catch(Me)},[r]);if(c.error&&Se(r.options.throwOnError,[c.error]))throw c.error;return{...c,mutate:n,mutateAsync:c.mutate}}const xs=()=>{const{id:a}=Ie(),t=Pe(),{t:s}=_e(),{user:r}=Le(),c=pe(),{mission:n,loading:N,error:w}=Oe(a),{goodExamples:O,badExamples:q,hasExamples:b,uploading:u,uploadExample:D,deleteExample:x}=Be(a),[p,F]=m.useState(!1),[V,W]=m.useState(""),[X,Z]=m.useState(""),[J,Y]=m.useState(""),[I,ee]=m.useState(0),y=m.useRef(null),se=async i=>{var P;const h=(P=i.target.files)==null?void 0:P[0];if(h){if(!h.type.startsWith("image/")){S.error(s("orderer.missionDetail.onlyImagesAllowed"));return}if(h.size>5*1024*1024){S.error(s("orderer.missionDetail.maxFileSize"));return}await D(h),y.current&&(y.current.value="")}},ge=async(i,h)=>{confirm(s("orderer.missionDetail.confirmDeleteImage"))&&await x(i,h)},{data:z=[],isLoading:je}=Ae({queryKey:["mission-claims",a],queryFn:async()=>a?await Fe(`/claims?mission_id=${a}&order=created_at.desc`)||[]:[],enabled:!!a}),fe=z.length,Ne=z.filter(i=>i.status==="pending"),be=z.filter(i=>i.status==="approved"),ve=z.reduce((i,h)=>{var P;return i+(((P=h.submissions)==null?void 0:P.length)||0)},0),B=me({mutationFn:async i=>{if(!a)throw new Error("Mission ID missing");await ce(`/missions/${a}`,i)},onSuccess:()=>{S.success(s("orderer.missionDetail.missionUpdated")),c.invalidateQueries({queryKey:["mission",a]}),c.invalidateQueries({queryKey:["orderer-missions"]}),F(!1)},onError:i=>{S.error(s("orderer.missionDetail.couldNotUpdate")+": "+i.message)}}),A=me({mutationFn:async()=>{if(!a)throw new Error("Mission ID missing");await ce(`/missions/${a}`,{status:"cancelled"})},onSuccess:()=>{S.success(s("orderer.missionDetail.missionCancelled")),c.invalidateQueries({queryKey:["mission",a]}),c.invalidateQueries({queryKey:["orderer-missions"]})},onError:i=>{S.error(s("orderer.missionDetail.couldNotCancel")+": "+i.message)}}),ye=()=>{n&&(W(n.title),Z(n.description||""),Y(n.instructions||""),ee(n.reward_credits),F(!0))},we=()=>{B.mutate({title:V,description:X,instructions:J,reward_credits:I})},te=i=>{const h=Math.max(1,I+i);ee(h)};if(N||je)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(_,{className:"w-8 h-8 animate-spin text-primary"})});if(w||!n)return e.jsxs("div",{className:"min-h-screen bg-background text-foreground pb-24",children:[e.jsx("main",{className:"p-4 pt-6",children:e.jsx(R,{className:"glass-card border-destructive/30",children:e.jsxs(K,{className:"p-6 text-center",children:[e.jsx(Qe,{className:"w-12 h-12 mx-auto text-destructive mb-4"}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:s("orderer.missionDetail.missionNotFound")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:s("orderer.missionDetail.missionNotFoundDesc")}),e.jsx(d,{onClick:()=>t("/orderer/dashboard"),children:s("orderer.missionDetail.backToDashboard")})]})})}),e.jsx(re,{})]});if(n.created_by!==(r==null?void 0:r.id))return t(`/mission/${a}`),null;const De=i=>{switch(i){case"active":return e.jsx(T,{className:"bg-green-600 text-white",children:s("orderer.status.active")});case"completed":return e.jsx(T,{variant:"secondary",children:s("orderer.status.completed")});case"cancelled":return e.jsx(T,{variant:"destructive",children:s("orderer.status.cancelled")});default:return e.jsx(T,{variant:"outline",children:i})}};return e.jsxs("div",{className:"min-h-screen bg-background text-foreground pb-24",children:[e.jsxs("main",{className:"p-4 space-y-4 pt-6",children:[e.jsxs(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(d,{variant:"ghost",size:"icon",onClick:()=>t("/orderer/dashboard"),children:e.jsx($e,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold",children:s("orderer.missionDetail.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("orderer.missionDetail.ordererView")})]})]}),p?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"ghost",size:"sm",onClick:()=>F(!1),children:e.jsx(qe,{className:"w-4 h-4"})}),e.jsxs(d,{size:"sm",onClick:we,disabled:B.isPending,children:[B.isPending?e.jsx(_,{className:"w-4 h-4 animate-spin"}):e.jsx(Ge,{className:"w-4 h-4 mr-2"}),s("orderer.missionDetail.save")]})]}):e.jsxs(d,{variant:"outline",size:"sm",onClick:ye,children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),s("orderer.missionDetail.edit")]})]}),e.jsx(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.05},children:e.jsx(R,{className:"glass-card",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[De(n.status),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s("orderer.missionDetail.created")," ",new Date(n.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"text-center p-3 rounded-lg bg-secondary/30",children:[e.jsx(He,{className:"w-5 h-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-xl font-bold",children:fe}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("orderer.missionDetail.views")})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-secondary/30",children:[e.jsx(ze,{className:"w-5 h-5 mx-auto text-blue-500 mb-1"}),e.jsx("p",{className:"text-xl font-bold",children:Ne.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("orderer.missionDetail.inProgress")})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-secondary/30",children:[e.jsx(Re,{className:"w-5 h-5 mx-auto text-green-500 mb-1"}),e.jsx("p",{className:"text-xl font-bold",children:be.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("orderer.missionDetail.approved")})]}),e.jsxs("div",{className:"text-center p-3 rounded-lg bg-secondary/30",children:[e.jsx(G,{className:"w-5 h-5 mx-auto text-amber-500 mb-1"}),e.jsx("p",{className:"text-xl font-bold",children:ve}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("orderer.missionDetail.photos")})]})]})]})})}),e.jsx(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(R,{className:"glass-card",children:[e.jsx(ne,{className:"pb-2",children:e.jsxs(oe,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ke,{className:"w-5 h-5 text-primary"}),s("orderer.missionDetail.missionDetails")]})}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:s("orderer.missionDetail.titleLabel")}),p?e.jsx(Te,{value:V,onChange:i=>W(i.target.value),className:"mt-1"}):e.jsx("p",{className:"font-medium",children:n.title})]}),e.jsxs("div",{children:[e.jsxs(M,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ue,{className:"w-3 h-3"})," ",s("orderer.missionDetail.location")]}),e.jsx("p",{className:"text-sm",children:n.area_name||s("orderer.missionDetail.notSpecified")})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:s("orderer.missionDetail.description")}),p?e.jsx(le,{value:X,onChange:i=>Z(i.target.value),className:"mt-1",rows:3}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n.description||s("orderer.missionDetail.noDescription")})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:s("orderer.missionDetail.instructions")}),p?e.jsx(le,{value:J,onChange:i=>Y(i.target.value),className:"mt-1",rows:3,placeholder:s("orderer.missionDetail.instructionsPlaceholder")}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n.instructions||s("orderer.missionDetail.noInstructions")})]}),e.jsxs("div",{children:[e.jsxs(M,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ve,{className:"w-3 h-3"})," ",s("orderer.missionDetail.reward")]}),p?e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(d,{variant:"outline",size:"icon",onClick:()=>te(-10),disabled:I<=10,children:e.jsx(Ze,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 text-center",children:[e.jsxs("span",{className:"text-2xl font-bold text-warning",children:[I," krediter"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.required_photos," ",s("orderer.missionDetail.photos")," = $",Math.round(I/n.required_photos)," krediter/",s("orderer.missionDetail.photos").slice(0,-1)]})]}),e.jsx(d,{variant:"outline",size:"icon",onClick:()=>te(10),children:e.jsx($,{className:"w-4 h-4"})})]}):e.jsxs("p",{className:"text-xl font-bold text-warning",children:[n.reward_credits," krediter",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-2",children:["(",n.required_photos," ",s("orderer.missionDetail.photos"),")"]})]})]}),n.active_until&&e.jsxs("div",{children:[e.jsxs(M,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(We,{className:"w-3 h-3"})," ",s("orderer.missionDetail.activeUntil")]}),e.jsx("p",{className:"text-sm",children:new Date(n.active_until).toLocaleDateString()})]})]})]})}),e.jsx(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.15},children:e.jsxs(R,{className:"glass-card",children:[e.jsx(ne,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(oe,{className:"text-lg flex items-center gap-2",children:[e.jsx(G,{className:"w-5 h-5 text-primary"}),s("orderer.missionDetail.exampleImages")]}),p&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"file",ref:y,onChange:se,accept:"image/*",className:"hidden"}),e.jsxs(d,{variant:"outline",size:"sm",className:"gap-1",onClick:()=>{var i;return(i=y.current)==null?void 0:i.click()},disabled:u,children:[u?e.jsx(_,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Xe,{className:"w-3.5 h-3.5"}),s(u?"orderer.missionDetail.uploading":"orderer.missionDetail.upload")]})]})]})}),e.jsx(K,{children:b?e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[[...O,...q].map(i=>e.jsxs("div",{className:"relative aspect-[4/3] rounded-lg overflow-hidden border border-border group",children:[e.jsx("img",{src:i.image_url,alt:i.caption||s("orderer.missionDetail.exampleImages"),className:"w-full h-full object-cover"}),i.caption&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 p-1",children:e.jsx("p",{className:"text-[10px] text-white truncate",children:i.caption})}),p&&e.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:e.jsx(d,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:()=>ge(i.id,i.image_url),children:e.jsx(de,{className:"w-4 h-4"})})})]},i.id)),p&&e.jsx("div",{className:"aspect-[4/3] rounded-lg border-2 border-dashed border-muted-foreground/30 flex items-center justify-center cursor-pointer hover:border-primary/50 hover:bg-primary/5 transition-colors",onClick:()=>{var i;return(i=y.current)==null?void 0:i.click()},children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx($,{className:"w-6 h-6 mx-auto mb-1"}),e.jsx("p",{className:"text-xs",children:s("orderer.missionDetail.addImage")})]})})]}):e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(G,{className:"w-10 h-10 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:s("orderer.missionDetail.noExampleImages")}),p&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"file",ref:y,onChange:se,accept:"image/*",className:"hidden"}),e.jsxs(d,{variant:"outline",size:"sm",className:"mt-3 gap-1",onClick:()=>{var i;return(i=y.current)==null?void 0:i.click()},disabled:u,children:[u?e.jsx(_,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx($,{className:"w-3.5 h-3.5"}),s("orderer.missionDetail.addExampleImage")]})]})]})})]})}),n.status==="active"&&e.jsx(L.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsxs(d,{variant:"destructive",className:"w-full",onClick:()=>{confirm(s("orderer.missionDetail.cancelConfirm"))&&A.mutate()},disabled:A.isPending,children:[A.isPending?e.jsx(_,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(de,{className:"w-4 h-4 mr-2"}),s("orderer.missionDetail.cancelMission")]})})]}),e.jsx(re,{})]})};export{xs as default};
|
|
//# sourceMappingURL=OrdererMissionDetail-rIgIT4BY.js.map
|