Files
PhaseWeb3-Vue/assets/CardsView.ea8ebf16.js

2 lines
3.0 KiB
JavaScript

import{r as _,s as $,o as k,a as r,c as g,w as i,b as t,W as I,X as h,e as o,a2 as A,_ as D,v as V,f as c,I as S,k as w,a3 as E,g as s,Q as F,i as p,F as P,j as N,t as T,l as O,n as B,V as L}from"./index.3d4bf4c6.js";import{d as v}from"./userData.bcc92478.js";import{_ as j}from"./FormField.6dc9c939.js";import{_ as M}from"./FormControl.93f28bf6.js";import{g as U,h as W,i as q}from"./account.d1ab38cd.js";const z={class:"grid md:grid-cols-2 mb-2"},G=s("div",{class:"text-xl md:text-right"},[s("h4",null,"AC = Web Access Code"),s("h4",null,[L("NFC-ID = Internal ID for "),s("samp",null,"card0.txt")])],-1),H={key:0,class:"grid grid-cols-1 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-6"},Q={class:"flex justify-between md:grid md:gap-2 mb-4 items-center"},R=["src"],Z={class:"text-xl text-center font-mono"},J={class:"grid grid-cols-3 md:grid-cols-2 gap-2"},le={__name:"CardsView",setup(K){const b="https://cdn.phaseii.network/file/PhaseII/web-assets";var d=_([]);const u=_(!1),n=$({newCard:null});async function m(){d.value=null;try{const e=await U();d.value=e}catch(e){console.error("Failed to fetch card data:",e)}}k(async()=>{await m()});function y(e){var a=e.target.value;a=a.replace(/[^A-Za-z0-9]/g,""),a=a.toUpperCase().replace(/(.{4})/g,"$1-").replace(/-$/,""),n.newCard=a}async function x(){u.value=!0,(await q(n.newCard)).status=="success"&&(n.newCard=null,u.value=!1,await m())}async function X(e){(await W(v(e))).status=="success"&&await m()}const C=e=>{navigator.clipboard.writeText(e).then(()=>{alert("Copied to clipboard!")}).catch(()=>{alert("Failed to copy to clipboard!")})};return(e,a)=>(r(),g(B,null,{default:i(()=>[t(O,null,{default:i(()=>[t(I,{class:"mb-6","use-small":"","even-smaller":""}),t(h,{icon:o(A),title:"Register Card",main:""},null,8,["icon"]),t(D,{"is-form":"",class:"row-span-2 mb-6",onSubmit:a[1]||(a[1]=V(l=>x(),["prevent"]))},{footer:i(()=>[t(c,{type:"submit",color:"success",label:"Add Card"}),u.value?(r(),g(S,{key:0,path:e.mdiLoading,color:"text-yellow-500",class:"animate animate-spin"},null,8,["path"])):w("",!0)]),default:i(()=>[t(j,{label:"Card ID",help:"The 16 character ACCESS CODE. If your card is dated after 2016, you'll need to get the ACCESS CODE from a game."},{default:i(()=>[t(M,{modelValue:n.newCard,"onUpdate:modelValue":a[0]||(a[0]=l=>n.newCard=l),icon:o(E),name:"cardId",type:"card",placeholder:"XXXX-XXXX-XXXX-XXXX",minlength:19,maxlength:19,required:"",onInput:y},null,8,["modelValue","icon"])]),_:1})]),_:1}),s("div",z,[t(h,{icon:o(F),title:"Login Cards",main:""},null,8,["icon"]),G]),o(d)?(r(),p("div",H,[(r(!0),p(P,null,N(o(d),l=>(r(),p("div",{key:l.id,class:"grid dark:bg-slate-900/70 rounded-2xl p-5"},[s("div",Q,[s("img",{src:`${o(b)}/passes/generic.webp`,class:"w-24 md:w-auto"},null,8,R),s("h1",Z,T(o(v)(l.encoded)),1)]),s("div",J,[t(c,{color:"info",label:"Copy AC",onClick:f=>C(l.encoded)},null,8,["onClick"]),t(c,{color:"info",label:"Copy NFC-ID",onClick:f=>C(l.id)},null,8,["onClick"]),t(c,{color:"danger",label:"Delete",onClick:f=>X(l.encoded)},null,8,["onClick"])])]))),128))])):w("",!0)]),_:1})]),_:1}))}};export{le as default};