PageSourceSearch

https://www.withlocals.com/assets/TransportationModePage-BMbAKNfu.js

js withlocals.com collected 2026-09-24 09:35:54 UTC 10,020 bytes, 6 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a3c0e1a6-a595-5d7a-a28e-309c16ae4db4")}catch(e){}}();
3import{r as f,j as e,a as T}from"./vendor-CHDpNRl_.js";import{ad as V,aZ as z,ae as F,af as A,h as v,a4 as N,aR as U,a2 as L,an as W,L as G,u as $}from"./index-m4t9BUro.js";import{P as H}from"./index-CEtjH_Lv.js";import{S as Z}from"./index-DjSz9cOw.js";import{W as q}from"./index-CUTyn206.js";import{T as J}from"./index-BkQgaSim.js";import{W as K}from"./index-D0H3X3Pb.js";import"./vendor-capacitor-Bp_CBuEU.js";import"./vendor-sentry-DNLfhAIm.js";import"./WithlocalsLogoSmall-DPqU_VCV.js";import"./VerifiedIcon-BrlloyCu.js";import"./WarningIcon-CFxH4fN-.js";const b=0,P=1,O=2,C=3,Q=-1,w={selectedOptions:["Walking","PublicTransport"],groupSize:{car:4,boat:4},fetchStatus:V,saveStatus:b,hasNoModeSaved:!1};function h(s,t=""){console.info(`%cDispatcher: ${s} ${t?`- ${t}`:""}`,"color: #bada55;")}function X(s,t){switch(t.type){case"FETCH_DETAILS":return h(t.type),{...s,fetchStatus:A};case"FETCH_DETAILS_SUCCESS":h(t.type);const o=t.payload.options.length===0,a=o?s.selectedOptions:t.payload.options;return{...s,selectedOptions:a,groupSize:t.payload.sizes,fetchStatus:F,saveStatus:o?C:b,hasNoModeSaved:o};case"FETCH_DETAILS_FAILED":return h(t.type),{...s,fetchStatus:z,saveStatus:b};case"SET_OPTION":h(t.type,t.payload.value);let n=s.selectedOptions;return s.selectedOptions.includes(t.payload.value)?n=s.selectedOptions.filter(r=>r!==t.payload.value):n.push(t.payload.value),{...s,selectedOptions:n,saveStatus:C};case"SET_GROUP_SIZE_CAR":return h(t.type,String(t.payload.size)),{...s,groupSize:{...s.groupSize,car:t.payload.size},saveStatus:C};case"SET_GROUP_SIZE_BOAT":return h(t.type,String(t.payload.size)),{...s,groupSize:{...s.groupSize,boat:t.payload.size},saveStatus:C};case"SAVE_DETAILS":return h(t.type),{...s,saveStatus:P};case"SAVE_DETAILS_SUCCESS":return h(t.type),{...s,saveStatus:O,hasNoModeSaved:!1};case"SAVE_DETAILS_FAILED":return h(t.type),{...s,saveStatus:Q}}}function M(s){return{fetch(t){s({type:"FETCH_DETAILS"}),v(`https://api.withlocals.com/api/v1/portfolio/host/${t}/transport-modes/`).get().then(({transportModes:o})=>{var r,l;const a={car:((r=o.find(c=>c.type==="Car"))==null?void 0:r.size)||4,boat:((l=o.find(c=>c.type==="Boat"))==null?void 0:l.size)||4},n=o.reduce((c,S)=>S.type!=="Other"?[...c,S.type]:[...c,S.what??""],[]);s({type:"FETCH_DETAILS_SUCCESS",payload:{options:n,sizes:a}})}).catch(()=>s({type:"FETCH_DETAILS_FAILED"}))},setOption(t){s({type:"SET_OPTION",payload:{value:t}})},setGroupSize(t,o){switch(t){case"car":return s({type:"SET_GROUP_SIZE_CAR",payload:{size:o}});case"boat":return s({type:"SET_GROUP_SIZE_BOAT",payload:{size:o}});default:return null}},onSubmit(t,o){s({type:"SAVE_DETAILS"}),v(`https://api.withlocals.com/api/v1/portfolio/host/${t}/transport-modes/`).post(o).then(()=>{s({type:"SAVE_DETAILS_SUCCESS"})}).catch(()=>s({type:"SAVE_DETAILS_FAILED"}))}}}const Y={...w,actions:M(()=>{})},k=f.createContext(Y),g=()=>f.useContext(k);function tt({children:s,accountId:t}){const[o,a]=f.useReducer(X,w),n=f.useMemo(()=>M(a),[a]),r={...o,actions:n};return f.useEffect(()=>{t&&n.fetch(t)},[t,n]),e.jsx(k.Provider,{value:r,children:s})}const E=[{name:"Walking",value:"Walking"},{name:"Public transport",value:"PublicTransport"},{name:"Bicycle",value:"Bike"},{name:"Car",value:"Car"},{name:"Boat",value:"Boat"},{name:"Scooter/Motor",value:"Motor"},{name:"Tuktuk",value:"TukTuk"}],et="_Container_1llc2_1",st="_AddButton_1llc2_5",ot="_ButtonText_1llc2_9",nt="_PlusIcon_1llc2_13",at="_Input_1llc2_30",rt="_ButtonContainer_1llc2_39",lt="_SmallButton_1llc2_44",ct="_CancelButton_1llc2_60",m={Container:et,AddButton:st,ButtonText:ot,PlusIcon:nt,Input:at,ButtonContainer:rt,SmallButton:lt,CancelButton:ct};function it(){const{t:s}=T(),{actions:t}=g(),[o,a]=f.useState(!1),[n,r]=f.useState(""),l=()=>a(!0),c=p=>r(p.target.value),S=p=>{p.preventDefault(),n&&(t.setOption(n),a(!1),r(""))},y=()=>{a(!1),r("")};
3return e.jsxs("div",{className:m.Container,children:[!o&&e.jsxs("button",{className:m.AddButton,onClick:l,children:[e.jsx("span",{className:m.PlusIcon,children:"+"}),e.jsx("span",{className:m.ButtonText,children:s("host-profile.addOtherMode",{defaultValue:"Add other mode"})})]}),o&&e.jsxs("div",{className:m.InputContainer,children:[e.jsx("input",{type:"text",value:n,onChange:c,className:m.Input,placeholder:s("host-profile.transportModePlaceholder",{defaultValue:"(i.e. segway, kick scooter...)"})}),e.jsxs("div",{className:m.ButtonContainer,children:[e.jsx(N,{type:"button",invertedBorder:!0,size:"S",className:m.SmallButton,disabled:!n,onClick:S,children:s("host-profile.addOption",{defaultValue:"Add option"})}),e.jsx(N,{type:"button",inverted:!0,size:"S",onClick:y,className:m.CancelButton,children:s("host-profile.cancel",{defaultValue:"Cancel"})})]})]})]})}const ut="_CapacitySelector_1ym13_1",pt="_Label_1ym13_6",dt="_Value_1ym13_16",St="_RoundButton_1ym13_24",ht="_ButtonsContainer_1ym13_50",d={CapacitySelector:ut,Label:pt,Value:dt,RoundButton:St,ButtonsContainer:ht};function mt({mode:s,value:t}){const{t:o}=T(),{actions:a}=g(),n=()=>{const l=t-1;l>0&&a.setGroupSize(s,l)},r=()=>{const l=t+1;l<=9&&a.setGroupSize(s,l)};return e.jsxs("div",{className:d.CapacitySelector,children:[e.jsx("span",{className:d.Label,children:o("host-profile.maxNumberOfPassengersInVehicle",{defaultValue:"Max. number of passengers in vehicle:"})}),e.jsxs("div",{className:d.ButtonsContainer,children:[e.jsx("span",{className:d.RoundButtonMinus,children:e.jsx("button",{type:"button",onClick:n,className:d.RoundButton,disabled:t===1,children:e.jsx("svg",{width:8,height:2,viewBox:"0 0 8 2",className:d.Minus,children:e.jsx("line",{x1:"0",y1:"1",x2:"8",y2:"1",strokeWidth:"1"})})})}),e.jsx("span",{className:d.Value,children:t===9?"8+":t}),e.jsx("span",{className:d.RoundButtonPlus,children:e.jsx("button",{"data-test-id":"increaseCounterButton",type:"button",onClick:r,className:d.RoundButton,disabled:t>8,children:e.jsxs("svg",{width:8,height:8,viewBox:"0 0 8 8",className:d.Plus,children:[e.jsx("line",{x1:"4",y1:"0",x2:"4",y2:"8",strokeWidth:"1"}),e.jsx("line",{x1:"0",y1:"4",x2:"8",y2:"4",strokeWidth:"1"})]})})})]})]})}const _t="_SubmitButton_1wkex_1",ft={SubmitButton:_t};function xt(){const{t:s}=T(),{selectedOptions:t,fetchStatus:o,saveStatus:a}=g(),n=t.length<1,r=()=>n||a===b||a===O,l=a===P;return o===V||o===A?null:e.jsxs(e.Fragment,{children:[n&&e.jsx(q,{text:s("host-profile.pleaseSelectMinimum1TransportationModeTo",{defaultValue:"Please select minimum 1 transportation mode to continue."})}),a===O&&e.jsx(Z,{}),e.jsx(N,{size:"S",type:"submit",disabled:r(),isLoading:l,className:ft.SubmitButton,children:"Save"})]})}const Ct="_ListItem_wh2jo_1",Tt="_OptionContent_wh2jo_6",yt="_Text_wh2jo_10",jt="_ChosenByDefault_wh2jo_16",gt="_Icon_wh2jo_25",j={ListItem:Ct,OptionContent:Tt,Text:yt,ChosenByDefault:jt,Icon:gt};function D({name:s,value:t,onSelect:o,isSelected:a,showChosenDefault:n}){const{t:r}=T(),l=()=>o(t);return e.jsx("li",{className:j.ListItem,children:e.jsx(U,{value:t,onChange:l,checked:!!a,children:e.jsxs("span",{className:j.OptionContent,children:[e.jsx(J,{name:t,className:j.Icon}),e.jsx("span",{className:j.Text,children:s}),n&&e.jsx("span",{className:j.ChosenByDefault,children:r("host-profile.chosenByDefault",{defaultValue:"Chosen by default"})})]})})})}const Bt="_Title_1lg0z_1",It="_Paragraph_1lg0z_7",Et="_Form_1lg0z_12",I={Title:Bt,Paragraph:It,Form:Et};function At(){const{t:s}=T(),{selectedOptions:t,groupSize:o,actions:a,saveStatus:n,fetchStatus:r,hasNoModeSaved:l}=g(),{account:c}=L(),S=W(),y=u=>{if(u.preventDefault(),n===C&&(c!=null&&c.id)){const i=t.map(_=>{const x=E.some(R=>R.value===_)?_:"Other",B=_==="Car"?o.car:_==="Boat"?o.boat:null;return{type:x,size:B,what:x==="Other"?_:null}});a.onSubmit(c.id,{transportModes:i})}},p=u=>{a.setOption(u)};return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:I.Title,children:s("host-profile.transport.question",{defaultValue:"What transportation mode(s) can you provide or arrange for you & your guests?"})}),e.jsx("p",{className:I.Paragraph,children:s("host-profile.transport.selectDescription",{defaultValue:"Select all the transportation modes you can offer to guests, whether owned or rented."})}),!S&&e.jsx("p",{className:I.Paragraph,children:s("host-profile.transport.matchingNote",{defaultValue:"This information will help us match you with the right Withlocals Originals experiences to get more bookings."})}),e.jsxs("form",{className:I.Form,onSubmit:y,children:[r!==A&&e.jsxs(e.Fragment,{children:[e.jsxs("ul",{children:[E.map(({name:u,value:i})=>{const _=i==="Walking"||i==="PublicTransport",x=t.includes(i),B=i==="Car"?o==null?void 0:o.car:i==="Boat"?o==null?void 0:o.boat:void 0;return e.jsxs(f.Fragment,{children:[e.jsx(D,{name:u,value:i,onSelect:p,isSelected:x,showChosenDefault:_&&l}),!!B&&x&&e.jsx(mt,{mode:i.toLowerCase(),value:B})]},i)}),t.map(u=>E.find(({value:i})=>i===u)?null:e.jsx(D,{name:u,value:u,isSelected:!0,onSelect:p},u))]}),e.jsx(it,{})]}
3),r===A&&e.jsx(G,{}),e.jsx(xt,{})]})]})}function bt({accountId:s}){const{t}=T(),{selectedOptions:o,saveStatus:a,groupSize:n,actions:r}=g(),l=$(),c=t("host-profile.transportationMode",{defaultValue:"Transportation mode"}),S=()=>{if(a===C&&s){const y=o.map(p=>{const u=E.some(x=>x.value===p)?p:"Other",i=p==="Car"?n.car:p==="Boat"?n.boat:null;return{type:u,size:i,what:u==="Other"?p:null}});r.onSubmit(s,{transportModes:y}),setTimeout(()=>l(),100)}};return e.jsxs(e.Fragment,{children:[e.jsx(H,{title:c,children:e.jsx(At,{})}),e.jsx(K,{onSave:S})]})}function Ut(){const{account:s}=L();return e.jsx(tt,{accountId:s==null?void 0:s.id,children:e.jsx(bt,{accountId:s==null?void 0:s.id})})}export{Ut as default};
4//# sourceMappingURL=TransportationModePage-BMbAKNfu.js.map
5
6//# debugId=a3c0e1a6-a595-5d7a-a28e-309c16ae4db4

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.