PageSourceSearch

https://analyticsindiamag.com/assets/ProfileNotifications-sv-z3Bn9.js

js analyticsindiamag.com collected 2026-09-24 08:26:51 UTC 4,696 bytes, 1 lines download raw bytes

1import{u as b,e as v,a as N,r as t,j as e,G as n,H as k,m as o,a2 as w,bq as S,B as E,L as C,s as p,b3 as F,M as P,a_ as R}from"./index-KSWbwNeY.js";import{P as G}from"./ProfileSidebar-RSiubeOO.js";import L from"./Footer-DPSMpmUX.js";import{F as q}from"./flame-Ck6h37yv.js";import"./alert-dialog-DFWe8irl.js";import"./index-BpbyRUKB.js";import"./trash-2-CwcwS_bf.js";import"./lock-DNHSxtLD.js";import"./monitor-DWTsCiB7.js";import"./twitter-yEUqfNJX.js";import"./linkedin-B1bA0DJP.js";import"./youtube-CwivUiPT.js";import"./facebook-DahhNxAJ.js";const Q=()=>{const{user:i,loading:l}=b(),m=v(),{toast:c}=N(),[g,y]=t.useState(!0),[d,u]=t.useState(!1),[x,f]=t.useState({game_emails_enabled:!0,daily_result_emails:!0,streak_reminder_emails:!0,weekly_summary_emails:!0});t.useEffect(()=>{!l&&!i&&m("/auth?redirect=/profile/notifications")},[i,l,m]),t.useEffect(()=>{i&&(async()=>{if(i)try{const{data:a,error:r}=await p.from("profiles").select("game_emails_enabled, daily_result_emails, streak_reminder_emails, weekly_summary_emails").eq("id",i.id).single();if(r)throw r;a&&f({game_emails_enabled:a.game_emails_enabled??!0,daily_result_emails:a.daily_result_emails??!0,streak_reminder_emails:a.streak_reminder_emails??!0,weekly_summary_emails:a.weekly_summary_emails??!0})}catch(a){console.error("Error fetching notification settings:",a)}finally{y(!1)}})()},[i]);const h=async()=>{if(i){u(!0);try{const{error:s}=await p.from("profiles").update({...x,updated_at:new Date().toISOString()}).eq("id",i.id);if(s)throw s;c({title:"Saved",description:"Your notification preferences have been updated"})}catch(s){console.error("Error saving notification settings:",s),c({title:"Error",description:"Failed to save preferences",variant:"destructive"})}finally{u(!1)}}},_=s=>{f(a=>({...a,[s]:!a[s]}))};if(l||g)return e.jsx("div",{className:"min-h-screen bg-muted/30",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8",children:[e.jsx(n,{className:"h-8 w-48 mb-8"}),e.jsxs("div",{className:"grid lg:grid-cols-[280px_1fr] gap-8",children:[e.jsx(n,{className:"h-64 w-full"}),e.jsx(n,{className:"h-96 w-full"})]})]})});const j=[{key:"game_emails_enabled",icon:F,label:"Game Emails",description:"Receive emails about games and challenges"},{key:"daily_result_emails",icon:P,label:"Daily Results",description:"Get daily game results delivered to your inbox"},{key:"streak_reminder_emails",icon:q,label:"Streak Reminders",description:"Reminders to maintain your playing streak"},{key:"weekly_summary_emails",icon:R,label:"Weekly Summary",description:"Weekly digest of your activity and performance"}];return e.jsxs(e.Fragment,{children:[e.jsxs(k,{children:[e.jsx("title",{children:"Notifications | AIM"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-muted/30",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-8",children:[e.jsx(o.h1,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"text-2xl font-bold text-foreground mb-8",children:"Account Settings"}),e.jsxs("div",{className:"grid lg:grid-cols-[280px_1fr] gap-8",children:[e.jsx(G,{}),e.jsx(o.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:"space-y-6",children:e.jsxs("div",{className:"bg-background border border-border p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(w,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Notification Preferences"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose what emails you'd like to receive"})]})]}),e.jsx("div",{className:"space-y-1",children:j.map((s,a)=>{const r=s.icon;return e.jsxs(o.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:a*.05},className:"flex items-center justify-between p-4 hover:bg-muted/50 rounded-lg transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 bg-muted rounded-lg",children:e.jsx(r,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description})]})]}),e.jsx(S,{checked:x[s.key],onCheckedChange:()=>_(s.key)})]},s.key)})}),e.jsx("div",{className:"flex items-center justify-end pt-6 border-t border-border mt-6",children:e.jsx(E,{onClick:h,disabled:d,className:"min-w-32",children:d?e.jsx(C,{className:"h-4 w-4 animate-spin"}):"Save Preferences"})})]})})]})]})}),e.jsx(L,{})]})};export{Q 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.