PageSourceSearch

https://trail-mind.lovable.app/assets/Accounts-BGod2qu0.js

js trail-mind.lovable.app collected 2026-10-03 03:50:29 UTC 3,637 bytes, 8 lines download raw bytes

1import{u as A,r,a as T,s as n,j as e,M as g,D as k,b as L,B as d,c as S,d as E,e as B,f as O,L as P,I as F,g as H,C as p,h as f,i as N,k as I,l as M,m as U}from"./index-BJ8wyECU.js";import{P as v}from"./plus-DGmjq6I1.js";const R=()=>{const w=A(),[u,m]=r.useState([]),[D,x]=r.useState(!0),[c,h]=r.useState(""),[C,l]=r.useState(!1),{toast:i}=T();r.useEffect(()=>{j()},[]);const j=async()=>{const{data:{user:s}}=await n.auth.getUser();if(!s){x(!1);return}const{data:t,error:o}=await n.from("account_members").select(`
2        accounts (
3          id,
4          name,
5          plan,
6          created_at
7        )
8      `).eq("user_id",s.id);if(o)i({title:"エラー",description:"アカウントの読み込みに失敗しました",variant:"destructive"}),m([]);else{const _=(t==null?void 0:t.map(a=>a.accounts).filter(a=>a!==null).sort((a,b)=>new Date(b.created_at).getTime()-new Date(a.created_at).getTime()))||[];m(_)}x(!1)},y=async()=>{if(!c.trim()){i({title:"エラー",description:"アカウント名を入力してください",variant:"destructive"});return}const{data:{user:s}}=await n.auth.getUser();if(!s)return;const{data:t,error:o}=await n.from("accounts").insert({name:c,owner_id:s.id}).select().single();if(o){i({title:"エラー",description:"アカウントの作成に失敗しました",variant:"destructive"});return}await n.from("account_members").insert({account_id:t.id,user_id:s.id,role:"owner"}),i({title:"成功",description:"アカウントを作成しました"}),h(""),l(!1),j()};return D?e.jsx(g,{children:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-muted-foreground",children:"読み込み中..."})})}):e.jsx(g,{children:e.jsxs("div",{className:"p-8 space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"アカウント"}),e.jsx("p",{className:"text-muted-foreground",children:"組織アカウントを管理します"})]}),e.jsxs(k,{open:C,onOpenChange:l,children:[e.jsx(L,{asChild:!0,children:e.jsxs(d,{children:[e.jsx(v,{className:"mr-2 h-4 w-4"}),"新規作成"]})}),e.jsxs(S,{children:[e.jsxs(E,{children:[e.jsx(B,{children:"新しいアカウント"}),e.jsx(O,{children:"組織のアカウントを作成します"})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"account-name",children:"アカウント名"}),e.jsx(F,{id:"account-name",value:c,onChange:s=>h(s.target.value),placeholder:"例:株式会社サンプル"})]})}),e.jsx(H,{children:e.jsx(d,{onClick:y,children:"作成"})})]})]})]}),u.length===0?e.jsx(p,{children:e.jsxs(f,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(N,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"アカウントがありません"}),e.jsxs(d,{onClick:()=>l(!0),children:[e.jsx(v,{className:"mr-2 h-4 w-4"}),"最初のアカウントを作成"]})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:u.map(s=>e.jsxs(p,{className:"transition-all hover:shadow-lg cursor-pointer",onClick:()=>w(`/accounts/${s.id}`),children:[e.jsxs(I,{children:[e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-5 w-5 text-primary"}),s.name]}),e.jsxs(U,{children:["プラン: ",s.plan]})]}),e.jsx(f,{children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["作成日: ",new Date(s.created_at).toLocaleDateString("ja-JP")]})})]},s.id))})]})})};export{R 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.