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
9.6 KiB
1 lines
9.6 KiB
var V=Object.defineProperty;var j=(s,t,e)=>t in s?V(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var d=(s,t,e)=>j(s,typeof t!="symbol"?t+"":t,e);import{C as _,V as T,_ as O,x as c,h as p,j as o,k as g,t as v,m as D,s as A,l as I,e as w,f as P,a as b,A as B,G as M,g as m,i as h,F as N,z as L,p as Y}from"./index-BLqts8WY.js";import{u as S}from"./index-CsfPLOYu.js";import{C as F}from"./ContactNameDialog-CYaRfHTt.js";import{Q as U}from"./QuickNav-DgCyvgDx.js";import{T as W}from"./TopMessage-BE0GBIgW.js";import{g as x,aH as G}from"./index-MyY_xqVN.js";var Q=Object.defineProperty,H=Object.getOwnPropertyDescriptor,J=(s,t,e,r)=>{for(var i=r>1?void 0:r?H(t,e):t,n=s.length-1,l;n>=0;n--)(l=s[n])&&(i=(r?l(t,e,i):l(i))||i);return r&&i&&Q(t,e,i),i};let k=class extends T{constructor(){super(...arguments);d(this,"$notify");d(this,"callback",()=>{});d(this,"inviteIdentifier","");d(this,"text","");d(this,"visible",!1);d(this,"expiresAt",new Date(Date.now()+1e3*60*60*24*7).toISOString().substring(0,10))}async open(e,r){this.callback=r,this.inviteIdentifier=e,this.visible=!0}async onClickSaveChanges(){this.expiresAt?(this.callback(this.text,this.expiresAt),this.visible=!1):this.$notify({group:"alert",type:"warning",title:"Needs Expiration",text:"You must select an expiration date."},5e3)}onClickCancel(){this.visible=!1}};k=J([_],k);const z={key:0,class:"dialog-overlay"},q={class:"dialog"},K={class:"mt-8"},X={class:"grid grid-cols-1 sm:grid-cols-2 gap-2"};function Z(s,t,e,r,i,n){return s.visible?(c(),p("div",z,[o("div",q,[t[4]||(t[4]=o("h1",{class:"text-xl font-bold text-center mb-4"},"Invitation & Notes",-1)),g(" These are optional notes for your use; they are comments to help you recall who it is when they accept it. These notes are sent to the server. If you want to store your own way, the invitation ID is: "+v(s.inviteIdentifier)+" ",1),D(o("input",{type:"text",placeholder:"Notes",class:"block w-full rounded border border-slate-400 mb-4 px-3 py-2","onUpdate:modelValue":t[0]||(t[0]=l=>s.text=l)},null,512),[[A,s.text]]),t[5]||(t[5]=g(" Expiration ")),D(o("input",{type:"date",class:"block rounded border border-slate-400 mb-4 px-3 py-2","onUpdate:modelValue":t[1]||(t[1]=l=>s.expiresAt=l)},null,512),[[A,s.expiresAt]]),o("div",K,[o("div",X,[o("button",{type:"button",class:"block w-full text-center text-lg font-bold uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md mb-2",onClick:t[2]||(t[2]=l=>s.onClickSaveChanges())}," Save "),o("button",{type:"button",class:"block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md mb-2",onClick:t[3]||(t[3]=l=>s.onClickCancel())}," Cancel ")])])])])):I("",!0)}const ee=O(k,[["render",Z]]);var te=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ie=(s,t,e,r)=>{for(var i=r>1?void 0:r?se(t,e):t,n=s.length-1,l;n>=0;n--)(l=s[n])&&(i=(r?l(t,e,i):l(i))||i);return r&&i&&te(t,e,i),i};let $=class extends T{constructor(){super(...arguments);d(this,"$notify");d(this,"invites",[]);d(this,"activeDid","");d(this,"apiServer","");d(this,"contactsRedeemed",{});d(this,"isRegistered",!1);d(this,"showAppleWarning",!1)}async mounted(){try{await w.open();const e=await P();this.activeDid=e.activeDid||"",this.apiServer=e.apiServer||"",this.isRegistered=!!e.isRegistered;const r=await x(this.activeDid),i=await b.get(this.apiServer+"/api/userUtil/invite",{headers:r});this.invites=i.data.data;const n=await w.contacts.toArray();for(const l of this.invites){const f=n.find(u=>u.did===l.redeemedBy);f&&l.redeemedBy&&(this.contactsRedeemed[l.redeemedBy]=f)}}catch(e){console.error("Error fetching invites:",e),this.$notify({group:"alert",type:"danger",title:"Load Error",text:"Got an error loading your invites."},5e3)}}getTruncatedInviteId(e){return e.length<=9?e:`${e.slice(0,6)}...`}getTruncatedRedeemedBy(e){return e?this.contactsRedeemed[e]?this.contactsRedeemed[e].name||B.NO_CONTACT_NAME:e.length<=19?e:`${e.slice(0,13)}...${e.slice(-3)}`:""}inviteLink(e){return M+"/invite-one-accept/"+e}copyInviteAndNotify(e,r){S().copy(this.inviteLink(r)),this.$notify({group:"alert",type:"success",title:"Copied",text:"Your clipboard now contains the link for invite "+e},5e3)}showInvite(e,r,i){let n=`Your clipboard now contains the invite ID ${e}`;r?n+=" (This invite has been used.)":i&&(n+=" (This invite has expired.)"),S().copy(e),this.$notify({group:"alert",type:"success",title:"Copied",text:n},5e3)}lookForErrorAndNotify(e,r,i){console.error(r,"-",e);let n=i;e.response&&e.response.data&&e.response.data.error&&(e.response.data.error.message?n=e.response.data.error.message:n=e.response.data.error),this.$notify({group:"alert",type:"danger",title:r,text:n},5e3)}async createInvite(){const e=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this.$refs.inviteDialog.open(e,async(r,i)=>{try{const n=await x(this.activeDid);if(!i)throw{response:{data:{error:"You must select an expiration date."}}};const l=(new Date(i).getTime()-Date.now())/1e3,f=await G(this.activeDid,void 0,e,l);await b.post(this.apiServer+"/api/userUtil/invite",{inviteJwt:f,notes:r},{headers:n});const u={inviteIdentifier:e,expiresAt:i,jwt:f,notes:r,redeemedAt:null,redeemedBy:null};this.invites=[u,...this.invites]}catch(n){this.lookForErrorAndNotify(n,"Error Creating Invite","Got an error creating your invite.")}})}addNewContact(e,r){this.$refs.contactNameDialog.open("To Whom Did You Send The Invite?","Their name will be added to your contact list.",i=>{const n={did:e,name:i,registered:!0};w.contacts.add(n),this.contactsRedeemed[e]=n,this.$notify({group:"alert",type:"success",title:"Contact Added",text:`${i} has been added to your contacts.`},3e3)},()=>{},r)}deleteInvite(e,r){this.$notify({group:"modal",type:"confirm",title:"Delete Invite?",text:`Are you sure you want to erase the invite for "${r}"? (There is no undo.)`,onYes:async()=>{const i=await x(this.activeDid);try{const n=await b.delete(this.apiServer+"/api/userUtil/invite/"+e,{headers:i});if(n.status!==204)throw n.data;this.invites=this.invites.filter(l=>l.inviteIdentifier!==e),this.$notify({group:"alert",type:"success",title:"Deleted",text:"Invite deleted."},3e3)}catch(n){this.lookForErrorAndNotify(n,"Error Deleting Invite","Got an error deleting your invite.")}}},-1)}};$=ie([_({components:{ContactNameDialog:F,QuickNav:U,TopMessage:W,InviteDialog:ee}})],$);const ne={id:"Content",class:"p-6 pb-24 max-w-3xl mx-auto"},oe={class:"text-lg text-center font-light relative px-7"},re={class:"ml-8 mt-4 list-outside list-disc w-5/6"},ae={key:1},le={key:1,class:"mt-6"},de={class:"min-w-full bg-white"},ce=["onClick","title"],pe=["onClick","title"],ue=["data-testId"],fe={class:"text-center"},he={class:"text-center"},ve={key:2,class:"mt-6 text-center"};function ge(s,t,e,r,i,n){const l=m("QuickNav"),f=m("TopMessage"),u=m("fa"),R=m("InviteDialog"),E=m("ContactNameDialog");return c(),p(N,null,[h(l,{selected:"Invite"}),h(f),o("section",ne,[o("div",oe,[o("h1",{class:"text-lg text-center px-2 py-1 absolute -left-2 -top-1",onClick:t[0]||(t[0]=a=>s.$router.back())},[h(u,{icon:"chevron-left",class:"fa-fw"})])]),t[7]||(t[7]=o("h1",{class:"text-4xl text-center font-light"},"Invitations",-1)),o("ul",re,[o("li",null,[t[3]||(t[3]=g(" Note when sending ")),s.showAppleWarning?(c(),p("span",ae," to Apple users: their links often fail because their device cuts off part of the link. You might need to send it to them some other way, like in an email. ")):(c(),p("span",{key:0,class:"text-blue-500 cursor-pointer",onClick:t[1]||(t[1]=a=>s.showAppleWarning=!s.showAppleWarning)}," to Apple users... "))])]),s.isRegistered?(c(),p("button",{key:0,class:"fixed right-6 top-12 text-center text-4xl leading-none bg-green-600 text-white w-14 py-2.5 rounded-full",onClick:t[2]||(t[2]=a=>s.createInvite())},[h(u,{icon:"plus",class:"fa-fw"})])):I("",!0),h(R,{ref:"inviteDialog"},null,512),s.invites.length?(c(),p("div",le,[o("table",de,[t[6]||(t[6]=o("thead",null,[o("tr",null,[o("th",{class:"py-2"},[g(" ID "),o("br"),g(" (click for link) ")]),o("th",{class:"py-2"},"Notes"),o("th",{class:"py-2"},"Expires At"),o("th",{class:"py-2"},"Redeemed")])],-1)),o("tbody",null,[(c(!0),p(N,null,L(s.invites,a=>{var C;return c(),p("tr",{key:a.inviteIdentifier,class:"border-t py-2"},[o("td",null,[!a.redeemedAt&&a.expiresAt>new Date().toISOString()?(c(),p("span",{key:0,onClick:y=>s.copyInviteAndNotify(a.inviteIdentifier,a.jwt),class:"text-center text-blue-500 cursor-pointer",title:s.inviteLink(a.jwt)},v(s.getTruncatedInviteId(a.inviteIdentifier)),9,ce)):(c(),p("span",{key:1,onClick:y=>s.showInvite(a.inviteIdentifier,!!a.redeemedAt,a.expiresAt<new Date().toISOString()),class:"text-center text-slate-500 cursor-pointer",title:s.inviteLink(a.jwt)},v(s.getTruncatedInviteId(a.inviteIdentifier)),9,pe))]),o("td",{class:"text-left","data-testId":s.inviteLink(a.jwt)},v(a.notes),9,ue),o("td",fe,v(a.redeemedAt?"":a.expiresAt.substring(0,10)),1),o("td",he,[g(v((C=a.redeemedAt)==null?void 0:C.substring(0,10))+" ",1),t[4]||(t[4]=o("br",null,null,-1)),g(" "+v(s.getTruncatedRedeemedBy(a.redeemedBy))+" ",1),t[5]||(t[5]=o("br",null,null,-1)),a.redeemedBy&&!s.contactsRedeemed[a.redeemedBy]?(c(),Y(u,{key:0,icon:"plus",class:"bg-green-600 text-white px-1 py-1 rounded-full cursor-pointer",onClick:y=>s.addNewContact(a.redeemedBy,a.notes)},null,8,["onClick"])):I("",!0)]),o("td",null,[h(u,{icon:"trash-can",class:"text-red-600 text-xl ml-2 mr-2 cursor-pointer",onClick:y=>s.deleteInvite(a.inviteIdentifier,a.notes)},null,8,["onClick"])])])}),128))])]),h(E,{ref:"contactNameDialog"},null,512)])):(c(),p("p",ve,"No invites found."))])],64)}const De=O($,[["render",ge]]);export{De as default};
|
|
|