PageSourceSearch

https://melon-ride-on.lovable.app/assets/DocumentSubmission-Chga8oa5.js

js melon-ride-on.lovable.app collected 2026-10-03 03:33:28 UTC 7,155 bytes, 1 lines download raw bytes

1import{b as L,r as d,j as e,d as f,u as E}from"./index-BtGFp6U-.js";import{C as w,b as C,d as k,c as D,a as S}from"./card-Bv3a_rxh.js";import{B as _}from"./button-CpP5hguP.js";import{I as N}from"./input-BvXG7xgz.js";import{L as v}from"./label-DJPxh7Vm.js";import{C as U}from"./checkbox-C-ITJtfP.js";import{A as M,b as q}from"./alert-B4FHhD0M.js";import{U as R}from"./upload-Dm1HL7sG.js";import{C as z}from"./circle-alert-HNvg42dN.js";import{F as y}from"./file-check-76ZdgpD6.js";import{u as G}from"./useSmartDashboard-6FJHLq3s.js";import{C as I}from"./circle-check-big-DIadFqyQ.js";import{A as T}from"./arrow-left--dLolqNV.js";import"./index-Cf0XRMqp.js";import"./check-Lktdb7n7.js";import"./navigation-CjdqbC_i.js";import"./useImpersonation-DnBWmLwT.js";const $=({applicationId:i,userId:l,onComplete:g})=>{const{toast:a}=L(),[n,h]=d.useState(!1),[m,j]=d.useState(!1),[o,x]=d.useState({driver_license_front:{type:"driver_license_front",file:null,uploaded:!1},driver_license_back:{type:"driver_license_back",file:null,uploaded:!1},proof_of_address:{type:"proof_of_address",file:null,uploaded:!1}}),P=["image/jpeg","image/png","image/webp","application/pdf"],A=10*1024*1024,b=(t,s)=>{if(s){if(!P.includes(s.type)){a({title:"Invalid file type",description:"Upload JPG, PNG, WebP, or PDF only",variant:"destructive"});return}if(s.size>A){a({title:"File too large",description:"Maximum file size is 10 MB",variant:"destructive"});return}}x(r=>({...r,[t]:{...r[t],file:s}}))},F=async(t,s)=>{const r=s.name.split(".").pop(),c=`${l}/${i}/${t}.${r}`,{error:p}=await f.storage.from("customer-documents").upload(c,s,{upsert:!0});if(p)throw p;const{error:u}=await f.from("customer_documents").insert({user_id:l,application_id:i,document_type:t,file_path:c,file_name:s.name,file_size:s.size});if(u)throw u},B=async()=>{if(!m){a({title:"Terms Required",description:"Please accept the terms and conditions to continue",variant:"destructive"});return}if(!Object.values(o).every(s=>s.file!==null)){a({title:"Documents Required",description:"Please upload all required documents",variant:"destructive"});return}h(!0);try{for(const[c,p]of Object.entries(o))p.file&&(await F(c,p.file),x(u=>({...u,[c]:{...u[c],uploaded:!0}})));const{data:s,error:r}=await f.functions.invoke("submit-documents",{body:{application_id:i}});if(r||s&&s.error)throw new Error((s==null?void 0:s.error)||(r==null?void 0:r.message)||"Submission failed");a({title:"Documents Submitted",description:"Your documents have been uploaded successfully. Proceed to payment."}),setTimeout(()=>{window.location.href="/payment"},1e3)}catch(s){console.error("Error uploading documents:",s),a({title:"Upload Failed",description:s.message||"Failed to upload documents",variant:"destructive"})}finally{h(!1)}};return e.jsxs(w,{className:"border-2 border-primary/20",children:[e.jsxs(C,{children:[e.jsxs(k,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5"}),"Document Upload Required"]}),e.jsx(D,{children:"Please upload the following documents to proceed with your application"})]}),e.jsxs(S,{className:"space-y-6",children:[e.jsxs(M,{children:[e.jsx(z,{className:"h-4 w-4"}),e.jsx(q,{children:"Accepted formats: PDF, JPG, PNG (Max 5MB per file)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"license-front",className:"flex items-center gap-2",children:[o.driver_license_front.uploaded&&e.jsx(y,{className:"w-4 h-4 text-primary"}),"Driver's License (Front)"]}),e.jsx(N,{id:"license-front",type:"file",accept:".pdf,.jpg,.jpeg,.png",onChange:t=>{var s;return b("driver_license_front",((s=t.target.files)==null?void 0:s[0])||null)},disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"license-back",className:"flex items-center gap-2",children:[o.driver_license_back.uploaded&&e.jsx(y,{className:"w-4 h-4 text-primary"}),"Driver's License (Back)"]}),e.jsx(N,{id:"license-back",type:"file",accept:".pdf,.jpg,.jpeg,.png",onChange:t=>{var s;return b("driver_license_back",((s=t.target.files)==null?void 0:s[0])||null)},disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"proof-address",className:"flex items-center gap-2",children:[o.proof_of_address.uploaded&&e.jsx(y,{className:"w-4 h-4 text-primary"}),"Proof of Address (Utility Bill or Bank Statement)"]}),e.jsx(N,{id:"proof-address",type:"file",accept:".pdf,.jpg,.jpeg,.png",onCh
1ange:t=>{var s;return b("proof_of_address",((s=t.target.files)==null?void 0:s[0])||null)},disabled:n})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsxs("div",{className:"flex items-start space-x-2",children:[e.jsx(U,{id:"terms",checked:m,onCheckedChange:t=>j(t),disabled:n}),e.jsxs("div",{className:"grid gap-1.5 leading-none",children:[e.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Accept terms and conditions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"I agree to the rental agreement terms, including weekly payment obligations, maintenance responsibilities, and end-of-term ownership transfer conditions."})]})]})}),e.jsx(_,{onClick:B,disabled:n||!m,className:"w-full",size:"lg",children:n?"Uploading...":"Submit Documents & Proceed to Payment"})]})]})},oe=()=>{const i=E(),{dashboardRoute:l,dashboardLabel:g}=G(),[a,n]=d.useState(null),[h,m]=d.useState(!0);d.useEffect(()=>{j()},[]);const j=async()=>{const{data:{user:o}}=await f.auth.getUser();if(!o){i("/?tab=login");return}const{data:x}=await f.from("applications").select("*").eq("user_id",o.id).eq("status","pending_documents").single();n(x),m(!1)};return h?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):a?e.jsx("div",{className:"min-h-screen bg-background p-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(_,{variant:"ghost",onClick:()=>i(l),className:"mb-6",children:[e.jsx(T,{className:"mr-2 h-4 w-4"}),"Back to ",g]}),e.jsxs(w,{className:"mb-6",children:[e.jsxs(C,{children:[e.jsx(k,{children:"Review Your Plan"}),e.jsx(D,{children:"Before submitting documents, please review your rental details"})]}),e.jsxs(S,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Selected Bike"}),e.jsx("span",{className:"font-medium",children:a.selected_bike})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Term Length"}),e.jsxs("span",{className:"font-medium",children:[a.selected_term_months," months"]})]})]})]}),e.jsx($,{applicationId:a.id,userId:a.user_id,onComplete:()=>i(l)})]})}):e.jsx("div",{className:"min-h-screen bg-background p-8",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(I,{className:"w-16 h-16 text-primary mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"No Pending Documents"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"You don't have any documents to submit at this time."}),e.jsxs(_,{onClick:()=>i(l),children:["Go to ",g]})]})})};export{oe 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.