1import{$ as n,A as a,D as u,E as b,Mt as m,N,R as E,T as A,Tt as D,Vt as t,Yt as F,_ as j,j as l,pn as v,rt as H,vt as r,w as i}from"./vue.runtime.esm-bundler-CjpbemCW.js";import{n as L,r as O,t as $}from"./jwt-C1g7L4pz.js";import{t as M}from"./label-DiOthwFW.js";import{E as c,M as R}from"./index.js";import{n as w}from"./button-9LpO_wNB.js";import{t as S}from"./format-cybCf7HO.js";import{t as z}from"./input-Cr50i-3q.js";import{t as G}from"./textarea-CxnurqH5.js";import{n as V}from"./number-helpers-BNH2GzGx.js";import{a as p,c as K,i as I,n as g,s as Y,t as q}from"./table-Cht09SGQ.js";import{a as J,i as P,n as Q,o as W,t as X}from"./card-CTrnnpXR.js";import{t as Z}from"./invoice-module-v2-api-DcUrWPwh.js";import{t as ee}from"./EInvoiceTabs-BWgtm_lu.js";E();D(),F();var te={class:"flex flex-row items-center justify-between"},le={class:"space-y-1.5"},re={class:"flex flex-col gap-6"},ie={key:0,class:"rounded-md border bg-muted/30 p-4"},ae={class:"space-y-4"},se={class:"flex items-center justify-between"},oe={class:"grid gap-4"},ne={class:"grid gap-2"},de={class:"grid gap-2"},ue={class:"flex justify-end gap-2"},fe={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"iconify mr-2 h-4 w-4 animate-spin"},ve={key:1,class:"flex justify-center p-4"},me={key:2,class:"text-center text-muted-foreground p-4"},pe={key:3,class:"rounded-md border"},ge=N({__name:"EInvoiceUserCredits",props:{profile:{}},setup(C){const x=new Z($,O,L),h=R().params.guid.toString(),_=m([]),f=m(!1),o=m({amount:void 0,description:""}),y=m(!1),k=m(!1);async function T(){y.value=!0;try{_.value=(await x.listUserCredits(h)).data}catch(d){console.error("Failed to fetch user credits:",d)}finally{y.value=!1}}async function U(){if(!(!o.value.amount||!o.value.description)){k.value=!0;try{await x.addCredits(h,{...o.value,amount:o.value.amount*100}),f.value=!1,o.value={amount:void 0,description:""},await T()}catch(d){console.error("Failed to add credits:",d)}finally{k.value=!1}}}function B(d){return d?S(new Date(d),"dd.MM.yyyy HH:mm",{locale:c}):"-"}return T(),(d,e)=>(n(),u(j,null,[l(ee,{profile:C.profile},null,8,["profile"]),l(t(W),null,{default:r(()=>[l(t(Q),null,{default:r(()=>[i("div",te,[i("div",le,[l(t(X),null,{default:r(()=>[...e[5]||(e[5]=[a("Oversikt",-1)])]),_:1}),l(t(P),null,{default:r(()=>[e[6]||(e[6]=a(" Oversikt over ",-1)),i("b",null,v(C.profile?.username),1),e[7]||(e[7]=a(" sine tildelte kreditt og gavekort.",-1)),e[8]||(e[8]=i("br",null,null,-1))]),_:1})]),f.value?b("",!0):(n(),A(t(w),{key:0,onClick:e[0]||(e[0]=s=>f.value=!0)},{default:r(()=>[...e[9]||(e[9]=[i("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"iconify mr-2 h-4 w-4"},[i("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1),a(" Tildel kreditt ",-1)])]),_:1}))])]),_:1}),l(t(J),null,{default:r(()=>[i("div",re,[f.value?(n(),u("div",ie,[i("div",ae,[i("div",se,[e[11]||(e[11]=i("h3",{class:"font-medium"},"Tildel nye kreditt",-1)),l(t(w),{variant:"ghost",size:"sm",onClick:e[1]||(e[1]=s=>f.value=!1)},{default:r(()=>[...e[10]||(e[10]=[i("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"iconify h-4 w-4"},[i("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"})],-1)])]),_:1})]),i("div",oe,[i("div",ne,[l(t(M),{for:"amount"},{default:r(()=>[...e[12]||(e[12]=[a("Beløp (NOK)",-1)])]),_:1}),l(t(z),{id:"amount",type:"number",modelValue:o.value.amount,"onUpdate:modelValue":e[2]||(e[2]=s=>o.value.amount=s),placeholder:"F.eks. 500"},null,8,["modelValue"])]),i("div",de,[l(t(M),{for:"description"},{default:r(()=>[...e[13]||(e[13]=[a("Beskrivelse",-1)])]),_:1}),l(t(G),{id:"description","model-value":o.value.description??"","onUpdate:modelValue":e[3]||(e[3]=s=>o.value.description=String(s)),placeholder:"Ã
rsak til tildeling...",rows:"3"},null,8,["model-value"])])]),i("div",ue,[l(t(w),{variant:"outline",onClick:e[4]||(e[4]=s=>f.value=!1)},{default:r(()=>[...e[14]||(e[14]=[a(" Avbryt ",-1)])]),_:1}),l(t(w),{onClick:U,disabled:k.value||!o.value.amount||!o.value.description},{default:r(()=>[k.value?(n(),u("svg",fe,[...e[15]||(e[15]=[i("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 1 1-6.219-8.56"},null,-1)])])):b("",!0),e[16]||(e[16]=a(" Lagre ",-1))]),_:1},8,["disabled"])])]),e[17]||(e[17]=i("p",{class:""}," Tildeling av kreditts påvirker ikke allerede sendte fakturaer, istedet vil det fungere som en rabatt på fremtidige fakturaer. Når en kreditt er tildelt, vil den vises i listen under, og beløpet vil bli trukket fra totalen på neste faktura som genereres for brukeren, inntil kredittens beløp er oppbrukt eller utløpt. ",-1))])):b("",!0),y.value?(n(),u("div",ve,[...e[18]||(e[18]=[i("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"iconify h-6 w-6 animate-spin text-muted-foreground"},[i("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 1 1-6.219-8.56"})],-1)])])):_.value.length===0?(n(),u("div",me," Ingen kreditts funnet for denne brukeren. ")):(n(),u("div",pe,[l(t(K),null,{default:r(()=>[l(t(q),null,{default:r(()=>[l(t(I),null,{default:r(()=>[l(t(g),null,{default:r(()=>[...e[19]||(e[19]=[a("Dato",-1)])]),_:1}),l(t(g),null,{default:r(()=>[...e[20]||(e[20]=[a("Beskrivelse",-1)])]),_:1}),l(t(g),{class:"text-right"},{default:r(()=>[...e[21]||(e[21]=[a("Opprinnelig beløp",-1)])]),_:1}),l(t(g),{class:"text-right"},{default:r(()=>[...e[22]||(e[22]=[a("Gjenværende beløp",-1)])]),_:1}),l(t(g),null,{default:r(()=>[...e[23]||(e[23]=[a("Utløper",-1)])]),_:1})]),_:1})]),_:1}),l(t(Y),null,{default:r(()=>[(n(!0),u(j,null,H(_.value,s=>(n(),A(t(I),{key:s.userCreditId},{default:r(()=>[l(t(p),null,{default:r(()=>[a(v(B(s.createdAt)),1)]),_:2},1024),l(t(p),null,{default:r(()=>[a(v(s.description),1)]),_:2},1024),l(t(p),{class:"text-right"},{default:r(()=>[a(v(t(V)((s.originalAmount??0)/100)),1)]),_:2},1024),l(t(p),{class:"text-right font-medium"},{default:r(()=>
1[a(v(t(V)((s.remainingAmount??0)/100)),1)]),_:2},1024),l(t(p),null,{default:r(()=>[a(v(B(s.expiresAt)),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]))])]),_:1})]),_:1})],64))}}),Ve=ge;export{Ve as default};
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.