PageSourceSearch

https://spotz.global/assets/crm.prosjekter._id-BtO0aO2w.js

js spotz.global collected 2026-10-09 22:06:40 UTC 12,270 bytes, 1 lines download raw bytes

1import{aq as be,h as ke,r as u,j as e,L as we,X as Pe}from"./index-bQZ6-MOf.js";import{u as j}from"./useQuery-BAgesPRj.js";import{u as c}from"./useMutation-BqblAeBb.js";import{u as a}from"./createServerFn-CU39I-WU.js";import{g as Se,b as Te,l as qe,e as Fe,r as Ae,f as Ke,h as Ee,i as Ie,j as Me,P as Le}from"./PhaseBadge-DUR6-4xb.js";import{j as Be,i as Ve,k as De,b as ze,g as Qe,t as He,h as Re}from"./crm.functions-LlKiiH4n.js";import{C as k}from"./card-CBB0DeSN.js";import{B as d}from"./button-FZYZqtg_.js";import{I as h}from"./input-BVxfNuVn.js";import{L as i}from"./label-DAIozxdR.js";import{T as O}from"./textarea-CyCG1bDT.js";import{B as U}from"./badge-DX37h3iV.js";import{C as Oe,A as Ue}from"./ActivityDialog-Cmi7BuRd.js";import{S as f,b as N,c as y,d as _,e as l}from"./select-C2uG7tmb.js";import{T as Xe,a as $e,b as X,c as S,d as Ge,e as T}from"./table-BHcxPV8I.js";import{t as p}from"./index-bl41CerC.js";import{e as Je,a as We}from"./AttachmentManager-VlY9FJ4W.js";import{A as Ye}from"./arrow-left-NVxwppvD.js";import{C as Ze}from"./clock-Dgvd9tuF.js";import{C as es}from"./check-FkfMqtoq.js";import{P as ss}from"./pencil-Bkld04if.js";import{T as $}from"./trash-2-CSPNkB6s.js";import{P as G}from"./plus-BTpNNBeh.js";import"./suspense-IMGYCAfs.js";import"./auth-middleware-24HItX2r.js";import"./utils-BQHNewu7.js";import"./dialog-D_gBSd9w.js";import"./index-BPzT5xwB.js";import"./useDirtyClose-uD0I9aKP.js";import"./index-CBAKR8_h.js";import"./chevron-down-D6XLa2aq.js";import"./chevron-up-gSPmVLc9.js";import"./file-text-Dn6GVqtF.js";import"./paperclip-DyKBC2yl.js";import"./loader-circle-CKIcQc3r.js";import"./eye-jSbaXCnC.js";import"./download-CNV669kQ.js";function Vs(){const{id:n}=be({from:"/crm/prosjekter/$id"}),w=ke(),J=a(Se),W=a(Te),Y=a(qe),Z=a(Be),ee=a(Ve),se=a(De),te=a(ze),ae=a(Fe),ne=a(Ae),ie=a(Ke),re=a(Ee),le=a(Ie),oe=a(Me),ce=a(Qe),de=a(He),me=a(Re),{data:g}=j({queryKey:["crm-project",n],queryFn:()=>J({data:{id:n}})}),{data:ue=[]}=j({queryKey:["crm-persons-all"],queryFn:()=>Z({data:{}})}),{data:he=[]}=j({queryKey:["crm-companies-all"],queryFn:()=>ee({data:{}})}),{data:xe=[]}=j({queryKey:["crm-users"],queryFn:()=>se()}),{data:je=[]}=j({queryKey:["crm-categories","project"],queryFn:()=>te({data:{appliesTo:"project"}})}),{data:K=[]}=j({queryKey:["crm-project-phases"],queryFn:()=>Y()}),{data:E=[]}=j({queryKey:["crm-project-time",n],queryFn:()=>re({data:{projectId:n}})}),o=()=>{w.invalidateQueries({queryKey:["crm-project",n]}),w.invalidateQueries({queryKey:["crm-project-time",n]}),w.invalidateQueries({queryKey:["my-open-task-count"]}),w.invalidateQueries({queryKey:["my-activities"]})},[I,pe]=u.useState(null),[P,M]=u.useState(""),[L,B]=u.useState(""),[q,V]=u.useState(0),[F,D]=u.useState(0),[z,Q]=u.useState(""),[H,C]=u.useState(null),[r,v]=u.useState(null),ge=c({mutationFn:s=>W({data:s}),onSuccess:()=>{o(),p.success("Lagret")}}),ve=c({mutationFn:()=>ae({data:{projectId:n,personId:P,role:L||null}}),onSuccess:()=>{o(),M(""),B("")}}),fe=c({mutationFn:s=>ne({data:{id:s}}),onSuccess:o}),A=c({mutationFn:()=>ie({data:{projectId:n,hours:Math.max(0,Math.floor(Number(q)||0)),minutes:Math.max(0,Math.floor(Number(F)||0)),note:z||null}}),onSuccess:()=>{o(),V(0),D(0),Q(""),p.success("Tid lagt til")},onError:s=>p.error(s?.message??"Kunne ikke lagre tid")}),R=c({mutationFn:s=>le({data:s}),onSuccess:()=>{o(),v(null),p.success("Oppdatert")},onError:s=>p.error(s?.message??"Kunne ikke oppdatere")}),Ne=c({mutationFn:s=>oe({data:{id:s}}),onSuccess:()=>{o(),p.success("Slettet")},onError:s=>p.error(s?.message??"Kunne ikke slette")}),ye=c({mutationFn:s=>ce({data:s}),onSuccess:()=>{o(),C(null)}}),_e=c({mutationFn:s=>de({data:s}),onSuccess:o}),Ce=c({mutationFn:s=>me({data:{id:s}}),onSuccess:()=>{o(),C(null)}});if(!g?.project)return e.jsx("div",{className:"text-muted-foreground",children:"Laster…"});const t=I??g.project,m=(s,x)=>pe({...I??g.project,[s]:x});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(we,{to:"/crm/prosjekter",className:"text-sm text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(Ye,{className:"w-4 h-4"})," Tilbake til prosjekter"]}),e.jsxs(k,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Tittel"}),e.jsx(h,{value:t.title,onChange:s=>m("title",s.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Fase"}),e.jsxs(f,{value:t.phase,onValueChange:s=>m("phase",s),children:[e.jsx(N,{children:e.jsx(y,{asChild:!0,children:e.jsx(Le,{name:t.phase,phases:K})})}),e.jsx(_,{children:K.map(s=>e.jsx(l,{value:s.name,children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"w-3 h-3 rounded-full",style:{background:s.
1color}}),s.name]})},s.id))})]})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Status"}),e.jsxs(f,{value:t.status,onValueChange:s=>m("status",s),children:[e.jsx(N,{children:e.jsx(y,{})}),e.jsxs(_,{children:[e.jsx(l,{value:"active",children:"Aktiv"}),e.jsx(l,{value:"archived",children:"Arkivert"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Selskap"}),e.jsxs(f,{value:t.company_id??"__none__",onValueChange:s=>m("company_id",s==="__none__"?null:s),children:[e.jsx(N,{children:e.jsx(y,{placeholder:"Ingen"})}),e.jsxs(_,{children:[e.jsx(l,{value:"__none__",children:"Ingen"}),he.map(s=>e.jsx(l,{value:s.id,children:s.name},s.id))]})]})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Prosjekteier"}),e.jsxs(f,{value:t.owner_id??"__none__",onValueChange:s=>m("owner_id",s==="__none__"?null:s),children:[e.jsx(N,{children:e.jsx(y,{placeholder:"Ingen"})}),e.jsxs(_,{children:[e.jsx(l,{value:"__none__",children:"Ingen"}),xe.map(s=>e.jsx(l,{value:s.id,children:s.display_name||s.email||s.id},s.id))]})]})]})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Kategori"}),e.jsxs(f,{value:t.category_id??"__none__",onValueChange:s=>m("category_id",s==="__none__"?null:s),children:[e.jsx(N,{children:e.jsx(y,{placeholder:"Ingen"})}),e.jsxs(_,{children:[e.jsx(l,{value:"__none__",children:"Ingen"}),je.map(s=>e.jsx(l,{value:s.id,children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"w-3 h-3 rounded-full",style:{background:s.color}}),s.name]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Mål"}),e.jsx(O,{rows:3,value:t.goals??"",onChange:s=>m("goals",s.target.value)})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Sluttnotat"}),e.jsx(O,{rows:2,value:t.end_note??"",onChange:s=>m("end_note",s.target.value)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx(Ze,{className:"w-4 h-4"})," Brukt tid: ",e.jsxs("strong",{children:[Math.floor(t.time_minutes/60),"t ",t.time_minutes%60,"min"]})]}),e.jsx(d,{onClick:()=>ge.mutate({id:n,title:t.title,phase:t.phase,status:t.status,goals:t.goals,end_note:t.end_note,category_id:t.category_id,company_id:t.company_id,person_id:t.person_id,owner_id:t.owner_id}),children:"Lagre"})]})]}),e.jsxs(k,{className:"p-4",children:[e.jsx("h3",{className:"font-medium mb-3",children:"Tidsføring"}),e.jsxs("div",{className:"flex gap-2 items-end flex-wrap",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Timer"}),e.jsx(h,{type:"number",inputMode:"numeric",min:0,step:1,value:q,onChange:s=>V(s.target.value===""?0:Number(s.target.value)),className:"w-24"})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Minutter"}),e.jsx(h,{type:"number",inputMode:"numeric",min:0,max:59,step:5,value:F,onChange:s=>D(s.target.value===""?0:Number(s.target.value)),className:"w-24"})]}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx(i,{children:"Kommentar"}),e.jsx(h,{placeholder:"Hva gikk tiden til?",value:z,onChange:s=>Q(s.target.value)})]}),e.jsx(d,{onClick:()=>A.mutate(),disabled:A.isPending||(Number(q)||0)===0&&(Number(F)||0)===0,children:A.isPending?"Lagrer…":"Legg til"})]}),E.length>0&&e.jsx("div",{className:"mt-4 overflow-x-auto",children:e.jsxs(Xe,{children:[e.jsx($e,{children:e.jsxs(X,{children:[e.jsx(S,{className:"w-[140px]",children:"Dato"}),e.jsx(S,{className:"w-[120px]",children:"Tid"}),e.jsx(S,{children:"Kommentar"}),e.jsx(S,{className:"w-[120px] text-right",children:"Handling"})]})}),e.jsx(Ge,{children:E.map(s=>{const x=r?.id===s.id;return e.jsxs(X,{children:[e.jsx(T,{className:"text-sm text-muted-foreground",children:new Date(s.created_at).toLocaleString("nb-NO",{dateStyle:"short",timeStyle:"short"})}),e.jsx(T,{children:x?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(h,{type:"number",min:0,value:r.hours,onChange:b=>v({...r,hours:Number(b.target.value)||0}),className:"w-16 h-8"}),e.jsx(h,{type:"number",min:0,max:59,value:r.minutes,onChange:b=>v({...r,minutes:Number(b.target.value)||0}),className:"w-16 h-8"})]}):e.jsxs("span",{children:[Math.floor(s.minutes/60),"t ",s.minutes%60,"min"]})}),e.jsx(T,{children:x?e.jsx(h,{value:r.note,onChange:b=>v({...r,note:b.target.value}),className:"h-8"}):e.jsx("span",{className:"text-sm",children:s.note||e.jsx("span",{className:"text-muted-foreground italic",children:"—"})})}),e.jsx(T,{className:"text-right",children:x?e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(d,{size:"icon",variant:"ghost",onClick:()=>R.mutate({id:s.id,hours:r.hours,minutes:r.minutes,note:r.note||null}),disabled:R.isPending,children:e.jsx(es,{className:"w-4 h-4"})}),e.jsx(d,{size:"icon",variant:"ghost",onClick:()=>v(null),children:e.jsx(Pe,{className:"w-4 h-4"})})]}):e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(d,{size:"icon",variant:"ghost",onClick:()=>v({id:s.id,hours:Math.floor(s.minutes/60),minutes:s.minutes%60,note:s.note??""}),children:e.jsx(ss,{className:"w-4 h-4"})}),e.jsx(d,{size:"icon",variant:"ghost",onClick:()=>{confirm("Slette denne tidsføringen?")&&Ne.mutate(s.id)},children:e.jsx($,{className:"w-4 h-4"})})]})})]},s.id)})})]})})]}),e.jsxs(k,{className:"p-4",children:[e.jsx("h3",{className:"font-medium mb-3",children:"Deltakere"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs(f,{value:P,onValueChange:M,children:[e.jsx(N,{className:"flex-1",children:e.jsx(y,{placeholder:"Velg person…"})}),e.jsx(_,{children:ue.map(s=>
1e.jsx(l,{value:s.id,children:[s.first_name,s.last_name].filter(Boolean).join(" ")},s.id))})]}),e.jsx(h,{placeholder:"Rolle",value:L,onChange:s=>B(s.target.value),className:"w-40"}),e.jsx(d,{onClick:()=>P&&ve.mutate(),disabled:!P,children:e.jsx(G,{className:"w-4 h-4"})})]}),e.jsx("ul",{className:"divide-y divide-border",children:g.participants.map(s=>e.jsxs("li",{className:"py-2 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:[s.persons?.first_name,s.persons?.last_name].filter(Boolean).join(" ")}),s.role&&e.jsx(U,{variant:"outline",className:"ml-2",children:s.role})]}),e.jsx(d,{variant:"ghost",size:"sm",onClick:()=>fe.mutate(s.id),children:e.jsx($,{className:"w-3 h-3"})})]},s.id))})]}),e.jsxs(k,{className:"p-4",children:[e.jsx("h3",{className:"font-medium mb-3",children:"Vedlegg"}),e.jsx(Je,{entityType:"project",entityId:n})]}),e.jsxs(k,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("h3",{className:"font-medium",children:"Aktiviteter"}),e.jsxs(d,{size:"sm",onClick:()=>C({title:"",type:"task",project_id:n}),children:[e.jsx(G,{className:"w-4 h-4"})," Ny"]})]}),e.jsxs("ul",{className:"divide-y divide-border",children:[g.activities.map(s=>e.jsxs("li",{className:"py-2 flex items-center gap-3",children:[e.jsx(Oe,{checked:s.completed,onCheckedChange:x=>_e.mutate({id:s.id,completed:!!x})}),e.jsxs("div",{className:"flex-1 cursor-pointer",onClick:()=>C(s),children:[e.jsx("div",{className:s.completed?"line-through text-muted-foreground":"",children:s.title}),s.due_date&&e.jsx("div",{className:"text-xs text-muted-foreground",children:We(s.due_date)})]}),e.jsx(U,{variant:"outline",children:s.type})]},s.id)),g.activities.length===0&&e.jsx("li",{className:"py-3 text-sm text-muted-foreground",children:"Ingen aktiviteter."})]})]}),e.jsx(Ue,{open:!!H,onOpenChange:s=>!s&&C(null),value:H,onSave:s=>ye.mutate(s),onDelete:s=>Ce.mutate(s)})]})}export{Vs as component};

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.