PageSourceSearch

https://foreseek.ai/assets/AlertsView-Dl2d6Xg_.js

js foreseek.ai collected 2026-10-05 14:11:19 UTC 13,931 bytes, 1 lines download raw bytes

1import{r as j,af as se,ah as R,j as e,C as v,g as b,h as N,ag as E,k as $,l as k,ap as te,T as W,aW as q,u as re,d as ae,c5 as le,bV as ie,s as z,N as y,B as w,al as ne,K as O,aB as F,cl as oe,F as de,t as ce}from"./index-CBgzuWa3.js";import{u as xe,B as me}from"./useMarketOpenWatch-B_TOceac.js";import{S as he,a as ue,b as fe,c as pe,d as G}from"./select-CzbFeLTN.js";import{T as U,a as Y,b as g,c as C}from"./tabs-fSN46brg.js";import{R as S,X as _,Y as D,s as K,T as L,A as je,B as A,C as ge}from"./generateCategoricalChart-D_1-83TC.js";import{e as ye,A as ve,B as V}from"./AreaChart-DPl2YXjm.js";import{C as T}from"./CartesianGrid-lPd2PpaF.js";import{f as P}from"./format-BF1Rjqon.js";import{p as I}from"./parseISO-QrV2fSX8.js";import{E as be}from"./eye-5hF-4ptV.js";import{F as Ne}from"./filter-CfO906PL.js";import"./chevron-down-DwFBhu8A.js";import"./chevron-up-DFr2l24j.js";function ke({alerts:n}){const m=j.useMemo(()=>{if(n.length===0)return[];const t=[...n].sort((r,x)=>new Date(r.settled_at).getTime()-new Date(x.settled_at).getTime()),a=new Date,h=new Date(t[0].settled_at),u=se(a,30),o=h<u?u:h,d=new Map;ye({start:R(o),end:R(a)}).forEach(r=>{const x=P(r,"yyyy-MM-dd");d.set(x,{wins:0,losses:0,pnl:0})}),t.forEach(r=>{const x=P(I(r.settled_at),"yyyy-MM-dd"),p=d.get(x);p&&(r.outcome==="win"?p.wins++:r.outcome==="loss"&&p.losses++,p.pnl+=r.pnl)});let l=0;const c=[];return t.filter(r=>new Date(r.settled_at)<o).forEach(r=>{l+=r.pnl}),d.forEach((r,x)=>{l+=r.pnl,c.push({date:x,dateLabel:P(I(x),"MMM d"),wins:r.wins,losses:r.losses,netPnl:r.pnl,cumulative:l,tradeCount:r.wins+r.losses})}),c},[n]),i=j.useMemo(()=>{const t=n.filter(l=>l.outcome==="win").length,a=n.filter(l=>l.outcome==="loss").length,h=n.reduce((l,c)=>l+c.pnl,0),u=t+a>0?Math.round(t/(t+a)*100):0;let o=0,d=null;const f=[...n].sort((l,c)=>new Date(c.settled_at).getTime()-new Date(l.settled_at).getTime());for(const l of f)if(l.outcome!=="push")if(d===null)d=l.outcome,o=1;else if(l.outcome===d)o++;else break;return{totalWins:t,totalLosses:a,totalPnl:h,winRate:u,currentStreak:o,streakType:d}},[n]);return n.length===0?e.jsxs(v,{children:[e.jsxs(b,{children:[e.jsxs(N,{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5 text-primary"}),"Settlement History"]}),e.jsx($,{children:"Win/loss trends and cumulative P&L"})]}),e.jsx(k,{children:e.jsx("div",{className:"h-[300px] flex items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(te,{className:"h-12 w-12 mx-auto mb-3 opacity-20"}),e.jsx("p",{children:"No settlements yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Charts will appear after your first trade settles"})]})})})]}):e.jsxs(v,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(N,{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5 text-primary"}),"Settlement History"]}),e.jsx($,{children:"Win/loss trends and cumulative P&L"})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Win Rate"}),e.jsxs("p",{className:`text-lg font-bold ${i.winRate>=50?"text-green-500":"text-red-500"}`,children:[i.winRate,"%"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total P&L"}),e.jsxs("p",{className:`text-lg font-bold ${i.totalPnl>=0?"text-green-500":"text-red-500"}`,children:[i.totalPnl>=0?"+":"",i.totalPnl,"¢"]})]}),i.currentStreak>1&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Streak"}),e.jsxs("p",{className:`text-lg font-bold flex items-center gap-1 ${i.streakType==="win"?"text-green-500":"text-red-500"}`,children:[i.streakType==="win"?e.jsx(W,{className:"h-4 w-4"}):e.jsx(q,{className:"h-4 w-4"}),i.currentStreak]})]})]})]})}),e.jsx(k,{children:e.jsxs(U,{defaultValue:"cumulative",className:"space-y-4",children:[e.jsxs(Y,{className:"grid w-full grid-cols-3",children:[e.jsx(g,{value:"cumulative",children:"Cumulative P&L"}),e.jsx(g,{value:"daily",children:"Daily P&L"}),e.jsx(g,{value:"winloss",children:"Win/Loss"})]}),e.jsx(C,{value:"cumulative",className:"h-[280px]",children:e.jsx(S,{width:"100%",height:"100%",children:e.jsxs(ve,{data:m,margin:{top:10,right:10,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"cumulativeGradientPos",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
1stopColor:"hsl(var(--foreseek-green))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--foreseek-green))",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"cumulativeGradientNeg",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--foreseek-red))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--foreseek-red))",stopOpacity:0})]})]}),e.jsx(T,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(_,{dataKey:"dateLabel",tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},axisLine:{stroke:"hsl(var(--border))"},tickLine:!1,interval:"preserveStartEnd"}),e.jsx(D,{tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},axisLine:{stroke:"hsl(var(--border))"},tickLine:!1,tickFormatter:t=>`${t}¢`}),e.jsx(K,{y:0,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3"}),e.jsx(L,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px",padding:"8px 12px"},labelStyle:{color:"hsl(var(--foreground))",fontWeight:"bold"},formatter:t=>[`${t>=0?"+":""}${t}¢`,"Cumulative P&L"]}),e.jsx(je,{type:"monotone",dataKey:"cumulative",stroke:i.totalPnl>=0?"hsl(var(--foreseek-green))":"hsl(var(--foreseek-red))",strokeWidth:2,fill:i.totalPnl>=0?"url(#cumulativeGradientPos)":"url(#cumulativeGradientNeg)"})]})})}),e.jsx(C,{value:"daily",className:"h-[280px]",children:e.jsx(S,{width:"100%",height:"100%",children:e.jsxs(V,{data:m,margin:{top:10,right:10,left:0,bottom:0},children:[e.jsx(T,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(_,{dataKey:"dateLabel",tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},axisLine:{stroke:"hsl(var(--border))"},tickLine:!1,interval:"preserveStartEnd"}),e.jsx(D,{tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},axisLine:{stroke:"hsl(var(--border))"},tickLine:!1,tickFormatter:t=>`${t}¢`}),e.jsx(K,{y:0,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"3 3"}),e.jsx(L,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px",padding:"8px 12px"},labelStyle:{color:"hsl(var(--foreground))",fontWeight:"bold"},formatter:(t,a)=>a==="netPnl"?[`${t>=0?"+":""}${t}¢`,"Daily P&L"]:[t,a]}),e.jsx(A,{dataKey:"netPnl",radius:[4,4,0,0],children:m.map((t,a)=>e.jsx(ge,{fill:t.netPnl>=0?"hsl(var(--foreseek-green))":"hsl(var(--foreseek-red))",opacity:.8},`cell-${a}`))})]})})}),e.jsx(C,{value:"winloss",className:"h-[280px]",children:e.jsx(S,{width:"100%",height:"100%",children:e.jsxs(V,{data:m,margin:{top:10,right:10,left:0,bottom:0},children:[e.jsx(T,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(_,{dataKey:"dateLabel",tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},axisLine:{stroke:"hsl(var(--border))"},tickLine:!1,interval:"preserveStartEnd"}),e.jsx(D,{tick:{fill:"hsl(var(--muted-foreground))",fontSize:10},axisLine:{stroke:"hsl(var(--border))"},tickLine:!1,allowDecimals:!1}),e.jsx(L,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px",padding:"8px 12px"},labelStyle:{color:"hsl(var(--foreground))",fontWeight:"bold"},formatter:(t,a)=>a==="wins"?[t,"Wins"]:a==="losses"?[t,"Losses"]:[t,a]}),e.jsx(A,{dataKey:"wins",stackId:"a",fill:"hsl(var(--foreseek-green))",radius:[0,0,0,0],opacity:.8}),e.jsx(A,{dataKey:"losses",stackId:"a",fill:"hsl(var(--foreseek-red))",radius:[4,4,0,0],opacity:.8})]})})})]})})]})}const H={settlement:"Settlements",price_alert:"Price Alerts",weekly_summary:"Weekly Summary",gift_subscription:"Gift Subscription",engagement_campaign:"Updates",personalized_reengagement:"Re-engagement",feature_update:"What's New",welcome:"Welcome",subscription:"Subscription",growth_celebration:"Growth Boost",affiliate:"Affiliate",system:"System",market_open:"Market Open"};function Ee(){const n=re(),{user:m}=ae(),{settlementAlerts:i}=le(),{notifications:t,unreadCount:a,markAllAsRead:h,trackClick:u}=ie(),{watches:o,removeWatch:d}=xe(),[f,l]=j.useState([]),[c,M]=j.useState("all"),[r,x]=j.useState("all");j.useEffect(()=>{m&&z.from("price_alerts").select("*").eq("user_id",m.id).eq("triggered",!1).order("created_at",{ascending:!1}).then(({data:s})=>{s&&l(s)})},[m]);const p=async s=>{const{error:Q}=await z.from("price_alerts").delete().eq("id",s);Q||(l(Z=>Z.filter(ee=>ee.id!==s)),ce.success("Alert removed"))},B=t.filter(s=>!(c!=="all"&&s.type!==c||r==="unread"&&s.read_at||r==="read"&&!s.read_at)),X=[...new Set(t.map(s=>s.type))],J=s=>{u(s.id),s.action_url&&n(s.action_url)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(ke,{alerts:i}),f.length>0&&e.jsxs(v,{className:"border-border/50",children:[e.jsx(b,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(W,{className:"h-4 w-4 text-primary"}),"Active Price Alerts",e.jsx(y,{variant:"secondary",className:"text-xs",children:f.length})]})}),e.jsx(k,{children:e.jsx("div",{className:"space-y-2",children:f.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-accent/30 border border-border/50",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:s.market_title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.condition==="above"?e.jsx(W,{className:"inline h-3 w-3 mr-1"}):e.jsx(q,{className:"inline h-3 w-3 mr-1"}),s.condition," ",s.target_price,"¢"]})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>p(s.id),children:e.jsx(ne,{className:"h-3.5 w-3.5"})})]},s.id))})})]}),o.length>0&&e.jsxs(v,{className:"border-border/50",children:[e.jsx(b,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-primary"}),"Market Watches",e.jsx(y,{variant:"secondary",className:"text-xs",children:o.length})]})}),e.jsx(k,{children:e.jsx("div",{className:"space-y-2",children:o.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-accent/30 border border-border/50",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:s.event_title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.category&&e.jsx(y,{variant:"outline",className:"text-[10px]",children:s.category}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:s.event_ticker}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",O(new Date(s.created_at),{addSuffix:!0})]})]})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>
1d(s.id),children:e.jsx(me,{className:"h-3.5 w-3.5"})})]},s.id))})})]}),e.jsxs("div",{className:"max-w-3xl space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(F,{className:"h-6 w-6 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a>0?`${a} unread`:"All caught up"})]})]}),a>0&&e.jsxs(w,{variant:"outline",size:"sm",onClick:h,className:"gap-1.5",children:[e.jsx(oe,{className:"h-3.5 w-3.5"}),"Mark all read"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3",children:[e.jsx(U,{value:r,onValueChange:s=>x(s),children:e.jsxs(Y,{children:[e.jsx(g,{value:"all",children:"All"}),e.jsx(g,{value:"unread",children:"Unread"}),e.jsx(g,{value:"read",children:"Read"})]})}),e.jsxs(he,{value:c,onValueChange:M,children:[e.jsxs(ue,{className:"w-full sm:w-[180px]",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 mr-2"}),e.jsx(fe,{placeholder:"All types"})]}),e.jsxs(pe,{children:[e.jsx(G,{value:"all",children:"All types"}),X.map(s=>e.jsx(G,{value:s,children:H[s]||s},s))]})]})]}),e.jsx("div",{className:"space-y-2",children:B.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(F,{className:"h-10 w-10 text-muted-foreground/30 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No notifications found"}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"You'll see trade settlements, price alerts, and more here"})]}):B.map(s=>e.jsx("button",{onClick:()=>J(s),className:de("w-full flex items-start gap-3 p-4 rounded-xl border transition-colors text-left",s.read_at?"border-border/50 hover:bg-accent/30":"border-primary/20 bg-primary/5 hover:bg-primary/10"),children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:s.title}),!s.read_at&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary shrink-0"}),e.jsx(y,{variant:"outline",className:"text-[10px] shrink-0 ml-auto",children:H[s.type]||s.type})]}),s.body&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.body}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/70 mt-1.5",children:[O(new Date(s.created_at),{addSuffix:!0}),s.channel!=="in_app"&&` • via ${s.channel}`]})]})},s.id))})]})]})}export{Ee 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.