1import{r as s,a as ne,j as e,y as M}from"./app-D8UIjF_9.js";import{D as oe}from"./Dashboard-DT61cewG.js";import{M as re}from"./ModalError-D9zSyi1_.js";import{F as P}from"./QuestionMarkCircleIcon-BV5cXfJn.js";import{F as de,a as ce}from"./PhotoIcon-CPK8UC6L.js";/* empty css */import"./Dropdown-_g-YAazs.js";import"./transition-Ca0IhWA_.js";import"./use-server-handoff-complete-C0avEQry.js";import"./use-is-mounted-8-rFA6wX.js";import"./dialog-BX-ecmYl.js";import"./use-tab-direction-j7XnGtiV.js";import"./LogoutButton-DjsFtCtB.js";import"./floating-872aDP9c.js";import"./SeoNoIndex-C7z_oAWU.js";import"./ExclamationTriangleIcon-CcLanru6.js";function Ce({auth:u,user_cars:l,userUnit:ue,errors:y}){const[g,T]=s.useState(l.length==1?l[0].id:""),[I,D]=s.useState(!0),[E,O]=s.useState(!1),[j,z]=s.useState(""),[w,p]=s.useState(l.length==1&&l[0].last_fuel_up_mileage!=null?l[0].last_fuel_up_mileage.fuel_mileage_current:""),[d,L]=s.useState(""),[x,R]=s.useState(l.length==1?l[0].fuel_unit_consumption.fuel_unit:"Unit"),[A,B]=s.useState(l.length==1?l[0].fuel_unit_consumption.fuel_unit_plural:"Units"),[n,W]=s.useState(""),[h,N]=s.useState(""),[k,f]=s.useState(""),[F,$]=s.useState("");s.useState({required:!0});const[q,S]=s.useState(!1),[G,_]=s.useState([]),[C,U]=s.useState([]),[Q,H]=s.useState(l.length==1?"("+l[0].odometer_unit.odometer_unit_short+")":""),[Y,m]=s.useState(""),[J,b]=s.useState(""),[V,c]=s.useState(!1),K=t=>{if(t!=""){T(t);let i=l.filter(o=>o.id==t);i[0].last_fuel_up_mileage!=null?p(i[0].last_fuel_up_mileage.fuel_mileage_current):p(""),H("("+i[0].odometer_unit.odometer_unit_short+")"),R(i[0].fuel_unit_consumption.fuel_unit),B(i[0].fuel_unit_consumption.fuel_unit_plural)}},X=t=>{W(t),t&&f(h/t)},Z=t=>{N(t),(n!=""||n!=0)&&t&&f(t/n)},ee=t=>{f(t),n!=""&&N(t*n)},te=t=>{console.log(u.subscribed),u.subscribed?t.target.value=null:(b("This is a premium feature"),m("Upgrade your current plan to add files"),c(!0),t.preventDefault())},ie=t=>{if(u.subscribed){const i=t.target.files,o=[],r=[],ae=["image/jpeg","image/png","image/gif","image/bmp","application/pdf","application/xml","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","text/csv","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain"];for(let a=0;a<i.length;a++)console.log(i[a]),ae.includes(i[a].type)?i[a].size<=10485760?(o.push(i[a]),r.push(URL.createObjectURL(i[a]))):(b("File Error"),m("File is too large ("+(i[a].size/1e3/1e3).toFixed(2)+" MB)"),c(!0),console.log("file too big")):(b("File Error"),m("Your file type is not accepted ("+i[a].type+")"),c(!0)),_(v=>[...v,...o]),U(v=>[...v,...r])}else m("Upgrade your current plan to add files"),c(!0)},se=t=>{_(i=>i.filter((o,r)=>r!==t)),U(i=>i.filter((o,r)=>r!==t))},le=t=>{t.preventDefault();const i={selectedCar:g,selectedFullTank:I,selectedMissedFill:E,selectedMileagePrevious:w,selectedMileageCurrent:j,selectedDate:d,selectedFuelCostPerUnit:n,selectedFuelTotalCost:h,selectedFuelQuantity:k,noteText:F,files:G};M.visit("/fuel",{method:"post",data:i,replace:!1,preserveState:!0,preserveScroll:!1,errorBag:null,forceFormData:!1,onError:o=>{S(!0)}})};return s.useEffect(()=>{d&&ne.get(`/fuel/${g}/lastodo?date=${d}`).then(t=>t.data).then(t=>{p(t.data.lastodo)}).catch(t=>{console.error("Error fetching data:",t)})},[d]),e.jsxs(oe,{auth:u,children:[e.jsx(re,{open:V,setOpen:c,modalHeader:J,modalMessage:Y}),e.jsxs("div",{className:q?"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative":"hidden",role:"alert",children:[e.jsx("span",{className:"block sm:inline",children:Object.keys(y).map((t,i)=>e.jsx("div",{children:y[t]}))}),e.jsx("span",{className:"absolute top-0 bottom-0 right-0 px-4 py-3",children:e.jsx("button",{onClick:()=>S(!1),children:e.jsxs("svg",{className:"fill-current h-6 w-6 text-red-500",role:"button",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:[e.jsx("title",{children:"Close"}),e.jsx("path",{d:"M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z"})]})})})]}),l.length>0?e.jsx("div",{className:"bg-white shadow sm:rounded-lg",children:e.jsx("div",{className:"px-4 py-5 sm:p-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base pb-3 font-semibold leading-6 text-blue-900",children:"Add Fuel Up"}),e.jsxs("form",{onSubmit:le,enctype:"multipart/form-data",children:[e.jsx("div",{className:"space-y-12",children:e.jsxs("div",{className:"border-b border-gray-900/10 pb-12",children:[e.jsx("div",{className:"grid grid-cols-1 gap-y-4 gap-x-6",children:e.jsxs("div",{className:" gap-y-6 gap-x-6",children:[e.jsx("label",{htmlFor:"year",className:"block text-sm font-medium leading-6 text-gray-900",children:"Select your vehicle:"}),e.jsx("div",{children:e.jsxs("select",{name:"vehicle_name",className:"block w-full rounded-md border-0 py-3 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-base sm:leading-6",value:g,onChange:t=>K(t.target.value),required:!0,children:[l.length==1?"":e.jsx("option",{value:"",children:"Select Your Car"}),l.map((t,i)=>e.jsx("option",{value:t.id,label:t.vehicle_name},i))]})})]})}),e.jsxs("div",{className:"flex grid-cols-3 py-3 gap-y-4 gap-x-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"service-date",className:"block text-sm font-medium leading-6 text-gray-900",children:"Date of Fuel up"}),e.jsx("div",{children:e.jsx("input",{type:"date",name:"service-date",id:"service-date",placeholder:"Service Date",value:d,onFocus:t=>t.target.showPicker(),onChange:t=>L(t.target.value),className:"block w-full rounded-md border-0 py-3 px-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-base sm:leading-6",required:!0})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{htmlFor:"vehicle-mileage",className:"block text-sm font-medium leading-6 text-gray-900",children:["Odometer at Fuel up ",Q]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",name:"vehicle-mileage",id:"vehicle-mileage",placeholder:"Odo at Fuel up",onWheel:t=>t.target.blur(),onChange:t=>z(t.target.value),value:j,className:"block w-full rounded-md border-0 py-3 px-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-base sm:leading-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsxs("p",{className:"text-xs",children:["Last Fuel Odo: ",w]})]})]})]}),e.jsxs("div",{className:"flex grid-cols-3 gap-y-4 gap-x-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{htmlFor:"vehicle-mileage",className:"block text-sm font-medium leading-6 text-gray-900",children:["Price / ",x]}),e.jsx("div",{children:e.jsx("input",{type:"number",name:"vehicle-mileage",id:"vehicle-mileage",placeholder:"Price / "+(x||"
1Unit"),onWheel:t=>t.target.blur(),onChange:t=>X(t.target.value),value:n,className:"block w-full rounded-md border-0 py-3 px-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-base sm:leading-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"vehicle-mileage",className:"block text-sm font-medium leading-6 text-gray-900",children:"Total Fuel up Cost"}),e.jsx("div",{children:e.jsx("input",{type:"number",name:"vehicle-mileage",id:"vehicle-mileage",placeholder:"Total Fuel up Cost",onWheel:t=>t.target.blur(),onChange:t=>Z(t.target.value),value:h,className:"block w-full rounded-md border-0 py-3 px-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-base sm:leading-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"vehicle-mileage",className:"block text-sm font-medium leading-6 text-gray-900",children:A}),e.jsx("div",{children:e.jsx("input",{type:"number",name:"vehicle-mileage",id:"vehicle-mileage",placeholder:"Fuel up Amount",onWheel:t=>t.target.blur(),onChange:t=>ee(t.target.value),value:k,className:"block w-full rounded-md border-0 py-3 px-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-base sm:leading-6 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"})})]})]}),e.jsx("div",{className:"flex grid-cols-1 pt-6 gap-y-4 gap-x-6",children:e.jsx("div",{className:"flex-1 items-center",children:e.jsxs("div",{className:"flex",children:[e.jsx("input",{defaultChecked:!0,id:"comments",name:"comments",type:"checkbox","aria-describedby":"comments-description",onClick:t=>D(t.target.checked),className:"scale-125 col-start-2 row-start-2 appearance-none rounded border border-gray-300 bg-white checked:border-indigo-600 checked:bg-indigo-600 indeterminate:border-indigo-600 indeterminate:bg-indigo-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 forced-colors:appearance-auto"}),e.jsx("p",{className:"text-base px-2",children:" Filled Full Tank"}),e.jsx("div",{"data-tooltip-target":"top-tooltip1",children:e.jsx(P,{className:" stroke-indigo-600 inline h-5 w-5"})})]})})}),e.jsx("div",{className:"flex grid-cols-1 pt-6 gap-y-4 gap-x-6",children:e.jsx("div",{className:"flex-1 items-center",children:e.jsxs("div",{className:"flex",children:[e.jsx("input",{id:"comments",name:"comments",type:"checkbox","aria-describedby":"comments-description",onClick:t=>O(t.target.checked),className:"scale-125 col-start-2 row-start-2 appearance-none rounded border border-gray-300 bg-white checked:border-indigo-600 checked:bg-indigo-600 indeterminate:border-indigo-600 indeterminate:bg-indigo-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 forced-colors:appearance-auto"}),e.jsx("p",{className:"text-base px-2",children:" Missed entering previous fuel up"}),e.jsx("div",{"data-tooltip-target":"top-tooltip2",children:e.jsx(P,{className:" stroke-indigo-600 inline h-5 w-5"})})]})})}),e.jsxs("div",{className:"absolute bottom-full invisible left-1/2 z-50 mb-3 -translate-x-1/2 whitespace-nowrap rounded-md bg-indigo-200 py-2 px-4 text-sm text-gray-800 font-medium transition-opacity duration-300 border border-gray-300 shadow-[0px_12px_30px_-4px_rgba(16,24,40,0.08);]",role:"tooltip",id:"top-tooltip1",children:[e.jsx("span",{className:"absolute -bottom-1.5 left-1/2 -z-20 h-3 w-3 border-b border-r border-gray-300 -translate-x-1/2 rotate-45 bg-indigo-200"}),"Fuel economy is only tracked when you fill the tank. If you only did a small top up, uncheck this."]}),e.jsxs("div",{className:"absolute bottom-full invisible left-1/2 z-50 mb-3 -translate-x-1/2 whitespace-nowrap rounded-md bg-indigo-200 py-2 px-4 text-sm text-gray-800 font-medium transition-opacity duration-300 border border-gray-300 shadow-[0px_12px_30px_-4px_rgba(16,24,40,0.08);]",role:"tooltip",id:"top-tooltip2",children:[e.jsx("span",{className:"absolute -bottom-1.5 left-1/2 -z-20 h-3 w-3 border-b border-r border-gray-300 -translate-x-1/2 rotate-45 bg-indigo-200"}),"If you missed entering a previous fuel up, we wont use the last entered fuel up as the basis between trips"]}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-x-6 gap-y-6 sm:grid-cols-6",children:[e.jsxs("div",{className:"col-span-full",children:[e.jsx("label",{htmlFor:"about",className:"block text-sm font-medium leading-6 text-gray-900",children:"Notes (optional)"}),e.jsx("div",{children:e.jsx("textarea",{maxLength:"255",id:"notes",name:"notes",rows:3,className:"block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-base sm:leading-6",defaultValue:"",value:F,onChange:t=>$(t.target.value),placeholder:"Enter any notes (ex. Oil top-up)"})})]}),e.jsxs("div",{className:"col-span-full",children:[e.jsx("label",{htmlFor:"cover-photo",className:"block text-sm font-medium leading-6 text-gray-900",children:"Upload a File"}),e.jsx("div",{className:"mt-2 flex justify-center rounded-lg border border-dashed border-gray-900/25 px-6 py-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(de,{className:"mx-auto h-12 w-12 text-gray-300","aria-hidden":"true"}),e.jsxs("div",{className:"mt-4 flex text-sm leading-6 text-gray-600",children:[e.jsxs("label",{htmlFor:"file-upload",className:"relative cursor-pointer rounded-md bg-white font-semibold text-indigo-600 focus-within:outline-none focus-within:ring-2 focus-within:ring-indigo-600 focus-within:ring-offset-2 hover:text-indigo-500",children:[e.jsx("span",{children:"Upload a file"}),e.jsx("input",{multiple:!0,id:"file-upload",name:"files[]",type:"file",accept:"image/*,application/pdf,application/xml,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel, text/csv, application/vnd.openxmlformats-officedocument.wordprocessingml.document, text/plain",onChange:ie,onClick:te,className:"sr-only"})]}),e.jsx("p",{className:"pl-1",children:"or drag and drop"})]}),e.jsx("p",{className:"text-xs leading-5 text-gray-600",children:"PNG, JPG, GIF up to 10MB"})]})})]}),e.jsx("div",{className:"col-span-full",children:C?e.jsx("div",{className:"gap-y-8",children:e.jsx("ul",{role:"list",className:"grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 sm:gap-x-6 lg:grid-cols-4 xl:gap-x-8",children:C.map((t,i)=>e.jsx("li",{children:e.jsxs("div",{className:"group relative flex-col aspect-h-7 aspect-w-10 block w-full overflow-hidden rounded-lg bg-gray-100 focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 focus-within:ring-offset-gray-100",children:[e.jsx("img",{src:t,alt:"",className:" w-full h-48 pointer-events-none object-cover "}),e.jsx("div",{className:"absolute top-0 right-0",children:e.jsx("button",{type:"button",className:"p-1 rounded-full bg-red-600 text-white shadow-sm hover:bg-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600",onClick:()=>se(i),children:e.jsx(ce,{className:"h-5 w-5","aria-hidden":"true"})})})]})},i))})}):null})]})]})}),e.jsx("div",{className:"mt-6 flex items-center justify-end gap-x-6",children:e.jsx("button",{type:"submit",className:"rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600",children:"Save"})})]})]})})}):e.jsx("div",{className:"bg-white shadow sm:rounded-lg",children:e.jsxs("div",{className:"px-4 py-5 sm:p-6",children:[e.jsx("div",{className:"mt-2 max-w-xl text-sm text-base",children:e.jsx("p",{children:"It looks like you don't have any active cars. Add or re-activate a car to get started!"})}),e.jsx("div",{className:"mt-5",children:e.jsx("button",{type:"button",className:"inline-flex items-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500",onClick:()=>M.visit("/add-car",{method:"get"}),children:"Add Car"})})]})})]})}export{Ce 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.