PageSourceSearch

https://rewards.kfh/assets/ProfileVouchers-Bgvp7efI.js

js rewards.kfh collected 2026-10-07 20:57:23 UTC 10,420 bytes, 96 lines download raw bytes

1import{c as M,m as H,u as F,a as U,b as Q,r as c,v as q,x as O,n as W,j as s,S as G,C as x,aQ as k,w as K,av as J,au as X}from"./index-_B-k6bTY.js";import{T as Y}from"./TopNavBar-Cjx2M6ST.js";import{S as Z}from"./SuccessPopup-CMajmxvH.js";import"./deviceDetection-6N0CWJQw.js";async function ee(t="deals",o="en"){const a=`/api/UI/LoadVouchers?pageNumber=1&recordRange=100&lang=${encodeURIComponent(o)}&source=website&type=${encodeURIComponent(t)}`;return U(a)}function se(t="deals",o="en",a=!0){return F({queryKey:["vouchers",t,o],queryFn:()=>ee(t,o),enabled:a})}function te(t="website"){const o=M(a=>a.locale.language);return H({mutationFn:async a=>{const r=await U(`/api/UI/MarkVoucherAsUsed?lang=${encodeURIComponent(o)}&source=${encodeURIComponent(t)}`,{method:"POST",body:{VoucherId:a}});if(!r||r.Status!=="success")throw new Error(r?.Message||"Failed to mark voucher as used");return r}})}const re=t=>{const o=document.querySelector(t);if(!o)return;const a=document.body.innerHTML,r=o.innerHTML,p=`
2    <style>
3      body {
4        margin: 0;
5        font-family: sans-serif;
6      }
7
8      /* Hide elements that shouldn't appear in print */
9      .copy-button,
10      .toggle-btn,
11      .success-popup__bottom-button,
12      .success-popup__secondary-button,
13      .success-popup__wallet-section,
14      .close-button,
15      .copy-toast,
16      .popup__close {
17        display: none !important;
18      }
19
20      /* Remove spacing above title/header */
21      .success-popup__subtitle,
22      .success-popup__content > *:first-child {
23        margin-top: 0 !important;
24        padding-top: 0 !important;
25      }
26
27      .success-popup__content {
28        display: block;
29        padding: 20px;
30        padding-top: 0 !important;
31      }
32
33      /* Remove spacing under QR/Barcode sections */
34      .code-display {
35        margin-bottom: 0 !important;
36        padding-bottom: 0 !important;
37      }
38
39      .code-toggle-buttons {
40        margin-top: 0 !important;
41        margin-bottom: 0 !important;
42        padding-top: 0 !important;
43        padding-bottom: 0 !important;
44      }
45
46      .success-popup__code-section {
47        margin-bottom: 0 !important;
48        padding-bottom: 0 !important;
49        gap: 0 !important;
50      }
51
52      /* Tighten spacing for code section elements */
53      .code-ready-text {
54        margin-bottom: 8px !important;
55      }
56
57      /* Reduce space between QR code and voucher code */
58      .voucher-code-frame {
59        page-break-inside: avoid;
60        margin-top: 0 !important;
61        margin-bottom: 10px !important;
62        padding-top: 0 !important;
63      }
64
65      img {
66        max-width: 100%;
67        height: auto;
68        display: block;
69      }
70
71      /* Increase font sizes for print */
72      .success-popup__subtitle {
73        font-size: 20px !important;
74      }
75
76      .success-popup__value-row {
77        font-size: 18px !important;
78      }
79
80      .success-popup__value-row .value-chip {
81        font-size: 18px !important;
82      }
83
84      .success-popup__value-row .points-redeemed {
85        font-size: 18px !important;
86      }
87
88      .expiry-date-row {
89        font-size: 18px !important;
90      }
91
92      .expiry-date-row .expiry-text {
93        font-size: 18px !important;
94      }
95    </style>
96  `;document.body.innerHTML=p+r,window.print(),document.body.innerHTML=a,window.location.reload()};function ne(){const{t,i18n:o}=Q(),a=o.language||"en",[r,p]=c.useState("deals"),[P,z]=c.useState(null),[j]=q(),d=O(),[E,_]=c.useState(!1),[R,g]=c.useState(!1),[N,v]=c.useState(null),b=te(),y=M(e=>e.auth.isGuest),{showSuccess:D,showError:f,showWarning:L,showInfo:$}=W(),w=c.useRef(!1);c.useEffect(()=>{y&&!w.current&&(w.current=!0,f({title:t("guestAccessDeniedTitle"),text:t("guestLoginRequired"),duration:5e3,position:"top-center"}),d("/home",{replace:!0}))},[y,d,f,t]),c.useEffect(()=>{j.get("tab")==="payments"?p("payments"):(p("deals"),d("/profile/vouchers?tab=deals",{replace:!0}))},[j,d]);const S=(e,u,l="",h=4e3)=>{const m={success:D,error:f,warning:L,info:$}[e];m({title:l,text:u,duration:h})},V=e=>{p(e),d(`/profile/vouchers?tab=${e}`,{replace:!0})},A=e=>{v(e),g(!0)},B=async()=>
96{if(N)try{const e=await b.mutateAsync(N);S("success",J(e).message,"Voucher marked as used successfully"),g(!1),_(!1),v(null),i.refetch()}catch(e){S("error",X(e).message,"Failed to mark voucher as used")}},C=e=>{const u=e.VoucherType==="payment",l={type:u?"payment":"voucher",headerTitle:e.VoucherMerchantName,headerImage:e.Image?.Url||e.DealVoucherImageUrl,description:e.Title,value:e.Value,pointsRedeemed:e.PointsRedeemed,expiryDate:e.ExpiryDate,voucherCode:e.Code,voucherId:e.VoucherId,showTitle:!u,buttonText:t("Print"),onButtonClick:()=>{re(".success-popup.popup__content")},...e.IsPredefined&&{secondaryButtonText:t("markasused"),onSecondaryButtonClick:()=>{A(e.VoucherId)}}};z(l),_(!0)},i=se(r==="deals"?"deals":"payment",a,!y),T=i.data?.Data||[];return s.jsxs("div",{className:"profile-vouchers",children:[s.jsx(Y,{title:t("myevouchers","My Vouchers")}),s.jsxs("div",{className:"profile-vouchers__tabs",children:[s.jsx("button",{className:`profile-vouchers__tab ${r==="deals"?"active":""}`,onClick:()=>V("deals"),children:t("deals","Deals")}),s.jsx("button",{className:`profile-vouchers__tab ${r==="payments"?"active":""}`,onClick:()=>V("payments"),children:t("payments","Payments")})]}),s.jsx("div",{className:"profile-vouchers__info",children:s.jsx("p",{children:t(r==="deals"?"dealsevoucherdesc":"paymentevoucherinfo")})}),s.jsxs("div",{className:"profile-vouchers__content",children:[i.isLoading&&s.jsx("div",{className:"profile-vouchers__loading",children:s.jsx(G,{size:"medium",text:t("common.loading","Loading...")})}),i.isError&&s.jsxs("div",{className:"profile-vouchers__empty",children:[s.jsx("i",{className:"fi fi-rr-exclamation",style:{fontSize:"48px",color:"var(--color-error)"}}),s.jsx("p",{children:i.error?.message||t("common.error","Error")})]}),!i.isLoading&&!i.isError&&T.length===0&&s.jsxs("div",{className:"profile-vouchers__empty",children:[s.jsx("i",{className:"fi fi-rr-ticket",style:{fontSize:"48px",color:"var(--color-text-tertiary)"}}),s.jsx("p",{children:t("vouchers.noVouchers","No vouchers found")})]}),s.jsx("div",{className:"profile-vouchers__list",children:T.map(e=>{const u=e.VoucherType==="payment"||r==="payments",l=(e.Status||"").toLowerCase(),h=l==="used",m=l==="expired",n=h||m,I=h?"voucher-strip--used":m?"voucher-strip--expired":"voucher-strip--valid";return u?s.jsxs("div",{className:`voucher-strip voucher-strip--standalone ${I} ${n?"voucher-strip--disabled":""}`,onClick:()=>!n&&C(e),style:{cursor:n?"not-allowed":"pointer"},children:[s.jsxs("div",{className:"voucher-strip__left",children:[s.jsx("img",{src:e.Image?.Url||e.DealVoucherImageUrl,alt:e.VoucherMerchantName,className:"voucher-strip__merchant-img"}),e.Status&&e.Status.toLowerCase()!=="not used"&&s.jsx(x,{text:e.Status,color:e.Status==="used"?"var(--color-success)":"var(--color-error)",textColor:"var(--color-primary-contrast)",borderless:!0,className:"voucher-strip__status-chip stay-ltr",style:{fontSize:"9px",padding:"3px 6px"}})]}),s.jsx("div",{className:"voucher-strip__sep","aria-hidden":"true"}),s.jsxs("div",{className:"voucher-strip__center",children:[s.jsx("div",{className:"voucher-strip__merchant",children:e.VoucherMerchantName}),e.Value&&s.jsx(x,{text:e.Value,color:"var(--color-primary)",borderless:!0,textColor:"var(--color-primary-contrast)",className:"voucher-strip__type-chip stay-ltr",style:{fontSize:"10px",padding:"2px 8px",fontWeight:"600",width:"fit-content",alignSelf:"flex-start"}}),s.jsxs("div",{className:"voucher-strip__expiry",children:[t("vouchers.expires","Expiry Date"),": ",e.ExpiryDate]}),s.jsxs("div",{className:"voucher-strip__code-row",children:[s.jsx("span",{className:"voucher-strip__code-icon-inline",children:s.jsx("img",{src:k,alt:"",className:"voucher-strip__code-icon-svg",style:{width:"16px",height:"16px"}})}),s.jsx("span",{className:"voucher-strip__code--under",children:e.Code})]})]}),s.jsx("div",{className:"voucher-strip__cutout voucher-strip__cutout--left"}),s.jsx("div",{className:"voucher-strip__cutout voucher-strip__cutout--right"}),n&&s.jsx("div",{className:"voucher-strip__overlay"})]},e.VoucherId):s.jsx("div",{className:`voucher-card ${n?"voucher-card--disabled":""}`,onClick:()=>!n&&C(e),style:{cursor:n?"not-allowed":"pointer"},children:s.jsx("div",{className:"voucher-card__image",style:{backgroundImage:`url(${e.DealVoucherImageUrl||e.Image?.Url})`},role:"img","aria-label":e.Title,children:s.jsxs("div",{className:`voucher-strip ${I}`,children:[s.jsxs("div",{className:"voucher-strip__left",children:[s.jsx("img",{src:e.Image?.Url||e.DealVoucherImageUrl,alt:e.VoucherMerchantName,className:"voucher-strip__merchant-img"}),e.Status&&e.Status.toLowerCase()!=="not used"&&s.jsx(x,{text:e.Status,color:e.Status==="used"?"var(--color-success)":"var(--color-error)",textColor:"var(--color-primary-contrast)",borderless:!0,className:"voucher-strip__status-chip",style:{fontSize:"9px",padding:"3px 6px"}})]}),s.jsx("div",{className:"voucher-strip__sep","aria-hidden":"true"}),s.jsxs("div",{className:"voucher-strip__center",children:[s.jsxs("div",{className:"voucher-strip__header",children:[s.jsx("div",{className:"voucher-strip__merchant",children:e.VoucherMerchantName}),e.Value&&s.jsx(x,{text:e.Value,color:"var(--color-primary)",borderless:!0,textColor:"var(--color-primary-contrast)",className:"voucher-strip__type-chip",style:{fontSize:"10px",padding:"2px 8px",fontWeight:"600"}})]}),s.jsx("div",{className:"voucher-strip__title",title:e.Title,children:e.Title}),s.jsxs("div",{className:"voucher-strip__expiry",children:[t("vouchers.expires","Expiry Date"),": ",e.ExpiryDate]}),s.jsxs("div",{className:"voucher-strip__code-row",children:[s.jsx("span",{className:"voucher-strip__code-icon-inline",children:s.jsx("img",{src:k,alt:"",className:"voucher-strip__code-icon-svg",style:{width:"16px",height:"16px"}})}),s.jsx("span",{className:"voucher-strip__code--under",children:e.Code})]})]}),s.jsx("div",{className:"voucher-strip__cutout voucher-strip__cutout--left"}),s.jsx("div",{className:"voucher-strip__cutout voucher-strip__cutout--right"})]})})},e.VoucherId)})})]}),s.jsx(Z,{open:E,onClose:()=>_(!1),data:P,showCloseButton:!0}),s.jsx(K,{open:R,title:t("confirm"),message:t("areyousuretomark"),confirmText:t("yes"),cancelText:t
96("no"),onConfirm:B,onCancel:()=>{g(!1),v(null)},loading:b.isPending})]})}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.