PageSourceSearch

https://buddicarsv.lovable.app/assets/index-BRSPwUAU.js

js buddicarsv.lovable.app collected 2026-10-03 03:24:44 UTC 12,873 bytes, 4 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visits.functions-BsFZ1OZG.js","assets/sonner-D-yLv_Jo.js","assets/index-jOKgC_H_.js"])))=>i.map(i=>d[i]);
2import{r as s,_ as fe,j as e,L as be}from"./index-jOKgC_H_.js";import{u as N,t as w,T as ge}from"./sonner-D-yLv_Jo.js";import{i as he,l as k}from"./liff-Y5tXGdX_.js";import{e as ye,f as je,h as Ne,i as ke,j as ve,a as Se}from"./booking.functions-DS4Jljct.js";const le="2026-06-07",De=2,we=[13,14,15,16,17];function F(r){const o=r+De;return`${String(r).padStart(2,"0")}:00〜${String(o).padStart(2,"0")}:00`}function v(r){const o=new Date(`${r}T00:00:00+09:00`),m=["日","月","火","水","木","金","土"][o.getDay()];return`${o.getMonth()+1}月${o.getDate()}日(${m})`}function Te(){const r=new Date;return new Date(r.getTime()+540*60*1e3).toISOString().slice(0,10)}function T(r){const o=new Date(r),m=new Date(o.getTime()+9*36e5),y=String(m.getUTCHours()).padStart(2,"0"),S=String(m.getUTCMinutes()).padStart(2,"0");return`${y}:${S}`}function V(r){const o=new Date(r);return new Date(o.getTime()+9*36e5).toISOString().slice(0,10)}function Oe(){const r=N(ye),o=N(je),m=N(Ne),y=N(ke),S=N(ve),$=N(Se),g=(()=>{const t=Te();return t<le?le:t})(),[d]=s.useState("purchase"),[c,M]=s.useState(g),[p,j]=s.useState(g.slice(0,7)),[A,E]=s.useState(g),[H,R]=s.useState(""),[i,C]=s.useState(null),[P,Y]=s.useState([]),[f,K]=s.useState(!1),[_,a]=s.useState(!1),[u,x]=s.useState(!1),[b,D]=s.useState(!1),[I,W]=s.useState([]),[G,z]=s.useState(!0),[h,Q]=s.useState(null),X=s.useRef(null),[O,Z]=s.useState(""),[q,de]=s.useState(""),[ee,te]=s.useState(!1),[L,ce]=s.useState(null),[se,ae]=s.useState([]),[re,ne]=s.useState(null),[ie,ue]=s.useState([]),[me,oe]=s.useState(!1);s.useEffect(()=>{oe(!0),o({data:{month:p,serviceType:d}}).then(t=>ue(t.days)).catch(()=>{}).finally(()=>oe(!1))},[p,d,o]),s.useEffect(()=>{he().then(t=>{C(t),t?.idToken&&fe(async()=>{const{recordVisit:n}=await import("./visits.functions-BsFZ1OZG.js");return{recordVisit:n}},__vite__mapDeps([0,1,2])).then(({recordVisit:n})=>{n({data:{lineIdToken:t.idToken,path:"/"}}).catch(()=>{})})}),$().then(t=>{R(t.maxDate),E(t.minDate),W(t.blockedDates??[]),M(n=>n<t.minDate?t.minDate:t.maxDate&&n>t.maxDate?t.maxDate:n)}).catch(()=>{})},[$]),s.useEffect(()=>{i?.displayName&&!O&&Z(i.displayName)},[i]);const B=s.useCallback(async(t,n)=>{z(!0),Q(null);try{const l=await r({data:{date:t,serviceType:n}});Y(l.takenHours),K(l.dayFull),a(l.beforeStart),x(l.afterWindow??!1),D(l.blocked??!1)}catch{w.error("空き状況の取得に失敗しました")}finally{z(!1)}},[r]);s.useEffect(()=>{B(c,d)},[c,d,B]);const U=s.useCallback(async()=>{if(!i?.idToken){ae([]);return}try{const t=await y({data:{lineIdToken:i.idToken}});t.ok&&ae(t.bookings)}catch{}},[i?.idToken,y]);s.useEffect(()=>{U()},[U]);const xe=async t=>{if(i?.idToken&&confirm(`${v(V(t.slot_start))} ${T(t.slot_start)} の予約をキャンセルしますか?`)){ne(t.id);try{const n=await S({data:{id:t.id,lineIdToken:i.idToken}});if(!n.ok){w.error(n.error||"キャンセルに失敗しました");return}try{k.isInClient?.()&&typeof k.sendMessages=="function"&&await k.sendMessages([{type:"text",text:["【BUDDICA TOKYO 査定予約 キャンセル】",`日時:${v(V(t.slot_start))} ${T(t.slot_start)}〜${T(t.slot_end)}`,"再度のご予約をお待ちしております。"].join(`
3`)}])}catch(l){console.warn("[LIFF] sendMessages failed",l)}w.success("予約をキャンセルしました"),await Promise.all([U(),B(c,d)])}finally{ne(null)}}},pe=async t=>{if(t.preventDefault(),h!=null){te(!0);try{const n=await m({data:{date:c,hour:h,name:O,phone:q,service_type:d,lineIdToken:i?.idToken??null}});if(!n.ok){w.error(n.error),B(c,d);return}try{if(k.isInClient?.()&&typeof k.sendMessages=="function"){const J=[`【BUDDICA TOKYO ${d==="purchase"?"買取":"販売"}予約 完了】`,`日時:${v(c)} ${F(h)}`,`お名前:${O.trim()}`,`電話番号:${q.trim()}`,"","当日のご来店をお待ちしております。"].join(`
4`);await k.sendMessages([{type:"text",text:J}])}}catch(l){console.warn("[LIFF] sendMessages failed",l)}ce({date:c,hour:h,serviceType:d}),U()}catch{w.error("通信エラーが発生しました")}finally{te(!1)}}};return L?e.jsx("div",{className:"min-h-screen bg-background p-6 flex items-center justify-center",children:e.jsxs("div",{className:"max-w-md w-full overflow-hidden rounded-2xl border-2 border-primary bg-card",children:[e.jsxs("div",{className:"bg-primary px-5 py-7 text-center text-primary-foreground",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-primary-foreground
4/20 text-4xl",children:"✓"}),e.jsxs("h1",{className:"mt-3 text-xl font-bold",children:[L.serviceType==="purchase"?"買取":"販売","予約が完了しました"]})]}),e.jsx("div",{className:"space-y-2 p-5 text-sm",children:e.jsxs("div",{className:"flex justify-between border-b border-border pb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"日時"}),e.jsxs("span",{className:"font-semibold",children:[v(L.date)," ",F(L.hour)]})]})}),e.jsx("div",{className:"px-5 pb-5",children:e.jsx(be,{to:"/",className:"block w-full rounded-lg bg-primary py-2.5 text-center text-sm font-bold text-primary-foreground",children:"トップに戻る"})})]})}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ge,{}),e.jsx("header",{className:"bg-secondary text-secondary-foreground px-6 py-5",children:e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsx("div",{className:"text-xs text-primary font-bold tracking-widest",children:"BUDDICA TOKYO"}),e.jsx("h1",{className:"text-xl font-bold",children:"査定予約"}),e.jsx("p",{className:"text-xs mt-1 opacity-80",children:"13:00〜19:00 / 2時間枠"})]})}),e.jsxs("main",{className:"max-w-2xl mx-auto p-6 space-y-6",children:[e.jsx("div",{className:"bg-muted/60 border border-border rounded-xl px-4 py-3 text-xs text-muted-foreground",children:"6/6(土)のオープン記念イベントは終了しました。ご来場ありがとうございました。"}),se.length>0&&e.jsxs("section",{className:"bg-card border-2 border-primary rounded-2xl p-5 space-y-3",children:[e.jsx("h2",{className:"text-sm font-bold",children:"あなたの予約"}),e.jsx("ul",{className:"space-y-2",children:se.map(t=>e.jsxs("li",{className:"flex items-center justify-between gap-3 bg-muted/50 rounded-xl p-3",children:[e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"font-bold",children:[v(V(t.slot_start))," ",T(t.slot_start),"〜",T(t.slot_end)]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.name," / ",t.phone]})]}),e.jsx("button",{type:"button",onClick:()=>xe(t),disabled:re===t.id,className:"text-xs px-3 py-2 rounded-lg border border-destructive text-destructive font-bold disabled:opacity-60 whitespace-nowrap",children:re===t.id?"...":"キャンセル"})]},t.id))})]}),e.jsxs("section",{className:"bg-card border border-border rounded-2xl p-5 space-y-4",children:[e.jsx($e,{month:p,setMonth:j,days:ie,selectedDate:c,onSelect:t=>M(t),minDate:A||g,maxDate:H,loading:me}),I.includes(c)&&e.jsx("p",{className:"text-xs text-destructive",children:"この日は予約を受け付けていません"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"時間を選ぶ(2時間)"}),G?e.jsx("p",{className:"text-sm text-muted-foreground",children:"読み込み中..."}):_?e.jsx("p",{className:"text-sm text-destructive",children:"この日付は予約できません"}):u?e.jsx("p",{className:"text-sm text-destructive",children:"予約可能期間を超えています"}):b?e.jsx("p",{className:"text-sm text-destructive",children:"この日は予約を受け付けていません"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:we.map(t=>{const n=P.includes(t),l=n||f&&!n,J=h===t;return e.jsx("button",{type:"button",disabled:l,onClick:()=>{Q(t),setTimeout(()=>{X.current?.scrollIntoView({behavior:"smooth",block:"start"})},0)},className:`py-3 rounded-xl border text-sm font-bold transition ${J?"bg-primary text-primary-foreground border-primary":l?"bg-muted text-muted-foreground border-border cursor-not-allowed line-through":"bg-background border-border hover:border-primary"}`,children:F(t)},t)}
4)}),f&&!G&&!_&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["この日の",d==="purchase"?"買取":"販売","枠は満席です"]})]})]}),h!=null&&e.jsxs("form",{ref:X,onSubmit:pe,className:"bg-card border border-border rounded-2xl p-5 space-y-4 scroll-mt-4",children:[e.jsxs("h2",{className:"font-bold",children:[v(c)," ",F(h)]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium",children:"お名前"}),e.jsx("input",{type:"text",value:O,onChange:t=>Z(t.target.value),required:!0,maxLength:100,className:"mt-2 w-full px-3 py-2.5 rounded-lg border border-input bg-background"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium",children:"電話番号"}),e.jsx("input",{type:"tel",value:q,onChange:t=>de(t.target.value),required:!0,maxLength:50,placeholder:"09012345678",className:"mt-2 w-full px-3 py-2.5 rounded-lg border border-input bg-background"})]}),e.jsx("button",{type:"submit",disabled:ee,className:"w-full py-3 rounded-xl bg-primary text-primary-foreground font-bold disabled:opacity-60",children:ee?"予約中...":"この時間で予約する"})]}),e.jsxs("footer",{className:"text-[11px] text-muted-foreground pt-2 pb-8 leading-relaxed",children:["※完全予約制です。",e.jsx("br",{}),"※お一人様1予約までを推奨しています。"]})]})]})}function $e({month:r,setMonth:o,days:m,selectedDate:y,onSelect:S,minDate:$,maxDate:g,loading:d}){const[c,M]=r.split("-"),p=Number(c),j=Number(M),A=new Date(Date.UTC(p,j-1,1)).getUTCDay(),E=new Date(Date.UTC(p,j,0)).getUTCDate(),H=new Map(m.map(a=>[a.date,a])),R=$.slice(0,7),i=g?g.slice(0,7):"",C=a=>{const u=new Date(Date.UTC(p,j-1+a,1)),x=u.getUTCFullYear(),b=String(u.getUTCMonth()+1).padStart(2,"0");o(`${x}-${b}`)},P=r<=R,Y=i?r>=i:!1,f=[];for(let a=0;a<A;a++)f.push(null);for(let a=1;a<=E;a++){const u=`${r}-${String(a).padStart(2,"0")}`;f.push({ymd:u,info:H.get(u)})}for(;f.length%7!==0;)f.push(null);const K=a=>{switch(a){case"available":return{mark:"○",cls:"text-emerald-600",bg:""};case"few":return{mark:"△",cls:"text-amber-600",bg:""};case"full":return{mark:"×",cls:"text-muted-foreground",bg:"opacity-60"};case"blocked":return{mark:"休",cls:"text-destructive",bg:"opacity-60"};default:return{mark:"−",cls:"text-muted-foreground/50",bg:"opacity-40"}}},_=["日","月","火","水","木","金","土"];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{type:"button",onClick:()=>C(-1),disabled:P,className:"px-3 py-1.5 rounded-lg border border-border text-sm disabled:opacity-40",children:"‹ 前月"}),e.jsxs("div",{className:"font-bold text-sm",children:[p,"年",j,"月",d&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"読込中…"})]}),e.jsx("button",{type:"button",onClick:()=>C(1),disabled:Y,className:"px-3 py-1.5 rounded-lg border border-border text-sm disabled:opacity-40",children:"翌月 ›"})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 text-[11px] text-center text-muted-foreground",children:_.map((a,u)=>e.jsx("div",{className:u===0?"text-destructive":u===6?"text-primary":"",children:a},a))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:f.map((a,u)=>{if(!a)return e.jsx("div",{},`e${u}`);const x=a.info,b=K(x?.status),D=!!x&&x.status!=="closed"&&x.status!=="blocked"&&x.status!=="full",I=a.ymd===y,W=Number(a.ymd.slice(-2));return e.jsxs("button",{type:"button",disabled:!D||d,onClick:()=>D&&S(a.ymd),className:`aspect-square rounded-lg border flex flex-col items-center justify-center gap-0.5 text-xs transition ${I?"bg-primary text-primary-foreground border-primary":D?`bg-background border-border hover:border-primary ${b.bg}`:`bg-muted border-border cursor-not-allowed ${b.bg}`}`,children:[e.jsx("span",{className:"font-medium",children:W}),e.jsx("span",{className:`text-base leading-none ${I?"":b.cls}`,children:b.mark})]},a.ymd)})}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground pt-1",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-emerald-600 font-bold",children:"○"})," 空きあり"]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-amber-600 font-bold",children:"△"})," 残り僅か"]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-muted-foreground font-bold",children:"×"})," 満席"]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-destructive font-bold",children:"休"})," 休業"]})]})]})}export{Oe as component};

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.