PageSourceSearch

https://yorisou-0317.web.app/assets/InstagramDmCampaignListPage-BCrgpb2l.js

js yorisou-0317.web.app collected 2026-10-03 12:41:30 UTC 9,436 bytes, 1 lines download raw bytes

1import{u as L,r as l,j as e,y as C,B as r,q as _,C as D,f as k,aw as P,d as $,e as T,aX as z,a1 as B,ay as S,aY as F,a5 as O,aO as R,a6 as q,a7 as A,a8 as G,a9 as H,p as U,aa as J,ab as V,b as p,t as N}from"./index-OESH-BF1.js";import{M as X}from"./mouse-pointer-6f9HoyvW.js";import{C as Y}from"./chart-no-axes-column-increasing-CH2bYFNv.js";var b=(x,h,c)=>new Promise((y,o)=>{var u=a=>{try{i(c.next(a))}catch(m){o(m)}},j=a=>{try{i(c.throw(a))}catch(m){o(m)}},i=a=>a.done?y(a.value):Promise.resolve(a.value).then(u,j);i((c=c.apply(x,h)).next())});function Z(){const x=L(),[h,c]=l.useState([]),[y,o]=l.useState(!0),[u,j]=l.useState(null),[i,a]=l.useState(null),[m,g]=l.useState(!1),[n,v]=l.useState(null);l.useEffect(()=>{document.title="Instagram DMキャンペーン"},[]),l.useEffect(()=>{f()},[]);const f=()=>b(null,null,function*(){try{o(!0),j(null);const s=yield p("GET","/api/tenants/me/instagram/dm-campaigns"),t=yield s.json();if(s.ok)c(t);else throw new Error(t.error||"キャンペーンの取得に失敗しました")}catch(s){const t=s instanceof Error?s.message:"予期せぬエラーが発生しました";j(t),N.error(t)}finally{o(!1)}}),w=()=>{x("/tenant/instagram/dm-campaigns/create")},E=s=>b(null,null,function*(){try{const t=yield p("GET",`/api/tenants/me/instagram/dm-campaigns/${s}/stats`);yield t.json(),t.ok&&(N.success("統計情報を更新しました"),f())}catch(t){console.error("Error fetching stats:",t)}}),M=s=>b(null,null,function*(){v(s),g(!0)}),I=()=>b(null,null,function*(){if(n){a(n.id),g(!1);try{const s=yield p("POST",`/api/tenants/me/instagram/dm-campaigns/${n.id}/send`,{});if(s.ok){const t=yield s.json();N.success(`${t.sentCount||0}件のDMを送信しました`),f()}else{const t=yield s.json();throw new Error(t.error||"送信に失敗しました")}}catch(s){const t=s instanceof Error?s.message:"予期せぬエラーが発生しました";N.error(t)}finally{a(null),v(null)}}}),d=(s,t)=>!s||!t||t===0?"0%":`${Math.round(s/t*100)}%`;return y?e.jsx("div",{className:"min-h-screen bg-[#eef5ff]",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(C,{className:"h-8 w-8 animate-spin text-gray-400"})})}):u?e.jsx("div",{className:"min-h-screen bg-[#eef5ff]",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-red-600 mb-4",children:u}),e.jsx(r,{onClick:f,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:"再読み込み"})]})}):e.jsx("div",{className:"min-h-screen bg-[#eef5ff]",children:e.jsxs("div",{className:"max-w-4xl mx-auto p-3 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg sm:text-2xl font-bold text-gray-900 truncate",children:"Instagram DMキャンペーン"}),e.jsx("p",{className:"text-sm text-gray-500 hidden sm:block",children:"InstagramのDMからLINE連携を促進するキャンペーンを管理します"})]}),e.jsxs(r,{onClick:w,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:[e.jsx(_,{className:"h-4 w-4 mr-2"}),"新規キャンペーン作成"]})]}),h.length===0?e.jsx(D,{className:"shadow-sm border-0 rounded-none bg-white",children:e.jsxs(k,{className:"text-center py-12",children:[e.jsx(P,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"まだキャンペーンがありません"}),e.jsxs(r,{onClick:w,variant:"outline",className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:[e.jsx(_,{className:"h-4 w-4 mr-2"}),"最初のキャンペーンを作成"]})]})}):e.jsx("div",{className:"grid gap-4",children:h.map(s=>e.jsxs(D,{className:"shadow-sm border-0 rounded-none bg-white",children:[e.jsx($,{className:"pb-4 p-4 sm:p-6",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(T,{className:"text-lg",children:s.campaign_name}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:s.dm_message||s.message_template})]}),e.jsx(z,{variant:"secondary",className:"ml-4",children:s.liff_page_type==="coupon"?"クーポン":s.liff_page_type==="reservation"?"予約":"カスタム"})]})}),e.jsxs(k,{className:"p-4 sm:p-6 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(B,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"対象者"})]}),e.jsx("p",{className:"text-xl font-semibold",children:s.total_recipients||0})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(S,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"送信数"})]}),e.jsx("p",{className:"text-xl font-semibold",children:s.sent_count||0})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(X,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"クリック"})]}),e.jsxs("p",{className:"text-xl font-semibold",children:[s.clicked_count||0,e.jsxs("span",{className:"text-sm text-gray-500 ml-1",children:["(",d(s.clicked_count,s.sent_count),")"]})]})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center mb-1",children:[e.jsx(F,{className:"h-4 w-4 text-gray-500 mr-1"}),e.jsx("span",{className:"text-sm text-gray-500",children:"連携"})]}),e.jsxs("p",{className:"text-xl font-semibold",children:[s.connected_count||0,e.jsxs("span",{className:"text-sm text-gray-500 ml-1",children:["(",d(s.connected_count,s.sent_count),")"]})]})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-gray-500",children:["作成日: ",new Date(s.created_at).toLocaleDateString("ja-JP")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>E(s.id),className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:[e.jsx(Y,{className:"h-4 w-4 mr-1"}),"統計更新"]}),s.sent_count===0&&e.jsx(r,{size:"sm",onClick:()=>M(s),disabled:i===s.id,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:i===s.id?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"h-4 w-4 mr-1 animate-spin"}),"送信中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 mr-1"}),"送信実行"]})}),s.sent_count&&s.sent_count>0&&e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>x(`/campaigns/page/${s.id}`),className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:[e.jsx(O,{className:"h-4 w-4 mr-1"}),"詳細"]})]})]}),s.sent_count&&s.sent_count>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"成果率"}),e.jsx(R,{className:"h-4 w-4 text-green-600"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{children:"クリック率"}),e.jsx("span",{children:d(s.clicked_count,s.sent_count)}
1)]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-blue-600 h-2 rounded-full",style:{width:`${Math.min(100,parseInt(d(s.clicked_count,s.sent_count)))}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{children:"連携率"}),e.jsx("span",{children:d(s.connected_count,s.sent_count)})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-green-600 h-2 rounded-full",style:{width:`${Math.min(100,parseInt(d(s.connected_count,s.sent_count)))}%`}})})]})]})]})]})]},s.id))}),e.jsx(q,{open:m,onOpenChange:g,children:e.jsxs(A,{className:"bg-white border-0 rounded-none",children:[e.jsxs(G,{children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5 text-yellow-600"}),"DMキャンペーンを送信しますか?"]}),e.jsx(J,{children:n&&e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"bg-gray-50 p-4",children:[e.jsx("p",{className:"font-medium text-gray-900 mb-2",children:n.campaign_name}),e.jsx("p",{className:"text-sm text-gray-600",children:n.dm_message||n.message_template})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600",children:"送信対象者数"}),e.jsxs("span",{className:"font-medium",children:[n.total_recipients||0,"名"]})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"この操作は取り消せません。対象者全員にDMが送信されます。"})]})})]}),e.jsxs(V,{children:[e.jsx(r,{variant:"outline",onClick:()=>g(!1),className:"rounded-none border-gray-200 bg-white shadow-sm hover:bg-gray-50",children:"キャンセル"}),e.jsx(r,{onClick:I,className:"rounded-none bg-blue-600 hover:bg-blue-700 text-white shadow-sm",children:"送信する"})]})]})})]})})}export{Z 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.