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.