PageSourceSearch

https://getmelon.com.au/assets/Flex-CydJG0F6.js

js getmelon.com.au collected 2026-09-30 06:38:05 UTC 6,826 bytes, 1 lines download raw bytes

1import{u as q,r as i,j as e,L as B,m as $,d,e as F,f as L,o as k}from"./index-DjvjYx8D.js";import{P as D}from"./PublicNavBar-C-wZl_UG.js";import{F as P}from"./Footer-D9cynoVw.js";import{C as y}from"./card-BoeYN9zz.js";import{B as u}from"./badge-Cl_SCNNJ.js";import{B as x}from"./button-Cz5sYbhP.js";import{D as I,a as M,b as E,c as T,d as A}from"./dialog-B9zYFgAh.js";import"./dropdown-menu-MtG1yKvd.js";import"./index-D8K3azz-.js";import"./Combination-Cmn8Mk01.js";import"./index-DAoShclu.js";import"./chevron-right-LW5lYHnM.js";import"./check-BUcFAsHw.js";import"./melon-logo-DaaW67WJ.js";import"./chevron-down-BXueFYvF.js";import"./arrow-right-BQhxQtC5.js";import"./map-pin-Ct9JBX2s.js";import"./index-Dxopu1_s.js";const ne=()=>{const l=q(),[w,f]=i.useState(!0),[_,N]=i.useState([]),[t,m]=i.useState(null),[p,h]=i.useState(0),[b,g]=i.useState(!1),v=async()=>{if(!t)return;g(!0);const{data:s}=await d.auth.getSession();if(!s.session){l("/get-started?tab=login&next=/flex");return}const{data:a,error:r}=await d.functions.invoke("request-flex-rental",{body:{vehicle_id:t.id,tier_index:p,referral_code:F()??void 0,referral_visitor_id:L()??void 0}});if(g(!1),r||a!=null&&a.error){k({title:"Request failed",description:(r==null?void 0:r.message)??(a==null?void 0:a.error),variant:"destructive"});return}k({title:"Request submitted",description:"We'll be in touch shortly to arrange pickup."}),m(null),l("/dashboard")};return i.useEffect(()=>{document.title="melon flex — try before you buy | rent any bike, no commitment",(async()=>{const{data:a,error:r}=await d.from("vehicles").select("id, snapshot_name, snapshot_manufacturer, snapshot_image_url, current_km, year_of_manufacture, bike_model_id, status").eq("flex_listed",!0).in("status",["available","returned"]);if(r){console.error(r),f(!1);return}const c=Array.from(new Set((a??[]).map(n=>n.bike_model_id).filter(Boolean))),{data:C}=c.length?await d.from("bike_models").select("id, flex_enabled, flex_pricing_tiers, flex_security_bond, flex_excess_reduction_weekly").in("id",c):{data:[]},S=new Map((C??[]).map(n=>[n.id,n])),R=(a??[]).map(n=>{const o=n.bike_model_id?S.get(n.bike_model_id):null;if(!o||!o.flex_enabled)return null;const j=o.flex_pricing_tiers??[];return j.length?{id:n.id,snapshot_name:n.snapshot_name,snapshot_manufacturer:n.snapshot_manufacturer,snapshot_image_url:n.snapshot_image_url,current_km:n.current_km,year_of_manufacture:n.year_of_manufacture,bike_model_id:n.bike_model_id,flex_pricing_tiers:j,flex_security_bond:Number(o.flex_security_bond??0),flex_excess_reduction_weekly:o.flex_excess_reduction_weekly}:null}).filter(Boolean);N(R),f(!1)})()},[]),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(D,{onLoginClick:()=>l("/get-started?tab=login"),onApplyClick:()=>l("/get-started?tab=apply")}),e.jsxs("main",{className:"container mx-auto px-4 py-12 max-w-6xl",children:[e.jsxs("header",{className:"text-center mb-12",children:[e.jsx(u,{className:"mb-4",children:"try before you buy"}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4 lowercase",children:"melon flex — weekly scooter rental, no lock-in"}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Pure rental. No ownership pathway. Pick a bike, ride it for a week or a year — pay less the longer you ride."}),e.jsx("div",{className:"mt-6 flex gap-3 justify-center",children:e.jsx(B,{to:"/compare",children:e.jsx(x,{variant:"outline",children:"Compare plans"})})})]}),w?e.jsx($,{}):_.length===0?e.jsx(y,{className:"p-12 text-center text-muted-foreground",children:"No Flex vehicles available right now. Check back soon."}):e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:_.map(s=>{const a=Math.min(...s.flex_pricing_tiers.map(r=>Number(r.weekly_rate)));return e.jsxs(y,{className:"p-5 flex flex-col",children:[s.snapshot_image_url&&e.jsx("img",{src:s.snapshot_image_url,alt:s.snapshot_name??"Bike",className:"w-full h-44 object-contain mb-4",loading:"lazy"}),e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(u,{variant:"secondary",children:"Flex"}),s.year_of_manufacture&&e.jsx(u,{variant:"outline",children:s.year_of_manufacture}),s.current_km!=null&&e.jsxs(u,{variant:"outline",children:[s.current_km.toLocaleStr
1ing()," km"]})]}),e.jsxs("h3",{className:"font-semibold text-lg",children:[s.snapshot_manufacturer," ",s.snapshot_name]}),e.jsxs("div",{className:"mt-3 mb-3",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"From"}),e.jsxs("div",{className:"text-3xl font-bold",children:["$",a,e.jsx("span",{className:"text-base font-normal text-muted-foreground",children:"/wk"})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mb-4 space-y-1",children:[s.flex_pricing_tiers.map((r,c)=>e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{children:[r.min_weeks,r.max_weeks?`–${r.max_weeks}`:"+"," weeks"]}),e.jsxs("span",{className:"",children:["$",Number(r.weekly_rate),"/wk"]})]},c)),e.jsxs("div",{className:"flex justify-between pt-2 border-t mt-2",children:[e.jsx("span",{children:"Refundable bond"}),e.jsxs("span",{className:"",children:["$",s.flex_security_bond]})]})]}),e.jsx(x,{className:"w-full mt-auto",onClick:()=>{m(s),h(0)},children:"Request this bike"})]},s.id)})})]}),e.jsx(I,{open:!!t,onOpenChange:s=>!s&&m(null),children:e.jsxs(M,{children:[e.jsx(E,{children:e.jsxs(T,{children:["Request ",t==null?void 0:t.snapshot_manufacturer," ",t==null?void 0:t.snapshot_name]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick how long you'd like to ride. The longer you commit, the lower the weekly rate."}),e.jsx("div",{className:"space-y-2",children:t==null?void 0:t.flex_pricing_tiers.map((s,a)=>e.jsxs("button",{onClick:()=>h(a),className:`w-full text-left border rounded-lg p-3 transition ${p===a?"border-primary bg-primary/5":"border-border hover:bg-muted/30"}`,children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"font-medium",children:[s.min_weeks,s.max_weeks?`–${s.max_weeks}`:"+"," weeks"]}),e.jsxs("span",{className:" font-semibold",children:["$",Number(s.weekly_rate),"/wk"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Minimum commitment ",s.min_weeks," week",s.min_weeks>1?"s":""]})]},a))}),e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-3",children:["Refundable security bond: ",e.jsxs("span",{className:"",children:["$",t==null?void 0:t.flex_security_bond]}),". Returned at end of rental, less any owed amounts."]})]}),e.jsxs(A,{children:[e.jsx(x,{variant:"ghost",onClick:()=>m(null),children:"Cancel"}),e.jsx(x,{onClick:v,disabled:b,children:b?"Submitting…":"Submit request"})]})]})}),e.jsx(P,{})]})};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.