1import{r as d,j as e,u as g}from"./index-DKJ0tKwF.js";import{J as N,D as S,M,n as R,q as E,U as v,P,k as q}from"./button-DFML8rOM.js";import{d as D,aE as L,bj as b,b1 as T,r as U,q as l,aI as o,aJ as m,aK as x,J as h,cw as i,g as A}from"./App-CL-mfmhu.js";import{am as n}from"./V2Layout-DEbe2yZA.js";import{B as _}from"./v3LegalOverrides-BUgTGJPl.js";import{L as B}from"./tracker-DzJH7QDt.js";import"./mouse-pointer-2-CzsmklB8.js";import"./index-BNGwt955.js";import"./SEOHead-B5IBZJEm.js";import"./types-DU7944Yl.js";function V(){const{user:c}=D(),{workspace:r}=L(),[y,w]=d.useState(!0),[u,f]=d.useState(!1),[a,p]=d.useState({email_notifications:!0,push_notifications:!0,deal_updates:!0,contact_added:!0,task_reminders:!0,call_notifications:!0,campaign_updates:!0,mentions:!0,system_alerts:!0});d.useEffect(()=>{c&&r&&C()},[c,r]);const C=async()=>{try{const{data:s,error:j}=await N.from("notification_preferences").select("*").eq("user_id",c==null?void 0:c.id).eq("workspace_id",r==null?void 0:r.id).maybeSingle();if(j&&j.code!=="PGRST116")throw j;s&&p({email_notifications:s.email_notifications,push_notifications:s.push_notifications,deal_updates:s.deal_updates,contact_added:s.contact_added,task_reminders:s.task_reminders,call_notifications:s.call_notifications,campaign_updates:s.campaign_updates,mentions:s.mentions,system_alerts:s.system_alerts})}catch(s){console.error("Error fetching preferences:",s)}finally{w(!1)}},k=async()=>{if(!(!c||!r)){f(!0);try{const{error:s}=await N.from("notification_preferences").upsert({user_id:c.id,workspace_id:r.id,...a,updated_at:new Date().toISOString()},{onConflict:"user_id,workspace_id"});if(s)throw s;g.success("Notification preferences saved")}catch(s){console.error("Error saving preferences:",s),g.error("Failed to save preferences")}finally{f(!1)}}},t=s=>{p({...a,[s]:!a[s]})};return y?e.jsx(b,{children:e.jsx("main",{className:"flex-1 p-8",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx(T,{className:"h-32 rounded-xl"},s))})})}):e.jsx(b,{children:e.jsx("main",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-8 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(U,{className:"mb-4 bg-primary/10 text-primary border-primary/20",children:[e.jsx(_,{className:"w-3 h-3 mr-1"}),"Notifications"]}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Notification Preferences"}),e.jsx("p",{className:"text-muted-foreground",children:"Choose how and when you want to be notified"})]}),e.jsxs(S,{onClick:k,disabled:u,children:[u&&e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Changes"]})]}),e.jsxs(l,{className:"mb-8",children:[e.jsxs(o,{children:[e.jsx(m,{children:"Delivery Methods"}),e.jsx(x,{children:"Choose how you want to receive notifications"})]}),e.jsxs(h,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10",children:e.jsx(M,{className:"h-5 w-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"Email Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Receive notifications via email"})]})]}),e.jsx(i,{checked:a.email_notifications,onCheckedChange:()=>t("email_notifications")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-green-500/10",children:e.jsx(R,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"Push Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Receive push notifications in your browser"})]})]}),e.jsx(i,{checked:a.push_notifications,onCheckedChange:()=>t("push_notifications")})]})]})]}),e.jsxs(l,{className:"mb-8",children:[e.jsxs(o,{children:[e.jsx(m,{children:"Activity Notifications"}),e.jsx(x,{children:"Get notified about important activities in your CRM"})]}),e.jsxs(h,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-purple-500/10",children:e.jsx(E,{className:"h-5 w-5 text-purple-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"Deal Updates"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When deals move stages or are won/lost"})]})]}),e.jsx(i,{checked:a.deal_updates,onCheckedChange:()=>t("deal_updates")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-cyan-500/10",children:e.jsx(v,{className:"h-5 w-5 text-cyan-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"New Contacts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When new contacts are added to your workspace"})]})]}),e.jsx(i,{checked:a.contact_added,onCheckedChange:()=>t("contact_added")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-orange-500/10",children:e.jsx(_,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"Task Reminders"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Reminders for upcoming and overdue tasks"})]})]}),e.jsx(i,{checked:a.task_reminders,onCheckedChange:()=>t("task_reminders")})]})]})]}),e.jsxs(l,{className:"mb-8",children:[e.jsxs(o,{children:[e.jsx(m,{children:"Communication Notifications"}),e.jsx(x,{children:"Stay updated on your communications"})]}),e.jsxs(h,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-green-500/10",children:e.jsx(P,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"Call Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Incoming calls and missed call alerts"})]})]}),e.jsx(i,{checked:a.call_notifications,onCheckedChange:()=>t("call_notifications")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-pink-500/10",children:e.jsx(q,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"Campaign Upd
1ates"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"SMS and email campaign status updates"})]})]}),e.jsx(i,{checked:a.campaign_updates,onCheckedChange:()=>t("campaign_updates")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-indigo-500/10",children:e.jsx(v,{className:"h-5 w-5 text-indigo-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"Mentions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"When someone mentions you in notes or comments"})]})]}),e.jsx(i,{checked:a.mentions,onCheckedChange:()=>t("mentions")})]})]})]}),e.jsxs(l,{children:[e.jsxs(o,{children:[e.jsx(m,{children:"System Notifications"}),e.jsx(x,{children:"Important alerts and system updates"})]}),e.jsx(h,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-red-500/10",children:e.jsx(A,{className:"h-5 w-5 text-red-500"})}),e.jsxs("div",{children:[e.jsx(n,{className:"text-base",children:"System Alerts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Security alerts, billing updates, and system maintenance"})]})]}),e.jsx(i,{checked:a.system_alerts,onCheckedChange:()=>t("system_alerts")})]})})]})]})})})}export{V 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.