PageSourceSearch

https://vidapeps.com/assets/WalletApprove-79RcqVO_.js

js vidapeps.com collected 2026-10-04 08:09:53 UTC 9,044 bytes, 1 lines download raw bytes

1import{u as I,j as e}from"./vendor-query-CniT1WJL.js";import{k as E,r as i,L as A}from"./vendor-react-69GsFwrV.js";import{aI as p,d3 as d,V as g,de as F,df as M,dg as f,dh as Y,di as G}from"./index-KjAD5lCC.js";import{P as k}from"./PaymentCard-CNmbrjef.js";import{a as w,P as H}from"./PayLinkSummaryCard-Cm5xFSna.js";import{a2 as K,J as Q,g as $,aw as z,aW as J,G as U}from"./vendor-ui-Ad3ANzF6.js";import"./vendor-forms-q6h4WU-p.js";function X(){if(typeof window>"u")return f.qr;const c=new URLSearchParams(window.location.search).get("via");return c==="email"?f.email:c==="sms"?f.sms:f.qr}function _(){return e.jsxs("div",{className:"space-y-4","aria-busy":"true",role:"status","aria-label":"Loading approval request",children:[e.jsx("div",{className:"h-44 animate-pulse rounded-card border border-card-border bg-muted/40"}),e.jsx("div",{className:"h-40 animate-pulse rounded-card border border-card-border bg-muted/40"})]})}function q(){return e.jsx(w,{tone:"neutral",title:"This approval request is no longer valid",titleTestId:"text-wallet-approve-invalid",actions:e.jsx(g,{asChild:!0,variant:"ghost","data-testid":"link-wallet-approve-support",children:e.jsxs(A,{href:"/about#contact",children:[e.jsx(U,{className:"mr-2 h-4 w-4"})," Contact support"]})}),children:e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-6 text-muted-foreground",children:"Approval requests expire quickly and can be replaced by a newer one. If you are still at the counter, ask for a fresh request; otherwise check your email for the most recent one."})})}function y({tone:c,title:o,body:s}){return e.jsxs(w,{tone:c==="done"?"success":"neutral",icon:c==="done"?void 0:J,title:o,titleTestId:"text-wallet-approve-closed",children:[e.jsx("p",{className:"mt-3 max-w-sm text-sm leading-6 text-muted-foreground",children:s}),e.jsx("p",{className:"mt-4 text-sm",children:e.jsx(A,{href:"/account",className:"font-semibold text-primary hover:text-primary/80","data-testid":"link-wallet-approve-account",children:"View it in your account"})})]})}function ne(){const[,c]=E("/wallet-approve/:token"),o=c?.token??"",[s,L]=i.useState(null),[v,S]=i.useState(!1),[u,x]=i.useState(null),[N,m]=i.useState(null),[V,C]=i.useState(!1),[h,P]=i.useState(null),j={cache:"no-store",omitCartToken:!0},l=I({queryKey:G(o),queryFn:({signal:a})=>Y(o,{...j,signal:a}),enabled:!!o,staleTime:0,gcTime:0,retry:(a,n)=>n instanceof p&&n.status>=400&&n.status<500?!1:a<1}),t=l.data??null,R=V||l.error instanceof p&&l.error.status===404,b=t?.expiresAt??null;i.useEffect(()=>{if(!b||s||v)return;const a=Date.parse(b);if(!Number.isFinite(a))return;const n=()=>P(Math.max(0,Math.floor((a-Date.now())/1e3)));n();const B=setInterval(n,1e3);return()=>clearInterval(B)},[b,s,v]);const T=i.useMemo(()=>t?Math.max(0,t.walletBalanceCents-t.amountCents):0,[t]);async function W(){if(!u){x("approve"),m(null);try{const a=await F(o,{channel:X()},j);L(a)}catch(a){if(a instanceof p&&a.status===404)C(!0);else if(a instanceof p){const n=a.data;m(typeof n?.error=="string"&&n.error!=="not_found"?n.error:"We could not apply your VidaCredit. Please try again.")}else m("We could not apply your VidaCredit. Please try again.")}finally{x(null)}}}async function D(){if(!u){x("decline"),m(null);try{await M(o,j),S(!0)}catch(a){a instanceof p&&a.status===404?C(!0):m("We could not record that. Please try again.")}finally{x(null)}}}let r;if(s)r=e.jsxs(w,{tone:"success",title:s.paid?"Paid with VidaCredit":"VidaCredit applied",titleTestId:"text-wallet-approve-applied",amountCents:s.appliedCents,children:[e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[d(s.appliedCents)," applied",s.orderNumber?` to order ${s.orderNumber}`:""]}),!s.paid&&s.remainingDueCents>0&&e.jsxs("p",{className:"mt-3 w-full rounded-xl bg-muted/60 px-4 py-3 text-sm","data-testid":"text-wallet-approve-remaining",children:[d(s.remainingDueCents)," is still due. The counter can take the rest now, or send you a payment link."]}),e.jsxs("p",{className:"mt-3 text-sm text-muted-foreground",children:["Remaining VidaCredit balance ",d(s.walletBalanceCents),"."]}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"You can close this page."})]});else if(v)r=e.jsx(y,{tone:"stopped",title:"Request declined",body:"Nothing was taken from your VidaCredit. Let the counter know how you would like to pay instead."});else if(!o||R&&!s)r=e.jsx(q,{});else if(l.isLoading)r=e.jsx(_,{});else if(!t&&l.error)r=e.jsxs(k,{children:[e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"We could not load this request right now. Please try again."}),e.jsx(g,{type:"button",variant:"ghost",className:"mt-4",disabled:l.isFetching,onClick:()=>{l.refetch()},children:l.isFetching?"Retrying...":"Retry"})]});else if(!t)r=e.jsx(q,{});else if(t.status==="approved")r=e.jsx(y,{tone:"done",title:"Already approved",body:"This request was already approved and your VidaCredit has been applied. You can close this page."});else if(t.status==="declined")r=e.jsx(y,{tone:"stopped",title:"Request declined",body:"Nothing was taken from your VidaCredit. Let the counter know how you would like to pay instead."});else if(t.status==="expired"||t.status==="cancelled")r=e.jsx(y,{tone:"stopped",title:t.status==="expired"?"This request expired":"This request was replaced",body:"Nothing was taken from your VidaCredit. Ask the counter for a fresh request, or check your email for a newer one."});else{const a=h===0;r=e.jsxs("div",{className:"space-y-4",children:[e.jsx(H,{targetType:"order",number:t.orderNumber??"Your order",lines:t.lineSummary,amountDueCents:t.amountDueCents}),e.jsxs(k,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-4 w-4 text-primary","aria-hidden":"true"}),e.jsx("h2",{className:"font-semibold",children:"Approve VidaPay charge"})]}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"The counter is asking to use your VidaCredit for this order. Nothing moves until you approve."}),e.jsxs("div",{className:"relative mt-4 overflow-hidden rounded-card border border-secondary bg-secondary/40 px-4 py-6 text-center",children:[e.jsx("span",{className:"block text-overline uppercase text-muted-foreground",children:"Amount to take from VidaCredit"}),e.jsx("span",{className:"money-numeral mt-1 block font-display text-t1 font-bold","data-testid":"text-wallet-approve-amount",children:d(t.amountCents)})]}),e.jsxs("dl",{className:"mt-4 space-y-1.5 border-t border-card-border pt-4 text-sm",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Your balance"}),e.jsx("dd",{className:"money-numeral font-medium",children:d(t.walletBalanceCents)})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Balance after approving"}),e.jsx("dd",{className:"money-numeral font-medium",children:d(T)})]}),t.amountDueCents>t.amountCents&&e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Still due after this"}),e.jsx("dd",{className:"money-numeral font-medium",children:d(t.amountDueCents-t.amountCents)})]})]}),h!=null&&!a&&e.jsx("p",{className:"mt-4 flex justify-center",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-[var(--vp-warn-bg)] px-3 py-1 text-xs font-medium text-[var(--vp-warn-ink)]",children:[e.jsx(Q,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Expires in ",Math.floor(h/60),":",String(h%60).padStart(2,"0")]})}),e.jsx(g,{type:"button",size:"lg",block:!0,className:"mt-4 min-h-14 text-base font-bold",disabled:u!==null||a,onClick:()=>{W()},"data-testid":"button-wallet-approve",children:u==="approve"?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4 animate-spin","aria-hidden":"true"})," Approving..."]}):a?"Request expired":`Approve ${d(t.amountCents)}`}),e.jsx(g,{type:"button",variant:"ghost",block:!0,className:"mt-2 min-h-11 text-muted-foreground",disabled:u!==null,onClick:()=>{D()},"data-testid":"button-wallet-decline",children:u==="decline"?"Declining...":"Decline"}),a&&e.jsx("p",{className:"mt-3 text-center text-sm text-muted-foreground",children:"This request timed out. Ask the counter to send a fresh one."}),N&&e.jsx("div",{role:"alert",className:"mt-4 rounded-card border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive","data-testid":"text-wallet-approve-error",children:N})]})]})}return e.jsx("div",{className:"ph-no-capture min-h-screen bg-background text-foreground",children:e.jsxs("main",{className:"mx-auto w-full max-w-2xl px-4 py-8 sm:px-6 lg:py-12",children:[e.jsx("div",{className:"mb-4 flex items-center justify-between gap-3",children:e.jsxs("p",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[e.jsx(z,{className:"h-4 w-4","aria-hidden":"true"})," Secure approval"]})}),r]})})}export{ne 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.