PageSourceSearch

https://tire-track-loyalty-3a0d7f0a.base44.app/assets/TireAccessRequests-HMSGpdpN.js

js tire-track-loyalty-3a0d7f0a.base44.app collected 2026-10-03 03:11:47 UTC 8,504 bytes, 1 lines download raw bytes

1import{r,j as e,b as p,t as n}from"./index-DdU35jPJ.js";import{B as c}from"./button-BfxMpK8P.js";import{B as R}from"./badge-O5l_SoDq.js";import{D,a as $,b as M,c as B}from"./dialog-gVN6KGjC.js";import{s as L,r as b}from"./tireAccessPendingStore-BAH_VYyl.js";import{L as g}from"./lock-Brnc1X-D.js";import{C as z}from"./clock-D8ofwCOI.js";import{C as E}from"./circle-check-big-B9divPaO.js";import{C as O}from"./circle-x-QpU72J1I.js";import{B as P}from"./building-2-DLUiP0-v.js";import{U}from"./user-TFtzTQfw.js";import{P as X}from"./phone-BiN9hL5_.js";import{M as F}from"./mail-DvcgW5d2.js";import{C as G}from"./check-BECSssz0.js";import{X as H}from"./x-DAruoHhn.js";import"./index-gN4drEn4.js";import"./index-Dp3B9jqt.js";import"./clsx-B-dksMZM.js";import"./utils-DCmAa5as.js";import"./bundle-mjs-BTmSotT-.js";import"./index-BhZ8ej-y.js";import"./index-12QbP6l0.js";import"./index-BsvT06Lq.js";import"./index-9bdZCgcr.js";import"./index-BvvUEucZ.js";import"./index-Bwgqm7vL.js";import"./createLucideIcon-DMxicyrC.js";const I={pending:"bg-amber-100 text-amber-700 border-amber-200",approved:"bg-green-100 text-green-700 border-green-200",denied:"bg-red-100 text-red-700 border-red-200"};function je(){const[l,j]=r.useState([]),[N,v]=r.useState(!1),[w,h]=r.useState(!0),[o,y]=r.useState("pending"),[i,d]=r.useState(null),[x,m]=r.useState(!1);r.useEffect(()=>{const s=L(({requests:t,ready:a})=>{j(t),v(!!a),h(!1)});return()=>{try{s()}catch{}}},[]);const _=()=>{h(!0),b()},S=!N&&l.length===0,C=s=>d(s),A=async()=>{m(!0);try{const s=await p.functions.invoke("grantTireAccess",{request_id:i.id}),t=(s==null?void 0:s.data)||s,a=t!=null&&t.sms_sent?" SMS sent.":t!=null&&t.sms_reason?` SMS: ${t.sms_reason}.`:"";n.success(`Access granted — customer can now view pricing.${a}`),d(null)}catch{n.error("Could not approve request")}finally{m(!1)}},k=async s=>{m(!0);try{const t=await p.functions.invoke("grantTireAccess",{request_id:s.id}),a=(t==null?void 0:t.data)||t;a!=null&&a.sms_sent?n.success("Approval SMS sent"):n.error(`SMS not sent${a!=null&&a.sms_reason?`: ${a.sms_reason}`:""}`)}catch{n.error("Could not retry approval SMS")}finally{m(!1)}},T=async s=>{confirm(`Deny access for ${s.customer_company} on ${s.tire_brand} ${s.tire_size}?`)&&(await p.entities.TireAccessRequest.update(s.id,{status:"denied",reviewed_date:new Date().toISOString()}),n.success("Request denied"),b())},u=l.filter(s=>o==="all"||s.status===o),f=l.filter(s=>s.status==="pending").length;return e.jsxs("div",{className:"min-h-screen bg-[#f6f7fb] px-3 pb-24 pt-4 sm:p-6 lg:p-10",children:[e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-[#323338]",children:"Tire Access Requests"}),f>0&&e.jsx("span",{className:"bg-[#e2445c] text-white text-sm font-bold px-2.5 py-0.5 rounded-full",children:f})]}),e.jsx("p",{className:"text-[#676879]",children:"Review and approve customer requests to see tire pricing"})]}),e.jsx("div",{className:"flex items-center gap-1 bg-white rounded-xl p-1 border border-[#e6e9ef] mb-6 w-fit",children:["pending","approved","denied","all"].map(s=>e.jsxs("button",{onClick:()=>y(s),className:`px-4 py-2 rounded-lg text-sm font-medium capitalize transition-all ${o===s?"bg-[#0073ea] text-white shadow-sm":"text-[#676879] hover:text-[#323338]"}`,children:[s," ",s!=="all"&&`(${l.filter(t=>t.status===s).length})`]},s))}),w?e.jsx("div",{className:"flex justify-center py-16",children:e.jsx("div",{className:"w-8 h-8 border-2 border-[#0073ea] border-t-transparent rounded-full animate-spin"})}):S?e.jsxs("div",{className:"text-center py-16 bg-white rounded-2xl border border-[#e6e9ef]",children:[e.jsx(g,{className:"w-12 h-12 text-[#c5c7d0] mx-auto mb-3"}),e.jsx("p",{className:"text-[#323338] font-medium mb-4",children:"Traffic limit reached"}),e.jsx(c,{onClick:()=>_(),className:"bg-[#0073ea] hover:bg-[#0060b9] text-white",children:"Try Again"})]}):u.length===0?e.jsxs("div",{className:"text-center py-16 bg-white rounded-2xl border border-[#e6e9ef]",children:[e.jsx(g,{className:"w-12 h-12 text-[#c5c7d0] mx-auto mb-3"}),e.jsxs("p",{className:"text-[#323338] font-medium",children:["No ",o==="all"?"":o," requests"]})]}):e.jsx("div",{className:"space-y-4",children:u.map(s=>e.jsx("div",{className:"bg-white rounded-2xl border border-[#e6e9ef] p-5 shadow-sm",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(R,{className:`border text-xs ${I[s.status]}`,children:[s.status==="pending"&&e.jsx(z,{className:"w-3 h-3 mr-1"}),s.status==="approved"&&e.jsx(E,{className:"w-3 h-3 mr-1"}),s.status==="denied"&&e.jsx(O,{className:"w-3 h-3 mr-1"}),s.status]}),e.jsx("span",{className:"text-xs text-[#9699a6]",children:new Date(s.created_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#323338]",children:[e.jsx(P,{className:"w-4 h-4 text-[#676879] shrink-0"}),e.jsx("span",{className:"font-medium",children:s.customer_company||"—"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#676879]",children:[e.jsx(U,{className:"w-4 h-4 shrink-0"}),s.customer_name||"—"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#676879]",children:[e.jsx(X,{className:"w-4 h-4 shrink-0"}),e.jsx("a",{href:`tel:${s.customer_phone}`,className:"hover:text-[#0073ea] hover:underline",children:s.customer_phone||"—"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[#676879]",children:[e.jsx(F,{className:"w-4 h-4 shrink-0"}),s.customer_email||"—"]})]})]}),e.jsxs("div",{className:"bg-[#f6f7fb] rounded-xl px-4 py-3 border border-[#e6e9ef] min-w-[160px]",children:[e.jsx("p",{className:"text-xs text-[#9699a6] mb-1",children:"Requested Tire"}),e.jsx("p",{className:"font-bold text-[#323338]",children:s.tire_brand}),s.tire_model&&e.jsx("p",{className:"text-sm text-[#676879]",children:s.tire_model}),e.jsx("p",{className:"text-sm text-[#676879]",children:s.tire_size}),s.tire_position&&e.jsx("p",{className:"text-xs text-[#9699a6]",children:s.tire_position}),s.status==="approved"&&e.jsx("p",{className:"text-sm font-bold text-green-600 mt-1",children:"Access granted"})]}),s.status==="pending"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(c,{onClick:()=>C(s),className:"bg-[#00c875] hover:bg-[#00b461] text-white gap-1",children:[e.jsx(G,{className:"w-4 h-4"})," Approve"]}),e.jsxs(c,{variant:"outline",onClick:()=>T(s),className:"border-[#e2445c] text-[#e2445c] hover:bg-[#e2445c]/10 gap-1",children:[e.jsx(H,{className:"w-4 h-4"})," Deny"]})]}),s.status==="approved"&&e.jsx(c,{variant:"outline",onClick:()=>k(s),disabled:x,className:"border-[#2563eb] text-[#2563eb] hover:bg-blue-50",children:"Retry SMS"})]})},s.id))})]}),e.jsx(D,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs($,{className:"inset-x-2 bottom-2 top-auto w-auto max-w-none translate-x-0 translate-y-0 rounded-2xl bg-white border-[#e6e9ef] max-h-[90dvh] overflow-y-auto sm:left-1/2 sm:top-1/2 sm:bottom-auto sm:w-full sm:max-w-sm sm:-translate-x-1/2 sm:-translate-y-1/2",children:[e.jsx(M,{children:e.jsx(B,{className:"text-[#323338]",children:"Approve Access"})}),i&&e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"bg-[#f6f7fb] rounded-xl p-3 border border-[#e6e9ef] text-sm",children:[e.jsxs("p",{className:"text-[#676879]",children:["Customer: ",e.jsx("span",{className:"font-medium text-[#323338]",children:i.customer_company})]}),e.jsxs("p",{className:"text-[#676879]",children:["Tire: ",e.jsxs("span",{className:"font-medium text-[#323338]",children:[i.tire_brand," ",i.tire_size]})]})]}),e.jsx("p",{className:"text-sm text-[#676879]",children:"The customer will see the standard Tire Pricing for this tire and be able to add it to their cart. No separate customer price is created."}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(c,{variant:"ghost",onClick:()=>d(null),className:"flex-1",children:"Cancel"}),e.jsx(c,{onClick:A,disabled:x,className:"flex-1 bg-[#00c875] hover:bg-[#00b461] text-white",children:x?"Saving...":"Grant Access"})]})]})]})})]})}export{je 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.