PageSourceSearch

https://quiqrpay.com/assets/OrderNumbers-CHxMtrKd.js

js quiqrpay.com collected 2026-09-24 14:51:16 UTC 9,363 bytes, 1 lines download raw bytes

1import{a as E,r as n,j as e}from"./index-zb99FpKi.js";import{B as F}from"./BusinessNavigation-DXHQ7jiw.js";/* empty css                  */import"./logout-CmEwPxOI.js";const W=i=>{const o=Number.parseFloat(String(i));if(!Number.isFinite(o)||o<=0)return null;const g=o>=0?o+Number.EPSILON:o-Number.EPSILON;return Math.round(g*100)},h=i=>Number(i||0)/100;function P(){const i=E(),o=sessionStorage.getItem("business_auth_token"),[g,S]=n.useState(!0),[y,p]=n.useState(!1),[N,l]=n.useState(""),[w,z]=n.useState(""),[x,C]=n.useState([]),[f,I]=n.useState([]),[b,k]=n.useState(null),[d,O]=n.useState(!1),[u,B]=n.useState(""),[c,R]=n.useState({});n.useEffect(()=>{o||i("/business-login")},[o,i]);const m=n.useMemo(()=>Object.entries(c||{}).map(([s,r])=>({menu_item_id:s,quantity:Math.max(0,Math.round(Number(r||0)))})).filter(s=>s.menu_item_id&&s.quantity>0),[c]),A=n.useMemo(()=>{if(!d){const r=W(u);return r?h(r):0}const t=new Map(x.map(r=>[String((r==null?void 0:r.id)||""),Number((r==null?void 0:r.price)||0)])),s=m.reduce((r,a)=>{const j=t.get(String(a.menu_item_id||""));return!Number.isFinite(j)||j<=0?r:r+Math.round((j+Number.EPSILON)*100)*a.quantity},0);return h(s)},[d,u,m,x]),v=async()=>{if(o)try{const t=await fetch("/api/payment/order-codes/recent",{headers:{Authorization:`Bearer ${o}`}});if(!t.ok)return;const s=await t.json();I(Array.isArray(s==null?void 0:s.orders)?s.orders:[])}catch{}};n.useEffect(()=>{(async()=>{if(o){S(!0),l("");try{const s=await fetch("/api/business/menu-items",{headers:{Authorization:`Bearer ${o}`}});if(s.ok){const r=await s.json();C(Array.isArray(r==null?void 0:r.items)?r.items:[])}await v()}catch(s){l(s.message||"Failed to load order portal")}finally{S(!1)}}})()},[o]);const _=async()=>{if(o){l(""),z(""),p(!0);try{const t={};if(d){if(!m.length){l("Select at least one menu item (quantity > 0)."),p(!1);return}t.items=m}else{const a=W(u);if(a===null){l("Enter an amount greater than 0."),p(!1);return}t.amount_cents=a}const s=await fetch("/api/payment/order-codes",{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await s.json().catch(()=>({}));if(!s.ok)throw new Error((r==null?void 0:r.error)||"Failed to generate order number");k((r==null?void 0:r.order)||null),z("Order number generated."),await v()}catch(t){l(t.message||"Failed to generate order number")}finally{p(!1)}}};return e.jsxs("div",{children:[e.jsx(F,{}),e.jsx("div",{className:"dashboard-page",children:e.jsx("div",{className:"dashboard-container",style:{maxWidth:"980px"},children:e.jsxs("div",{className:"dashboard-card",style:{textAlign:"left",padding:"40px"},children:[e.jsx("h1",{style:{marginBottom:"8px"},children:"Order Numbers"}),e.jsx("p",{style:{fontSize:"1.05em",color:"var(--color-slate-500)",marginBottom:"22px"},children:"Generate order numbers so customers can enter them from a Store QR scan."}),N&&e.jsx("div",{className:"message error",style:{padding:"12px",marginBottom:"16px"},children:N}),w&&e.jsx("div",{className:"message success",style:{padding:"12px",marginBottom:"16px"},children:w}),g?e.jsx("div",{className:"loading",children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"16px",border:"1px solid var(--color-slate-200)",borderRadius:"12px",background:"var(--color-surface-1)",marginBottom:"18px"},children:[e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:d,onChange:t=>O(t.target.checked)}),e.jsx("span",{style:{fontWeight:"600",color:"var(--color-slate-900)"},children:"Itemize with menu items"})]}),e.jsxs("div",{style:{fontSize:"0.9em",color:"var(--color-slate-500)"},children:["Total: ",e.jsxs("strong",{style:{color:"var(--color-slate-900)"},children:["$",A.toFixed(2)]})]})]}),d?e.jsxs("div",{style:{marginTop:"14px"},children:[e.jsx("div",{style:{fontWeight:"600",marginBottom:"8px"},children:"Menu Items"}),x.length===0?e.jsx("div",{style:{color:"var(--color-slate-500)"},children:"No menu items found."}):e.jsx("div",{style:{display:"grid",gap:"10px"},children:x.map(t=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",alignItems:"center",padding:"10px 12px",border:"1px solid var(--color-slate-200)",borderRadius:"10px",background:"var(--color-surface-2)"},children:[e.jsxs("div",{style:{minWidth:"0"},children:[e.jsx("div",{style:{fontWeight:"600",color:"var(--color-slate-900)"},children:t.name||"Item"}),e.jsxs("div",{style:{fontSize:"0.9em",color:"var(--color-slate-500)"},children:["$",Number(t.price||0).toFixed(2)]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"0.9em",color:"var(--color-slate-500)"},children:"Qty"}),e.jsx("input",{type:"number",min:"0",step:"1",value:(c==null?void 0:c[t.id])||0,onChange:s=>{const r=s.target.value;R(a=>({...a||{},[t.id]:r}))}
1,style:{width:"90px",padding:"10px 12px",border:"2px solid var(--color-slate-200)",borderRadius:"8px",boxSizing:"border-box"}})]})]},t.id))})]}):e.jsxs("div",{style:{marginTop:"14px"},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontWeight:"600"},children:"Amount"}),e.jsx("input",{type:"text",value:u,onChange:t=>B(t.target.value),placeholder:"0.00",style:{width:"100%",padding:"12px",border:"2px solid var(--color-slate-200)",borderRadius:"8px",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{marginTop:"16px",display:"flex",gap:"10px",flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"btn-primary-obsidian",onClick:_,disabled:y,children:y?"Generating...":"Generate Order Number"}),e.jsx("button",{type:"button",className:"btn-secondary",onClick:v,disabled:y,children:"Refresh Recent"})]})]}),b&&e.jsx("div",{style:{padding:"18px",borderRadius:"14px",border:"1px solid var(--color-slate-200)",background:"linear-gradient(135deg, rgba(15,23,42,0.04) 0%, rgba(15,23,42,0.01) 100%)",marginBottom:"18px"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"14px",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:"800",color:"var(--color-slate-900)",marginBottom:"6px"},children:"Current Code"}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:"56px",lineHeight:"1",fontWeight:"900",letterSpacing:"0.08em",color:"var(--color-slate-900)"},children:String(b.code||"")}),e.jsxs("div",{style:{marginTop:"10px",color:"var(--color-slate-500)"},children:["Amount: ",e.jsxs("strong",{style:{color:"var(--color-slate-900)"},children:["$",h(b.amount_cents).toFixed(2)]})]})]}),e.jsxs("div",{style:{flex:"1 1 260px",minWidth:"260px"},children:[e.jsx("div",{style:{fontWeight:"700",marginBottom:"8px",color:"var(--color-slate-900)"},children:"Customer Steps"}),e.jsxs("div",{style:{color:"var(--color-slate-600)",fontSize:"0.95em",lineHeight:"1.5"},children:["1. Customer scans your Store QR.",e.jsx("br",{}),"2. Tap ",e.jsx("strong",{children:"Enter order number"}),".",e.jsx("br",{}),"3. Enter the order number shown above."]})]})]})}),e.jsxs("div",{style:{padding:"16px",border:"1px solid var(--color-slate-200)",borderRadius:"12px",background:"var(--color-surface-1)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",flexWrap:"wrap",marginBottom:"10px"},children:[e.jsxs("div",{style:{fontWeight:"800",color:"var(--color-slate-900)"},children:["Last ",f.length," Orders"]}),e.jsx("div",{style:{fontSize:"0.9em",color:"var(--color-slate-500)"},children:"Showing up to 16 most recent"})]}),f.length===0?e.jsx("div",{style:{color:"var(--color-slate-500)"},children:"No recent order numbers yet."}):e.jsx("div",{style:{overflowX:"auto",border:"1px solid var(--color-slate-200)",borderRadius:"10px"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"560px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"var(--color-surface-2)",textAlign:"left"},children:[e.jsx("th",{style:{padding:"10px 12px",fontSize:"0.85em",color:"var(--color-slate-600)"},children:"Code"}),e.jsx("th",{style:{padding:"10px 12px",fontSize:"0.85em",color:"var(--color-slate-600)"},children:"Amount"}),e.jsx("th",{style:{padding:"10px 12px",fontSize:"0.85em",color:"var(--color-slate-600)"},children:"Status"}),e.jsx("th",{style:{padding:"10px 12px",fontSize:"0.85em",color:"var(--color-slate-600)"},children:"Created"})]})}),e.jsx("tbody",{children:f.map(t=>e.jsxs("tr",{style:{borderTop:"1px solid var(--color-slate-200)"},children:[e.jsx("td",{style:{padding:"10px 12px",fontFamily:"monospace",fontWeight:"800",letterSpacing:"0.06em"},children:String(t.code||"")}),e.jsxs("td",{style:{padding:"10px 12px",fontWeight:"700"},children:["$",h(t.amount_cents).toFixed(2)]}),e.jsx("td",{style:{padding:"10px 12px"},children:e.jsx("span",{style:{padding:"4px 10px",borderRadius:"999px",fontSize:"0.85em",fontWeight:"700",background:t.status==="paid"?"rgba(16, 185, 129, 0.14)":"rgba(59, 130, 246, 0.14)",color:t.status==="paid"?"#065f46":"#1e40af"},children:t.status==="paid"?"PAID":"OPEN"})}),e.jsx("td",{style:{padding:"10px 12px",color:"var(--color-slate-500)",fontSize:"0.9em"}
1,children:t.created_at?new Date(t.created_at).toLocaleString():"-"})]},`${t.code}_${t.created_at||""}`))})]})})]})]})]})})})]})}export{P 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.