PageSourceSearch

https://slantapp.ai/assets/GroupTripProposalPage-Db1P7tGy.js

js slantapp.ai collected 2026-10-05 15:05:18 UTC 9,997 bytes, 1 lines download raw bytes

1import{u as K,c as Q,f as X,r as i,j as e,M as $,a4 as c,E as V,U as W,O as Z,L as H,n as ee,X as te,a9 as se,a7 as ae,B as ie,d as ne,Q as re,T as R,P as le}from"./index-tc5-nNLC.js";import{A as oe}from"./arrow-left-kYemJdx8.js";import{P as ce}from"./pencil-C45dJbNG.js";import{U as de}from"./utensils-crossed-Bhs6Ah8Z.js";import{B as xe}from"./bus-C1fQ2ti_.js";import{H as pe}from"./hotel-BRZfVFiM.js";const me={hotel:pe,flight:le,activity:R,ticket:R,transport:xe,dining:de};function ue(o){const d=me[o]??$;return e.jsx(d,{className:"w-3.5 h-3.5"})}function h(){return`s_${crypto.randomUUID().replace(/-/g,"").slice(0,12)}`}function ye(){const[,o]=K(),{toast:d}=Q(),{user:g,isAuthenticated:z}=X(),[n,L]=i.useState(null),[l,v]=i.useState(""),[f,w]=i.useState(""),[b,S]=i.useState(""),[j,k]=i.useState(6),[r,x]=i.useState([]),[C,p]=i.useState(null),[P,_]=i.useState(""),[m,E]=i.useState(!1),[D,I]=i.useState(!1),[T,U]=i.useState(""),M=sessionStorage.getItem("group_trip_session")??"";i.useEffect(()=>{const t=sessionStorage.getItem("group_trip_extraction");if(!t){o("/group-trip");return}try{const s=JSON.parse(t);L(s),v(s.destination??""),w(s.startDate??""),S(s.endDate??""),k(s.headcountEstimate??6)}catch{o("/group-trip")}},[]),i.useEffect(()=>{var t;if(g){const s=g,a=[s.firstName??s.first_name,s.lastName??s.last_name].filter(Boolean).join(" ")||((t=s.email)==null?void 0:t.split("@")[0])||"";U(a)}},[g]),i.useEffect(()=>{l&&O()},[l]);async function O(){var t;E(!0);try{const s=await fetch("/api/chain-plans/generate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({destination:l,startDate:f||void 0,endDate:b||void 0,headcount:j,context:((t=n==null?void 0:n.placesMentioned)==null?void 0:t.join(", "))??""})});if(!s.ok)throw new Error("generation failed");const u=((await s.json()).stops??[]).map(y=>({...y,_id:h()})),N=((n==null?void 0:n.placesMentioned)??[]).slice(0,3).map(y=>({_id:h(),day:1,name:y,type:"activity",description:"Place mentioned in your group chat",estimatedCostPerPersonUsd:0,durationHours:2}));x([...N,...u])}catch{const s=((n==null?void 0:n.suggestedActivities)??[]).slice(0,4).map((a,u)=>({_id:h(),day:Math.floor(u/2)+1,name:a.name,type:a.type??"activity",description:"",estimatedCostPerPersonUsd:0,durationHours:2}));x(s)}finally{E(!1)}}function Y(t){p(t._id),_(t.name)}function A(t){x(s=>s.map(a=>a._id===t?{...a,name:P}:a)),p(null)}function G(t){x(s=>s.filter(a=>a._id!==t))}function F(){const t=r.length>0?r[r.length-1].day:1;x(s=>[...s,{_id:h(),day:t,name:"New stop",type:"activity",description:"",estimatedCostPerPersonUsd:0,durationHours:2}])}const B=r.reduce((t,s)=>t+(s.estimatedCostPerPersonUsd??0),0);async function J(){if(!z){d({title:"Sign in to invite your group",description:"Your plan is ready — just sign in first.",variant:"destructive"}),window.location.href=`/api/login?returnTo=${encodeURIComponent("/group-trip/proposal")}`;return}if(!l.trim()){d({title:"Add a destination",variant:"destructive"});return}I(!0);try{const t=r.map(({_id:u,...N})=>N),a=await(await re("POST","/api/group-trip/publish",{destination:l.trim(),startDate:f||null,endDate:b||null,headcount:j,title:`${l.trim()} Group Trip`,stops:t,organizerDisplayName:T||void 0,sessionId:M})).json();if(!a.token)throw new Error("No invite token returned");sessionStorage.removeItem("group_trip_extraction"),o(`/group-trip/share/${a.token}`)}catch(t){d({title:"Failed to publish",description:t.message,variant:"destructive"}),I(!1)}}const q=Array.from(new Set(r.map(t=>t.day))).sort((t,s)=>t-s);return n?e.jsxs("div",{className:"min-h-screen bg-slate-950",children:[e.jsx("div",{className:"sticky top-0 z-20 bg-slate-950/95 backdrop-blur border-b border-slate-800",children:e.jsxs("div",{className:"max-w-lg mx-auto px-4 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>o("/group-trip"),className:"flex items-center gap-1.5 text-sm text-slate-400 hover:text-white transition-colors",children:[e.jsx(oe,{className:"w-4 h-4"})," Back"]}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Your trip plan"}),e.jsx("div",{className:"w-10"})]})}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 space-y-6",children:[e.jsxs("div",{className:"bg-slate-900 border border-slate-700 rounded-2xl p-5 space-y-4",children:[e.jsx("h2",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Trip details"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx($,{className:"w-3.5 h-3.5"})," Destination"]}
1),e.jsx(c,{value:l,onChange:t=>v(t.target.value),placeholder:"City, country…",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-600"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx(V,{className:"w-3.5 h-3.5"})," Start"]}),e.jsx(c,{type:"date",value:f,onChange:t=>w(t.target.value),className:"bg-slate-800 border-slate-700 text-white"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs text-slate-500",children:"End"}),e.jsx(c,{type:"date",value:b,onChange:t=>S(t.target.value),className:"bg-slate-800 border-slate-700 text-white"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx(W,{className:"w-3.5 h-3.5"})," Group size"]}),e.jsx(c,{type:"number",min:2,max:200,value:j,onChange:t=>k(Number(t.target.value)),className:"bg-slate-800 border-slate-700 text-white w-28"})]}),n.preferences&&n.preferences.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.preferences.map(t=>e.jsx(Z,{variant:"outline",className:"text-xs border-indigo-500/40 text-indigo-400",children:t},t))})]}),e.jsxs("div",{className:"bg-slate-900 border border-slate-700 rounded-2xl p-5 space-y-2",children:[e.jsx("label",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:"Your name on the invite"}),e.jsx(c,{value:T,onChange:t=>U(t.target.value),placeholder:"How should your group see you?",className:"bg-slate-800 border-slate-700 text-white placeholder:text-slate-600"}),e.jsx("p",{className:"text-xs text-slate-600",children:"Only your first name is shown to invitees — no contact details."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider",children:["Suggested stops ",r.length>0&&`(${r.length})`]}),e.jsx("button",{onClick:O,disabled:m,className:"text-xs text-indigo-400 hover:text-indigo-300 transition-colors",children:m?"Rebuilding…":"Regenerate"})]}),m?e.jsxs("div",{className:"flex items-center gap-3 bg-slate-900 border border-slate-800 rounded-xl p-5",children:[e.jsx(H,{className:"w-4 h-4 text-indigo-400 animate-spin"}),e.jsx("p",{className:"text-sm text-slate-400",children:"Building suggested itinerary…"})]}):e.jsxs("div",{className:"space-y-2",children:[q.map(t=>e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-bold text-slate-600 uppercase tracking-widest mb-1.5 px-1",children:["Day ",t]}),r.filter(s=>s.day===t).map(s=>e.jsxs("div",{className:"flex items-center gap-3 bg-slate-900 border border-slate-800 hover:border-slate-700 rounded-xl px-4 py-3 mb-1.5 group",children:[e.jsx("span",{className:"text-slate-500 flex-shrink-0",children:ue(s.type)}),C===s._id?e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsx(c,{autoFocus:!0,value:P,onChange:a=>_(a.target.value),onKeyDown:a=>{a.key==="Enter"&&A(s._id),a.key==="Escape"&&p(null)},className:"h-7 text-sm bg-slate-800 border-slate-600 text-white px-2"}),e.jsx("button",{onClick:()=>A(s._id),className:"text-emerald-400",children:e.jsx(ee,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>p(null),className:"text-slate-500",children:e.jsx(te,{className:"w-4 h-4"})})]}):e.jsx("span",{className:"flex-1 text-sm text-slate-200 font-medium",children:s.name}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[C!==s._id&&e.jsx("button",{onClick:()=>Y(s),className:"p-1 text-slate-500 hover:text-slate-300",children:e.jsx(ce,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>G(s._id),className:"p-1 text-slate-500 hover:text-red-400",children:e.jsx(se,{className:"w-3.5 h-3.5"})})]})]},s._id))]},t)),e.jsxs("button",{onClick:F,className:"w-full flex items-center justify-center gap-2 border border-dashed border-slate-700 hover:border-indigo-500 rounded-xl py-3 text-sm text-slate-500 hover:text-indigo-400 transition-colors",children:[e.jsx(ae,{className:"w-4 h-4"})," Add a stop"]})]})]}),B>0&&e.jsxs("div",{className:"bg-slate-900/60 border border-slate-800 rounded-xl px-4 py-3 flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Est. cost per person"}),e.jsxs("p",{className:"text-sm font-bold text-white",children:["$",B.toLocaleStr
1ing()]})]}),e.jsx("p",{className:"text-xs text-slate-600 text-center",children:"You can skip suggested stops — they're just a starting point. Your group decides what to actually book."}),e.jsx(ie,{className:"w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-7 text-base rounded-2xl",disabled:D||m||!l.trim(),onClick:J,children:D?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4 animate-spin"})," Publishing…"]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Invite the group ",e.jsx(ne,{className:"w-5 h-5"})]})}),e.jsx("p",{className:"text-[11px] text-slate-600 text-center pb-6",children:"This creates a shared trip page. Nobody is enrolled automatically — each person joins by tapping the link you share."})]})]}):null}export{ye 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.