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.

2 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)}`:""