PageSourceSearch

https://tracktrip.app/assets/budget-settings-BNJQROAb.js

js tracktrip.app collected 2026-10-02 01:16:07 UTC 4,021 bytes, 1 lines download raw bytes

1import{i as S,aC as d,y as T,U as o,an as p,k as v,j as e,am as w,B,A as D,az as A,as as F,ap as I,t as L}from"./index-BhunPy9K.js";import{u as C,a as G}from"./zod-D4Rm9sI3.js";import{I as z,a as Q,b as U,d as E}from"./input-group-CsxwQ8ab.js";import{u as O}from"./params-BHLXge9_.js";const R=p({budgets:A(I(o),p({amount:F().min(0,"Amount must be positive").nullable().optional()}))}),H=({travelId:n,onboarding:u,onSave:j})=>{const m=S(s=>s.from({budgets:d}).where(({budgets:t})=>T(t.travel,n)),[n]).data||[],a=O({id:n}),{register:h,handleSubmit:b,watch:x}=C({resolver:G(R),defaultValues:{budgets:o.reduce((s,t)=>{const r=m.find(c=>c.categoryType===t);return s[t]={amount:r?r.amount:null},s},{})}}),g=Object.values(x("budgets")).reduce((s,{amount:t})=>s+(t||0),0),i=v(a.endDate).diff(v(a.startDate),"day"),f=g*i,N=async s=>{try{for(const[t,{amount:r}]of Object.entries(s.budgets)){const c=m.find(l=>l.categoryType===t);c?d.update(c.id,l=>({...l,amount:r})):r&&d.insert({id:crypto.randomUUID(),travel:n,categoryType:t,category:null,amount:r})}u||L.success("Budgets successfully saved."),j?.()}catch(t){console.error("Failed to save budgets:",t)}},y=s=>{const t=x(`budgets.${s}.amount`);if(!(t==null||isNaN(t)))return t};return e.jsxs("div",{className:"space-y-6 px-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Expense types"}),e.jsx("div",{className:"text-xs text-subtle-foreground",children:"Set a budget for each type of expense and evaluate your total spending."})]}),e.jsxs("form",{onSubmit:b(N),className:"space-y-6",children:[e.jsx("div",{children:o.map(s=>e.jsx("div",{className:"space-y-2 border-b py-4",children:e.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{categoryType:s}),e.jsx("div",{className:"font-medium text-sm capitalize",children:s})]}),e.jsx("div",{className:"text-subtle-foreground text-xs pl-9",children:y(s)?e.jsxs(e.Fragment,{children:["Travel forecast:"," ",e.jsx("span",{className:"font-mono",children:(y(s)*i).toLocaleString(void 0,{style:"currency",currency:a.currency})})]}):"No budget set."})]}),e.jsxs(z,{className:"w-44",children:[e.jsx(Q,{placeholder:"10",step:"0.01",...h(`budgets.${s}.amount`,{valueAsNumber:!0})}),e.jsx(U,{align:"inline-end",children:e.jsxs(E,{children:[a.currency," / day"]})})]})]})},s))}),e.jsxs("div",{className:"space-y-2 border-b py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"font-medium text-sm",children:"Daily budget"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"text-sm font-mono",children:[g.toLocaleString(void 0,{style:"currency",currency:a.currency})," ","/ day"]})})]}),e.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"font-medium text-sm",children:"Travel forecast"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm font-mono",children:[e.jsxs("div",{className:"text-subtle-foreground",children:["x ",i," days ="]}),e.jsx("div",{children:f.toLocaleString(void 0,{style:"currency",currency:a.currency})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"font-medium text-sm",children:"Travel forecast per traveller"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm font-mono",children:[e.jsxs("div",{className:"text-subtle-foreground",children:["/ ",a.users.length," ="]}),e.jsx("div",{children:(f/a.users.length).toLocaleString(void 0,{style:"currency",currency:a.currency})})]})]})]}),e.jsx(B,{type:"submit",className:"w-full",children:u?e.jsxs(e.Fragment,{children:["Next",e.jsx(D,{className:"size-4"})]}):"Save budgets"})]})]})};export{H as B};

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.