Files
boc/backups/2026-07-12-1023/landvex-prod/assets/OrdererMissionDetail-BnWG6WKo.js
T
Bernt 58ca4e68db feat(boc): Complete Business Operations Center v1.0
- Go backend API with full CRUD for all modules (CRM, Sales, Finance, HR, Legal, Marketing, Support, Purchase, Inventory, Projects, Automation, Analytics)
- Rust analytics service with parallel report generation
- C runtime with POSIX shared memory IPC
- PostgreSQL schema with 30+ tables, full migrations
- Redis cache, sessions, pub/sub
- Kafka event streaming with Zookeeper
- WebSocket hub for real-time updates
- Automation engine with cron jobs, workflows, event triggers
- JWT authentication, multi-tenant from start
- Docker Compose with all services
- Nginx reverse proxy with rate limiting
- Integration tests passing
- Feature gap analysis against Fortnox/Odoo/Visma

Refs: BOC-001
2026-07-12 12:41:35 +00:00

15 lines
16 KiB
JavaScript

var te=r=>{throw TypeError(r)};var A=(r,t,s)=>t.has(r)||te("Cannot "+s);var o=(r,t,s)=>(A(r,t,"read from private field"),s?s.call(r):t.get(r)),w=(r,t,s)=>t.has(r)?te("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),D=(r,t,s,a)=>(A(r,t,"write to private field"),a?a.call(r,s):t.set(r,s),s),C=(r,t,s)=>(A(r,t,"access private method"),s);import{o as me,a_ as Ce,a$ as Ee,b0 as ie,b1 as ke,b2 as ue,b3 as xe,r as u,b4 as Me,b5 as Se,$ as Ie,u as qe,a as _e,p as Le,a2 as Oe,j as e,L as I,x as z,y as R,v as m,B as re,q,X as ze,b6 as Re,A as Pe,ag as ae,ah as ne,C as Te,s as E,I as Ue,M as Ke,aR as oe,aY as B,w as k,z as Q}from"./index-oAPVDf-r.js";import{B as P}from"./badge-Qwi4CUXx.js";import{u as Fe}from"./useMissionExamples-B0el-PHm.js";import{u as Ae}from"./useQuery-BxfmyRLz.js";import{C as Be}from"./circle-alert-C1Hs9zwh.js";import{A as Qe}from"./arrow-left-m6EiMbb-.js";import{S as $e}from"./save-BwjzM02b.js";import{E as He}from"./eye-G89nJUb2.js";import{I as $}from"./image-DuU1QaV8.js";import{T as Ve}from"./trending-up-Be0ZnpBQ.js";import{C as We}from"./clock-DRtqJZUo.js";import{U as Xe}from"./upload-LLBu8Q_P.js";import{T as le}from"./trash-2-A3LTadZ7.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 Ye=me("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 Ge=me("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 N,b,c,p,g,T,H,de,Je=(de=class extends Ce{constructor(t,s){super();w(this,g);w(this,N);w(this,b);w(this,c);w(this,p);D(this,N,t),this.setOptions(s),this.bindMethods(),C(this,g,T).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var a;const s=this.options;this.options=o(this,N).defaultMutationOptions(t),Ee(this.options,s)||o(this,N).getMutationCache().notify({type:"observerOptionsUpdated",mutation:o(this,c),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&ie(s.mutationKey)!==ie(this.options.mutationKey)?this.reset():((a=o(this,c))==null?void 0:a.state.status)==="pending"&&o(this,c).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=o(this,c))==null||t.removeObserver(this)}onMutationUpdate(t){C(this,g,T).call(this),C(this,g,H).call(this,t)}getCurrentResult(){return o(this,b)}reset(){var t;(t=o(this,c))==null||t.removeObserver(this),D(this,c,void 0),C(this,g,T).call(this),C(this,g,H).call(this)}mutate(t,s){var a;return D(this,p,s),(a=o(this,c))==null||a.removeObserver(this),D(this,c,o(this,N).getMutationCache().build(o(this,N),this.options)),o(this,c).addObserver(this),o(this,c).execute(t)}},N=new WeakMap,b=new WeakMap,c=new WeakMap,p=new WeakMap,g=new WeakSet,T=function(){var s;const t=((s=o(this,c))==null?void 0:s.state)??ke();D(this,b,{...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){ue.batch(()=>{var s,a,d,n,j,y,_,L;if(o(this,p)&&this.hasListeners()){const f=o(this,b).variables,x=o(this,b).context;(t==null?void 0:t.type)==="success"?((a=(s=o(this,p)).onSuccess)==null||a.call(s,t.data,f,x),(n=(d=o(this,p)).onSettled)==null||n.call(d,t.data,null,f,x)):(t==null?void 0:t.type)==="error"&&((y=(j=o(this,p)).onError)==null||y.call(j,t.error,f,x),(L=(_=o(this,p)).onSettled)==null||L.call(_,void 0,t.error,f,x))}this.listeners.forEach(f=>{f(o(this,b))})})},de);function ce(r,t){const s=xe(),[a]=u.useState(()=>new Je(s,r));u.useEffect(()=>{a.setOptions(r)},[a,r]);const d=u.useSyncExternalStore(u.useCallback(j=>a.subscribe(ue.batchCalls(j)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),n=u.useCallback((j,y)=>{a.mutate(j,y).catch(Me)},[a]);if(d.error&&Se(a.options.throwOnError,[d.error]))throw d.error;return{...d,mutate:n,mutateAsync:d.mutate}}const xs=()=>{const{id:r}=Ie(),t=qe(),{t:s}=_e(),{user:a}=Le(),d=xe(),{mission:n,loading:j,error:y}=Oe(r),{goodExamples:_,badExamples:L,hasExamples:f,uploading:x,uploadExample:he,deleteExample:pe}=Fe(r),[h,U]=u.useState(!1),[V,W]=u.useState(""),[X,Y]=u.useState(""),[G,J]=u.useState(""),[M,Z]=u.useState(0),v=u.useRef(null),ee=async i=>{var S;const l=(S=i.target.files)==null?void 0:S[0];if(l){if(!l.type.startsWith("image/")){k.error(s("orderer.missionDetail.onlyImagesAllowed"));return}if(l.size>5*1024*1024){k.error(s("orderer.missionDetail.maxFileSize"));return}await he(l),v.current&&(v.current.value="")}},ge=async(i,l)=>{confirm(s("orderer.missionDetail.confirmDeleteImage"))&&await pe(i,l)},{data:O=[],isLoading:je}=Ae({queryKey:["mission-claims",r],queryFn:async()=>{if(!r)return[];const{data:i,error:l}=await Q.from("claims").select(`
*,
submissions (*)
`).eq("mission_id",r).order("created_at",{ascending:!1});if(l)throw l;return i||[]},enabled:!!r}),fe=O.length,Ne=O.filter(i=>i.status==="pending"),be=O.filter(i=>i.status==="approved"),ve=O.reduce((i,l)=>{var S;return i+(((S=l.submissions)==null?void 0:S.length)||0)},0),K=ce({mutationFn:async i=>{if(!r)throw new Error("Mission ID missing");const{error:l}=await Q.from("missions").update(i).eq("id",r);if(l)throw l},onSuccess:()=>{k.success(s("orderer.missionDetail.missionUpdated")),d.invalidateQueries({queryKey:["mission",r]}),d.invalidateQueries({queryKey:["orderer-missions"]}),U(!1)},onError:i=>{k.error(s("orderer.missionDetail.couldNotUpdate")+": "+i.message)}}),F=ce({mutationFn:async()=>{if(!r)throw new Error("Mission ID missing");const{error:i}=await Q.from("missions").update({status:"cancelled"}).eq("id",r);if(i)throw i},onSuccess:()=>{k.success(s("orderer.missionDetail.missionCancelled")),d.invalidateQueries({queryKey:["mission",r]}),d.invalidateQueries({queryKey:["orderer-missions"]})},onError:i=>{k.error(s("orderer.missionDetail.couldNotCancel")+": "+i.message)}}),ye=()=>{n&&(W(n.title),Y(n.description||""),J(n.instructions||""),Z(n.reward_credits),U(!0))},we=()=>{K.mutate({title:V,description:X,instructions:G,reward_credits:M})},se=i=>{const l=Math.max(1,M+i);Z(l)};if(j||je)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(I,{className:"w-8 h-8 animate-spin text-primary"})});if(y||!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(z,{className:"glass-card border-destructive/30",children:e.jsxs(R,{className:"p-6 text-center",children:[e.jsx(Be,{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(m,{onClick:()=>t("/orderer/dashboard"),children:s("orderer.missionDetail.backToDashboard")})]})})}),e.jsx(re,{})]});if(n.created_by!==(a==null?void 0:a.id))return t(`/mission/${r}`),null;const De=i=>{switch(i){case"active":return e.jsx(P,{className:"bg-green-600 text-white",children:s("orderer.status.active")});case"completed":return e.jsx(P,{variant:"secondary",children:s("orderer.status.completed")});case"cancelled":return e.jsx(P,{variant:"destructive",children:s("orderer.status.cancelled")});default:return e.jsx(P,{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(q.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(m,{variant:"ghost",size:"icon",onClick:()=>t("/orderer/dashboard"),children:e.jsx(Qe,{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")})]})]}),h?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{variant:"ghost",size:"sm",onClick:()=>U(!1),children:e.jsx(ze,{className:"w-4 h-4"})}),e.jsxs(m,{size:"sm",onClick:we,disabled:K.isPending,children:[K.isPending?e.jsx(I,{className:"w-4 h-4 animate-spin"}):e.jsx($e,{className:"w-4 h-4 mr-2"}),s("orderer.missionDetail.save")]})]}):e.jsxs(m,{variant:"outline",size:"sm",onClick:ye,children:[e.jsx(Ge,{className:"w-4 h-4 mr-2"}),s("orderer.missionDetail.edit")]})]}),e.jsx(q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.05},children:e.jsx(z,{className:"glass-card",children:e.jsxs(R,{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(Re,{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(Pe,{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($,{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(q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(z,{className:"glass-card",children:[e.jsx(ae,{className:"pb-2",children:e.jsxs(ne,{className:"text-lg flex items-center gap-2",children:[e.jsx(Te,{className:"w-5 h-5 text-primary"}),s("orderer.missionDetail.missionDetails")]})}),e.jsxs(R,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:s("orderer.missionDetail.titleLabel")}),h?e.jsx(Ue,{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(E,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ke,{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(E,{className:"text-xs text-muted-foreground",children:s("orderer.missionDetail.description")}),h?e.jsx(oe,{value:X,onChange:i=>Y(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(E,{className:"text-xs text-muted-foreground",children:s("orderer.missionDetail.instructions")}),h?e.jsx(oe,{value:G,onChange:i=>J(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(E,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ve,{className:"w-3 h-3"})," ",s("orderer.missionDetail.reward")]}),h?e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(m,{variant:"outline",size:"icon",onClick:()=>se(-10),disabled:M<=10,children:e.jsx(Ye,{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:[M," kr"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.required_photos," ",s("orderer.missionDetail.photos")," = ",Math.round(M/n.required_photos)," kr/",s("orderer.missionDetail.photos").slice(0,-1)]})]}),e.jsx(m,{variant:"outline",size:"icon",onClick:()=>se(10),children:e.jsx(B,{className:"w-4 h-4"})})]}):e.jsxs("p",{className:"text-xl font-bold text-warning",children:[n.reward_credits," kr",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(E,{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(q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.15},children:e.jsxs(z,{className:"glass-card",children:[e.jsx(ae,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ne,{className:"text-lg flex items-center gap-2",children:[e.jsx($,{className:"w-5 h-5 text-primary"}),s("orderer.missionDetail.exampleImages")]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"file",ref:v,onChange:ee,accept:"image/*",className:"hidden"}),e.jsxs(m,{variant:"outline",size:"sm",className:"gap-1",onClick:()=>{var i;return(i=v.current)==null?void 0:i.click()},disabled:x,children:[x?e.jsx(I,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Xe,{className:"w-3.5 h-3.5"}),s(x?"orderer.missionDetail.uploading":"orderer.missionDetail.upload")]})]})]})}),e.jsx(R,{children:f?e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[[..._,...L].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})}),h&&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(m,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:()=>ge(i.id,i.image_url),children:e.jsx(le,{className:"w-4 h-4"})})})]},i.id)),h&&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=v.current)==null?void 0:i.click()},children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(B,{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($,{className:"w-10 h-10 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:s("orderer.missionDetail.noExampleImages")}),h&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"file",ref:v,onChange:ee,accept:"image/*",className:"hidden"}),e.jsxs(m,{variant:"outline",size:"sm",className:"mt-3 gap-1",onClick:()=>{var i;return(i=v.current)==null?void 0:i.click()},disabled:x,children:[x?e.jsx(I,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(B,{className:"w-3.5 h-3.5"}),s("orderer.missionDetail.addExampleImage")]})]})]})})]})}),n.status==="active"&&e.jsx(q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsxs(m,{variant:"destructive",className:"w-full",onClick:()=>{confirm(s("orderer.missionDetail.cancelConfirm"))&&F.mutate()},disabled:F.isPending,children:[F.isPending?e.jsx(I,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(le,{className:"w-4 h-4 mr-2"}),s("orderer.missionDetail.cancelMission")]})})]}),e.jsx(re,{})]})};export{xs as default};