You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
6.1 KiB

var $=Object.defineProperty;var T=(a,t,s)=>t in a?$(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var v=(a,t,s)=>T(a,typeof t!="symbol"?t+"":t,s);import{V as E,e as N,f as O,C as V,_ as j,g as x,h as l,i as m,j as e,w as G,t as y,F as b,z as R,x as d,k as D,l as A}from"./index-BLqts8WY.js";import{Q as I}from"./QuickNav-DgCyvgDx.js";import{A as U,G as F,g as _,H as J,S,I as M}from"./index-MyY_xqVN.js";import{c as B}from"./concat-BK8PKeDS.js";import{s as H}from"./sort-Dh4GzQVc.js";import"./index-CsfPLOYu.js";var P=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,W=(a,t,s,i)=>{for(var n=i>1?void 0:i?Q(t,s):t,h=a.length-1,r;h>=0;h--)(r=a[h])&&(n=(i?r(t,s,n):r(n))||n);return i&&n&&P(t,s,n),n};let w=class extends E{constructor(){super(...arguments);v(this,"$notify");v(this,"activeDid","");v(this,"apiServer","");v(this,"contact",null);v(this,"giveRecords",[]);v(this,"numAccounts",0);v(this,"displayAmount",U)}async beforeCreate(){this.numAccounts=await F()}async created(){try{const t=this.$route.query.contactDid;this.contact=await N.contacts.get(t)||null;const s=await O();this.activeDid=(s==null?void 0:s.activeDid)||"",this.apiServer=(s==null?void 0:s.apiServer)||"",this.activeDid&&this.contact&&this.loadGives(this.activeDid,this.contact)}catch(t){console.error("Error retrieving settings or gives.",t),this.$notify({group:"alert",type:"danger",title:"Error",text:t.userMessage||"There was an error retrieving your settings or contacts or gives."},-1)}}async loadGives(t,s){try{let i=[];const n=this.apiServer+"/api/v2/report/gives?agentDid="+encodeURIComponent(this.activeDid)+"&recipientDid="+encodeURIComponent(s.did),h=await _(t),r=await this.axios.get(n,{headers:h});r.status===200?i=r.data.data:(console.error("Got bad response status & data of",r.status,r.data),this.$notify({group:"alert",type:"danger",title:"Error With Server",text:"Got an error retrieving your given time from the server."},-1));const c=this.apiServer+"/api/v2/report/gives?agentDid="+encodeURIComponent(s.did)+"&recipientDid="+encodeURIComponent(this.activeDid),g=await _(t),p=await this.axios.get(c,{headers:g});p.status===200?i=B(i,p.data.data):(console.error("Got bad response status & data of",p.status,p.data),this.$notify({group:"alert",type:"danger",title:"Error With Server",text:"Got an error retrieving your given time from the server."},-1));const o=H((u,f)=>new Date(f.issuedAt).getTime()-new Date(u.issuedAt).getTime(),i);this.giveRecords=o}catch(i){this.$notify({group:"alert",type:"danger",title:"Error With Server",text:i},-1)}}async confirm(t){var g,p;const s=J(t.fullClaim);t.fullClaim["@context"]==S&&delete s["@context"],s.identifier=t.handleId;const i={"@context":S,"@type":"AgreeAction",object:s},n=await M(this.activeDid,i),h=JSON.stringify({jwtEncoded:n}),r=this.apiServer+"/api/v2/claim",c=await _(this.activeDid);try{(g=(await this.axios.post(r,h,{headers:c})).data)!=null&&g.success&&(t.amountConfirmed=((p=s.object)==null?void 0:p.amountOfThisGood)||1)}catch(o){let u="There was an error.";const f=o;f?f.message?u=f.message:u=JSON.stringify(f.toJSON()):u=o,this.$notify({group:"alert",type:"danger",title:"Error With Server",text:u},-1)}}cannotConfirmMessage(){this.$notify({group:"alert",type:"danger",title:"Not Allowed",text:"Only the recipient can confirm final receipt."},-1)}};w=W([V({components:{QuickNav:I}})],w);const L={id:"Content",class:"p-6 pb-24 max-w-3xl mx-auto"},q={class:"mb-8"},z={id:"ViewBreadcrumb",class:"text-lg text-center font-light relative px-7"},X={id:"ViewHeading",class:"text-4xl text-center font-light pt-4"},K={class:"table-auto w-full border-t border-slate-300 text-sm sm:text-base text-center"},Y={class:"p-1 text-xs sm:text-sm text-left text-slate-500"},Z={class:"p-1"},tt={key:0},et={class:"font-bold"},st={key:0,title:"Confirmed"},ot=["onClick"],at={class:"italic text-xs sm:text-sm text-slate-500"},it={class:"p-1"},nt={key:0},rt={key:1},ct={class:"p-1"},lt={key:0},dt={class:"font-bold"},pt={key:0,title:"Confirmed"},ut={class:"italic text-xs sm:text-sm text-slate-500"};function ft(a,t,s,i,n,h){var p;const r=x("QuickNav"),c=x("fa"),g=x("router-link");return d(),l(b,null,[m(r,{selected:"Contacts"}),e("section",L,[e("div",q,[e("h1",z,[m(g,{to:{name:"contacts"},class:"text-lg text-center px-2 py-1 absolute -left-2 -top-1"},{default:G(()=>[m(c,{icon:"chevron-left",class:"fa-fw"})]),_:1})]),e("h1",X," Transferred with "+y((p=a.contact)==null?void 0:p.name),1)]),t[2]||(t[2]=e("div",{class:"flex justify-around"},[e("span"),e("span",{class:"justify-around"},"(Only 50 most recent)"),e("span")],-1)),t[3]||(t[3]=e("div",{class:"flex justify-around"},[e("span"),e("span",{class:"justify-around"}," (This does not include claims by them if they're not visible to you.) "),e("span")],-1)),e("table",K,[t[1]||(t[1]=e("thead",{class:"bg-slate-100"},[e("tr",{class:"border-b border-slate-300"},[e("th"),e("th",{class:"px-1 py-2"},"From Them"),e("th"),e("th",{class:"px-1 py-2"},"To Them")])],-1)),e("tbody",null,[(d(!0),l(b,null,R(a.giveRecords,o=>{var u,f,C;return d(),l("tr",{key:o.id,class:"border-b border-slate-300"},[e("td",Y,y(new Date(o.issuedAt).toLocaleString()),1),e("td",Z,[o.agentDid==((u=a.contact)==null?void 0:u.did)?(d(),l("span",tt,[e("div",et,[D(y(a.displayAmount(o.unit,o.amount))+" ",1),o.amountConfirmed?(d(),l("span",st,[m(c,{icon:"circle-check",class:"text-green-600 fa-fw"})])):(d(),l("button",{key:1,onClick:k=>a.confirm(o),title:"Unconfirmed"},[m(c,{icon:"circle",class:"text-blue-600 fa-fw"})],8,ot))]),e("div",at,y(o.description),1)])):A("",!0)]),e("td",it,[o.agentDid==((f=a.contact)==null?void 0:f.did)?(d(),l("span",nt,[m(c,{icon:"arrow-left",class:"text-slate-400 fa-fw"})])):(d(),l("span",rt,[m(c,{icon:"arrow-right",class:"text-slate-400 fa-fw"})]))]),e("td",ct,[o.agentDid!=((C=a.contact)==null?void 0:C.did)?(d(),l("span",lt,[e("div",dt,[D(y(a.displayAmount(o.unit,o.amount))+" ",1),o.amountConfirmed?(d(),l("span",pt,[m(c,{icon:"circle-check",class:"text-green-600 fa-fw"})])):(d(),l("button",{key:1,onClick:t[0]||(t[0]=k=>a.cannotConfirmMessage()),title:"Unconfirmed"},[m(c,{icon:"circle",class:"text-slate-600 fa-fw"})]))]),e("div",ut,y(o.description),1)])):A("",!0)])])}),128))])])])],64)}const wt=j(w,[["render",ft]]);export{wt as default};