hey-pharmacist-ecommerce 1.1.31 → 1.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +92 -267
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -268
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/AccountSettingsTab.tsx +0 -50
- package/src/components/NotificationDrawer.tsx +2 -9
- package/src/components/ProductCard.tsx +3 -3
- package/src/components/TabNavigation.tsx +1 -1
- package/src/components/ui/Button.tsx +1 -1
- package/src/providers/NotificationCenterProvider.tsx +11 -27
- package/src/screens/NotificationSettingsScreen.tsx +119 -211
- package/src/styles/globals.css +4 -0
- package/styles/base.css +6 -0
- package/styles/globals.css +3 -0
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import React12, { createContext, forwardRef, useContext, useEffect, useState, us
|
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import globalAxios21 from 'axios';
|
|
5
5
|
import { motion, AnimatePresence, useMotionValue, useTransform } from 'framer-motion';
|
|
6
|
-
import { Trash2, X, CheckCheck, Settings, BellOff, Eye, Star, ShoppingCart, Sparkles, ShieldCheck, TrendingUp, Search, Package, ArrowUpDown, ChevronDown, LayoutGrid, LayoutList, Clock, User, MessageCircle, Filter, ChevronLeft, Check, Heart, Truck, RotateCcw, Shield, Minus, Plus, ShoppingBag, ArrowRight, CheckCircle2, MapPin, CreditCard, Edit3, AlertCircle, Lock, EyeOff, UserPlus, Mail, Send, ArrowLeft, MessageSquare, ChevronRight, ArrowUpRight, PackageCheck, Warehouse, BellRing, Crown, Phone, Grid, List, Loader2, Bell,
|
|
6
|
+
import { Trash2, X, CheckCheck, Settings, BellOff, Eye, Star, ShoppingCart, Sparkles, ShieldCheck, TrendingUp, Search, Package, ArrowUpDown, ChevronDown, LayoutGrid, LayoutList, Clock, User, MessageCircle, Filter, ChevronLeft, Check, Heart, Truck, RotateCcw, Shield, Minus, Plus, ShoppingBag, ArrowRight, CheckCircle2, MapPin, CreditCard, Edit3, AlertCircle, Lock, EyeOff, UserPlus, Mail, Send, ArrowLeft, MessageSquare, ChevronRight, ArrowUpRight, PackageCheck, Warehouse, BellRing, Crown, Phone, Grid, List, Loader2, Bell, LogOut, Menu, Facebook, Twitter, Instagram, Shirt, Pill, Box, TrendingDown, ExternalLink, Gift, Tag, Globe, Home, CheckCircle, Edit, AlertTriangle, Info, XCircle } from 'lucide-react';
|
|
7
7
|
import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';
|
|
8
8
|
import { useRouter, useSearchParams, useParams } from 'next/navigation';
|
|
9
9
|
import Image4 from 'next/image';
|
|
@@ -12434,13 +12434,6 @@ function NotificationCenterProvider({ children }) {
|
|
|
12434
12434
|
setIsLoading(true);
|
|
12435
12435
|
try {
|
|
12436
12436
|
const response = await notificationsApi.current.getNotifications(pageNum, 20, false);
|
|
12437
|
-
console.log("Raw API response:", {
|
|
12438
|
-
fullResponse: response,
|
|
12439
|
-
data: response.data,
|
|
12440
|
-
dataType: typeof response.data,
|
|
12441
|
-
isArray: Array.isArray(response.data),
|
|
12442
|
-
keys: response.data ? Object.keys(response.data) : []
|
|
12443
|
-
});
|
|
12444
12437
|
const data = response.data;
|
|
12445
12438
|
let rawNotifications = [];
|
|
12446
12439
|
if (Array.isArray(data)) {
|
|
@@ -12460,13 +12453,6 @@ function NotificationCenterProvider({ children }) {
|
|
|
12460
12453
|
createdAt: n.createdAt,
|
|
12461
12454
|
data: n.data
|
|
12462
12455
|
}));
|
|
12463
|
-
console.log("Fetched and mapped notifications:", {
|
|
12464
|
-
pageNum,
|
|
12465
|
-
append,
|
|
12466
|
-
rawCount: rawNotifications.length,
|
|
12467
|
-
mappedCount: newNotifications.length,
|
|
12468
|
-
firstNotification: newNotifications[0]
|
|
12469
|
-
});
|
|
12470
12456
|
if (append) {
|
|
12471
12457
|
setNotifications((prev) => [...prev, ...newNotifications]);
|
|
12472
12458
|
} else {
|
|
@@ -12485,7 +12471,6 @@ function NotificationCenterProvider({ children }) {
|
|
|
12485
12471
|
setIsLoading(true);
|
|
12486
12472
|
try {
|
|
12487
12473
|
const response = await notificationsApi.current.getSettings();
|
|
12488
|
-
console.log("Settings API response raw:", response);
|
|
12489
12474
|
const rawData = response.data;
|
|
12490
12475
|
let finalSettings = null;
|
|
12491
12476
|
if (rawData) {
|
|
@@ -12530,7 +12515,6 @@ function NotificationCenterProvider({ children }) {
|
|
|
12530
12515
|
finalSettings = rawData;
|
|
12531
12516
|
}
|
|
12532
12517
|
}
|
|
12533
|
-
console.log("Parsed settings:", finalSettings);
|
|
12534
12518
|
setSettings(finalSettings);
|
|
12535
12519
|
} catch (error) {
|
|
12536
12520
|
console.error("Failed to fetch settings:", error);
|
|
@@ -12546,11 +12530,12 @@ function NotificationCenterProvider({ children }) {
|
|
|
12546
12530
|
}
|
|
12547
12531
|
return;
|
|
12548
12532
|
}
|
|
12549
|
-
const token = getAuthToken();
|
|
12550
|
-
if (!token) return;
|
|
12551
12533
|
try {
|
|
12552
12534
|
const config = getCurrentConfig();
|
|
12553
|
-
const
|
|
12535
|
+
const token = getAuthToken();
|
|
12536
|
+
if (!token) return;
|
|
12537
|
+
const baseUrl = config.apiBaseUrl.endsWith("/") ? config.apiBaseUrl.slice(0, -1) : config.apiBaseUrl;
|
|
12538
|
+
const sseUrl = `${baseUrl}/notifications/stream?token=${encodeURIComponent(token)}`;
|
|
12554
12539
|
const eventSource = new EventSource(sseUrl);
|
|
12555
12540
|
eventSourceRef.current = eventSource;
|
|
12556
12541
|
eventSource.onmessage = (event) => {
|
|
@@ -12671,14 +12656,13 @@ function NotificationCenterProvider({ children }) {
|
|
|
12671
12656
|
}
|
|
12672
12657
|
}))
|
|
12673
12658
|
};
|
|
12674
|
-
console.log("Updating settings with payload:", payload);
|
|
12675
12659
|
await notificationsApi.current.updateSettings(payload);
|
|
12676
|
-
|
|
12660
|
+
await fetchSettings();
|
|
12677
12661
|
} catch (error) {
|
|
12678
12662
|
console.error("Failed to update settings:", error);
|
|
12679
12663
|
throw error;
|
|
12680
12664
|
}
|
|
12681
|
-
}, []);
|
|
12665
|
+
}, [fetchSettings]);
|
|
12682
12666
|
const value = {
|
|
12683
12667
|
notifications,
|
|
12684
12668
|
unreadCount,
|
|
@@ -12846,14 +12830,6 @@ function NotificationDrawer() {
|
|
|
12846
12830
|
const router = useRouter();
|
|
12847
12831
|
const { buildPath } = useBasePath();
|
|
12848
12832
|
const scrollContainerRef = useRef(null);
|
|
12849
|
-
console.log("NotificationDrawer render:", {
|
|
12850
|
-
isDrawerOpen,
|
|
12851
|
-
notificationsCount: notifications.length,
|
|
12852
|
-
notifications: notifications.slice(0, 2),
|
|
12853
|
-
// First 2 for brevity
|
|
12854
|
-
unreadCount,
|
|
12855
|
-
isLoading
|
|
12856
|
-
});
|
|
12857
12833
|
const handleScroll = () => {
|
|
12858
12834
|
if (!scrollContainerRef.current || isLoading || !hasMore) return;
|
|
12859
12835
|
const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current;
|
|
@@ -12885,6 +12861,7 @@ function NotificationDrawer() {
|
|
|
12885
12861
|
closeDrawer();
|
|
12886
12862
|
router.push(buildPath("/account/notifications"));
|
|
12887
12863
|
};
|
|
12864
|
+
console.log(notifications);
|
|
12888
12865
|
return /* @__PURE__ */ jsx(AnimatePresence, { children: isDrawerOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12889
12866
|
/* @__PURE__ */ jsx(
|
|
12890
12867
|
motion.div,
|
|
@@ -13381,7 +13358,7 @@ function ProductCard({
|
|
|
13381
13358
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] line-clamp-2", children: product.name }),
|
|
13382
13359
|
selectedVariant && /* @__PURE__ */ jsx("p", { className: "text-xs font-['Poppins',sans-serif] text-[#676c80]", children: selectedVariant.name })
|
|
13383
13360
|
] }),
|
|
13384
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 ", children: [
|
|
13361
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 my-2", children: [
|
|
13385
13362
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-0.5", children: [...Array(5)].map((_, i) => /* @__PURE__ */ jsx(
|
|
13386
13363
|
Star,
|
|
13387
13364
|
{
|
|
@@ -13389,7 +13366,7 @@ function ProductCard({
|
|
|
13389
13366
|
},
|
|
13390
13367
|
i
|
|
13391
13368
|
)) }),
|
|
13392
|
-
/* @__PURE__ */ jsxs("span", { className: "font-['Poppins',sans-serif] text-[10px] text-[#676c80]
|
|
13369
|
+
/* @__PURE__ */ jsxs("span", { className: "font-['Poppins',sans-serif] text-[10px] text-[#676c80] ", children: [
|
|
13393
13370
|
"(",
|
|
13394
13371
|
product.summary?.reviewCount || 0,
|
|
13395
13372
|
")"
|
|
@@ -13475,7 +13452,7 @@ function ProductCard({
|
|
|
13475
13452
|
}
|
|
13476
13453
|
},
|
|
13477
13454
|
disabled: isAddingToCart || variantImages.length > 0 && !selectedVariantId || displayInventoryCount === 0,
|
|
13478
|
-
className: "w-full font-['Poppins',sans-serif] font-medium text-[11px] px-3 py-2 rounded-full bg-[#5B9BD5] text-white hover:bg-[#4a8ac4] hover:shadow-lg transition-all duration-300 flex items-center justify-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
13455
|
+
className: "w-full font-['Poppins',sans-serif] font-medium text-[11px] px-3 py-2 rounded-full bg-[#5B9BD5] text-white hover:bg-[#4a8ac4] hover:shadow-lg transition-all duration-300 flex items-center justify-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",
|
|
13479
13456
|
children: [
|
|
13480
13457
|
/* @__PURE__ */ jsx(ShoppingCart, { className: "h-4 w-4" }),
|
|
13481
13458
|
displayInventoryCount === 0 ? "Out of Stock" : "Add to Cart"
|
|
@@ -13539,7 +13516,7 @@ function Button({
|
|
|
13539
13516
|
children,
|
|
13540
13517
|
...props
|
|
13541
13518
|
}) {
|
|
13542
|
-
const baseStyles = "font-medium rounded-full transition-all duration-200 inline-flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed focus:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500";
|
|
13519
|
+
const baseStyles = "font-medium rounded-full transition-all duration-200 inline-flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed focus:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500 hover:cursor-pointer";
|
|
13543
13520
|
const variants = {
|
|
13544
13521
|
primary: "bg-primary-600 text-white hover:bg-primary-700 shadow-lg shadow-primary-500/30 hover:shadow-xl hover:shadow-primary-500/40",
|
|
13545
13522
|
secondary: "bg-secondary-600 text-white hover:bg-secondary-700 shadow-lg shadow-secondary-500/30 hover:shadow-xl hover:shadow-secondary-500/40",
|
|
@@ -18067,7 +18044,7 @@ function TabNavigation({ tabs: tabs2, activeTab, onTabChange }) {
|
|
|
18067
18044
|
{
|
|
18068
18045
|
onClick: () => onTabChange(tab.id),
|
|
18069
18046
|
className: `
|
|
18070
|
-
flex items-center gap-2 px-6 py-3 text-sm font-medium whitespace-nowrap
|
|
18047
|
+
flex items-center gap-2 px-6 py-3 mt-2 text-sm font-medium whitespace-nowrap
|
|
18071
18048
|
border-b-2 transition-colors
|
|
18072
18049
|
${isActive ? "bg-secondary text-white rounded-xl hover:transition-all hover:duration-300 hover:ease-in-out hover:-translate-y-1" : "bg-white text-muted rounded-xl hover:text-secondary hover:transition-all hover:duration-150 hover:ease-in-out hover:-translate-y-1"}
|
|
18073
18050
|
`,
|
|
@@ -18747,9 +18724,6 @@ function AccountSettingsTab() {
|
|
|
18747
18724
|
const router = useRouter();
|
|
18748
18725
|
const { buildPath } = useBasePath();
|
|
18749
18726
|
const { logout } = useAuth();
|
|
18750
|
-
const [emailNotifications, setEmailNotifications] = useState(true);
|
|
18751
|
-
const [orderUpdates, setOrderUpdates] = useState(true);
|
|
18752
|
-
const [promotionalEmails, setPromotionalEmails] = useState(false);
|
|
18753
18727
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
18754
18728
|
const [isDeleting, setIsDeleting] = useState(false);
|
|
18755
18729
|
const [deleteError, setDeleteError] = useState(null);
|
|
@@ -18769,59 +18743,6 @@ function AccountSettingsTab() {
|
|
|
18769
18743
|
}
|
|
18770
18744
|
};
|
|
18771
18745
|
return /* @__PURE__ */ jsxs("div", { className: "p-6 space-y-6", children: [
|
|
18772
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-slate-200 bg-white p-6", children: [
|
|
18773
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-4", children: [
|
|
18774
|
-
/* @__PURE__ */ jsx(Bell, { className: "h-5 w-5 text-secondary" }),
|
|
18775
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-secondary", children: "Account Preferences" })
|
|
18776
|
-
] }),
|
|
18777
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
18778
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center justify-between gap-4 rounded-lg border border-slate-200 bg-slate-50 px-4 py-3", children: [
|
|
18779
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
18780
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-secondary", children: "Email Notifications" }),
|
|
18781
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted", children: "Receive updates about your orders" })
|
|
18782
|
-
] }),
|
|
18783
|
-
/* @__PURE__ */ jsx(
|
|
18784
|
-
"input",
|
|
18785
|
-
{
|
|
18786
|
-
type: "checkbox",
|
|
18787
|
-
checked: emailNotifications,
|
|
18788
|
-
onChange: (e) => setEmailNotifications(e.target.checked),
|
|
18789
|
-
className: "h-4 w-4 rounded-sm border-primary-300 text-secondary focus:ring-primary-500"
|
|
18790
|
-
}
|
|
18791
|
-
)
|
|
18792
|
-
] }),
|
|
18793
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center justify-between gap-4 rounded-lg border border-slate-200 bg-slate-50 px-4 py-3", children: [
|
|
18794
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
18795
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-secondary", children: "Order Updates" }),
|
|
18796
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted", children: "Get notified about shipping status" })
|
|
18797
|
-
] }),
|
|
18798
|
-
/* @__PURE__ */ jsx(
|
|
18799
|
-
"input",
|
|
18800
|
-
{
|
|
18801
|
-
type: "checkbox",
|
|
18802
|
-
checked: orderUpdates,
|
|
18803
|
-
onChange: (e) => setOrderUpdates(e.target.checked),
|
|
18804
|
-
className: "h-4 w-4 rounded-sm border-primary-300 text-secondary focus:ring-primary-500"
|
|
18805
|
-
}
|
|
18806
|
-
)
|
|
18807
|
-
] }),
|
|
18808
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center justify-between gap-4 rounded-lg border border-slate-200 bg-slate-50 px-4 py-3", children: [
|
|
18809
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
18810
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-secondary", children: "Promotional Emails" }),
|
|
18811
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted", children: "Receive special offers and discounts" })
|
|
18812
|
-
] }),
|
|
18813
|
-
/* @__PURE__ */ jsx(
|
|
18814
|
-
"input",
|
|
18815
|
-
{
|
|
18816
|
-
type: "checkbox",
|
|
18817
|
-
checked: promotionalEmails,
|
|
18818
|
-
onChange: (e) => setPromotionalEmails(e.target.checked),
|
|
18819
|
-
className: "h-4 w-4 rounded-sm border-primary-300 text-secondary focus:ring-primary-500"
|
|
18820
|
-
}
|
|
18821
|
-
)
|
|
18822
|
-
] })
|
|
18823
|
-
] })
|
|
18824
|
-
] }),
|
|
18825
18746
|
/* @__PURE__ */ jsxs("div", { className: "rounded-2xl border border-slate-200 bg-white p-6", children: [
|
|
18826
18747
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-4", children: [
|
|
18827
18748
|
/* @__PURE__ */ jsx(Lock, { className: "h-5 w-5 text-secondary" }),
|
|
@@ -21453,7 +21374,6 @@ function OrderReviewsScreen() {
|
|
|
21453
21374
|
var NOTIFICATION_CATEGORIES = [
|
|
21454
21375
|
{
|
|
21455
21376
|
name: "Order Updates",
|
|
21456
|
-
icon: Package,
|
|
21457
21377
|
types: [
|
|
21458
21378
|
{
|
|
21459
21379
|
type: "ORDER_CONFIRMATION" /* ORDERCONFIRMATION */,
|
|
@@ -21474,7 +21394,6 @@ var NOTIFICATION_CATEGORIES = [
|
|
|
21474
21394
|
},
|
|
21475
21395
|
{
|
|
21476
21396
|
name: "Payments",
|
|
21477
|
-
icon: CreditCard,
|
|
21478
21397
|
types: [
|
|
21479
21398
|
{
|
|
21480
21399
|
type: "PAYMENT_FAILED" /* PAYMENTFAILED */,
|
|
@@ -21490,7 +21409,6 @@ var NOTIFICATION_CATEGORIES = [
|
|
|
21490
21409
|
},
|
|
21491
21410
|
{
|
|
21492
21411
|
name: "Security",
|
|
21493
|
-
icon: Shield,
|
|
21494
21412
|
types: [
|
|
21495
21413
|
{
|
|
21496
21414
|
type: "PASSWORD_RESET" /* PASSWORDRESET */,
|
|
@@ -21513,7 +21431,6 @@ var NOTIFICATION_CATEGORIES = [
|
|
|
21513
21431
|
},
|
|
21514
21432
|
{
|
|
21515
21433
|
name: "Marketing",
|
|
21516
|
-
icon: Bell,
|
|
21517
21434
|
types: [
|
|
21518
21435
|
{
|
|
21519
21436
|
type: "ABANDONED_CART_REMINDER" /* ABANDONEDCARTREMINDER */,
|
|
@@ -21536,31 +21453,29 @@ var NOTIFICATION_CATEGORIES = [
|
|
|
21536
21453
|
]
|
|
21537
21454
|
}
|
|
21538
21455
|
];
|
|
21456
|
+
var Switch = ({ checked, onChange, disabled }) => /* @__PURE__ */ jsx(
|
|
21457
|
+
"button",
|
|
21458
|
+
{
|
|
21459
|
+
onClick: () => !disabled && onChange(!checked),
|
|
21460
|
+
className: `relative w-9 h-5 rounded-full transition-colors duration-200 ease-in-out focus:outline-none ${checked ? "bg-black" : "bg-slate-200"} ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}`,
|
|
21461
|
+
children: /* @__PURE__ */ jsx(
|
|
21462
|
+
"span",
|
|
21463
|
+
{
|
|
21464
|
+
className: `absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform duration-200 ease-in-out ${checked ? "translate-x-4" : "translate-x-0"}`
|
|
21465
|
+
}
|
|
21466
|
+
)
|
|
21467
|
+
}
|
|
21468
|
+
);
|
|
21539
21469
|
function NotificationSettingsScreen() {
|
|
21540
21470
|
const { settings, updateSettings, isLoading } = useNotificationCenter();
|
|
21541
21471
|
const [localSettings, setLocalSettings] = useState(settings);
|
|
21542
|
-
const [expandedCategories, setExpandedCategories] = useState(
|
|
21543
|
-
new Set(NOTIFICATION_CATEGORIES.map((cat) => cat.name))
|
|
21544
|
-
);
|
|
21545
21472
|
const [isSaving, setIsSaving] = useState(false);
|
|
21546
21473
|
const [hasChanges, setHasChanges] = useState(false);
|
|
21547
21474
|
useEffect(() => {
|
|
21548
|
-
console.log("NotificationSettingsScreen: settings updated:", settings);
|
|
21549
21475
|
if (settings) {
|
|
21550
21476
|
setLocalSettings(settings);
|
|
21551
21477
|
}
|
|
21552
21478
|
}, [settings]);
|
|
21553
|
-
const toggleCategory = (categoryName) => {
|
|
21554
|
-
setExpandedCategories((prev) => {
|
|
21555
|
-
const next = new Set(prev);
|
|
21556
|
-
if (next.has(categoryName)) {
|
|
21557
|
-
next.delete(categoryName);
|
|
21558
|
-
} else {
|
|
21559
|
-
next.add(categoryName);
|
|
21560
|
-
}
|
|
21561
|
-
return next;
|
|
21562
|
-
});
|
|
21563
|
-
};
|
|
21564
21479
|
const getChannelSetting = (type, channel) => {
|
|
21565
21480
|
const activeSettings = hasChanges ? localSettings : settings;
|
|
21566
21481
|
if (!activeSettings?.preferences || !Array.isArray(activeSettings.preferences)) {
|
|
@@ -21616,173 +21531,83 @@ function NotificationSettingsScreen() {
|
|
|
21616
21531
|
setIsSaving(false);
|
|
21617
21532
|
}
|
|
21618
21533
|
};
|
|
21619
|
-
const disableAllChannel = (channel) => {
|
|
21620
|
-
setLocalSettings((prev) => {
|
|
21621
|
-
const currentSettings = prev || { preferences: [] };
|
|
21622
|
-
const prefIsArray = Array.isArray(currentSettings.preferences);
|
|
21623
|
-
const preferences = NOTIFICATION_CATEGORIES.flatMap(
|
|
21624
|
-
(cat) => cat.types.filter((t) => !t.isComingSoon).map((t) => t.type)
|
|
21625
|
-
).map((type) => {
|
|
21626
|
-
const existing = prefIsArray ? currentSettings.preferences.find((p) => p.type === type) : void 0;
|
|
21627
|
-
return {
|
|
21628
|
-
type,
|
|
21629
|
-
settings: {
|
|
21630
|
-
email: channel === "email" ? false : existing?.settings?.email ?? true,
|
|
21631
|
-
push: channel === "push" ? false : existing?.settings?.push ?? true,
|
|
21632
|
-
inApp: existing?.settings?.inApp ?? true
|
|
21633
|
-
}
|
|
21634
|
-
};
|
|
21635
|
-
});
|
|
21636
|
-
return { ...currentSettings, preferences };
|
|
21637
|
-
});
|
|
21638
|
-
setHasChanges(true);
|
|
21639
|
-
};
|
|
21640
21534
|
if (isLoading && !settings) {
|
|
21641
|
-
return /* @__PURE__ */
|
|
21642
|
-
/* @__PURE__ */ jsx(Loader2, { className: "w-10 h-10 text-primary animate-spin mb-4" }),
|
|
21643
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted font-medium", children: "Loading preferences..." })
|
|
21644
|
-
] });
|
|
21535
|
+
return /* @__PURE__ */ jsx("div", { className: "flex h-[50vh] flex-col items-center justify-center", children: /* @__PURE__ */ jsx(Loader2, { className: "h-6 w-6 animate-spin text-slate-400" }) });
|
|
21645
21536
|
}
|
|
21646
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
21647
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
21648
|
-
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold text-
|
|
21649
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-
|
|
21537
|
+
return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-4xl px-6 py-8", children: [
|
|
21538
|
+
/* @__PURE__ */ jsx("div", { className: "mb-6 flex items-end justify-between border-b border-slate-100 pb-4", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
21539
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold tracking-tight text-slate-900", children: "Notifications" }),
|
|
21540
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-slate-500", children: "Manage your notification preferences across all channels." })
|
|
21650
21541
|
] }) }),
|
|
21651
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
21652
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
21653
|
-
|
|
21654
|
-
|
|
21655
|
-
|
|
21656
|
-
|
|
21657
|
-
|
|
21658
|
-
|
|
21659
|
-
|
|
21660
|
-
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
|
|
21665
|
-
}
|
|
21666
|
-
),
|
|
21667
|
-
/* @__PURE__ */ jsx(AnimatePresence, { children: expandedCategories.has(category.name) && /* @__PURE__ */ jsx(
|
|
21668
|
-
motion.div,
|
|
21669
|
-
{
|
|
21670
|
-
initial: { height: 0, opacity: 0 },
|
|
21671
|
-
animate: { height: "auto", opacity: 1 },
|
|
21672
|
-
exit: { height: 0, opacity: 0 },
|
|
21673
|
-
transition: { duration: 0.2 },
|
|
21674
|
-
className: "border-t border-slate-100",
|
|
21675
|
-
children: /* @__PURE__ */ jsx("div", { className: "p-6 space-y-4", children: category.types.map((notifType) => /* @__PURE__ */ jsx(
|
|
21676
|
-
"div",
|
|
21677
|
-
{
|
|
21678
|
-
className: `rounded-xl border border-slate-200 bg-slate-50 p-4 transition-all hover:bg-white hover:shadow-sm ${notifType.isComingSoon ? "opacity-50 grayscale select-none" : ""}`,
|
|
21679
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row sm:items-center justify-between gap-6", children: [
|
|
21680
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
21681
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
21682
|
-
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-secondary", children: notifType.label }),
|
|
21683
|
-
notifType.isComingSoon && /* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold uppercase tracking-wider bg-slate-200 text-muted px-2 py-0.5 rounded-full", children: "Soon" })
|
|
21684
|
-
] }),
|
|
21685
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted mt-1 leading-relaxed", children: notifType.description })
|
|
21686
|
-
] }),
|
|
21687
|
-
!notifType.isComingSoon && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-6 sm:border-l sm:border-slate-200 sm:pl-6", children: [
|
|
21688
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 cursor-pointer group/label", children: [
|
|
21689
|
-
/* @__PURE__ */ jsx(
|
|
21690
|
-
"input",
|
|
21691
|
-
{
|
|
21692
|
-
type: "checkbox",
|
|
21693
|
-
checked: getChannelSetting(notifType.type, "email"),
|
|
21694
|
-
onChange: (e) => updateChannelSetting(notifType.type, "email", e.target.checked),
|
|
21695
|
-
className: "w-4 h-4 text-primary border-slate-300 rounded-sm focus:ring-primary focus:ring-offset-0"
|
|
21696
|
-
}
|
|
21697
|
-
),
|
|
21698
|
-
/* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold text-muted uppercase tracking-wider group-hover/label:text-primary transition-colors", children: "Email" })
|
|
21699
|
-
] }),
|
|
21700
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 cursor-pointer group/label", children: [
|
|
21701
|
-
/* @__PURE__ */ jsx(
|
|
21702
|
-
"input",
|
|
21703
|
-
{
|
|
21704
|
-
type: "checkbox",
|
|
21705
|
-
checked: getChannelSetting(notifType.type, "push"),
|
|
21706
|
-
onChange: (e) => updateChannelSetting(notifType.type, "push", e.target.checked),
|
|
21707
|
-
className: "w-4 h-4 text-primary border-slate-300 rounded-sm focus:ring-primary focus:ring-offset-0"
|
|
21708
|
-
}
|
|
21709
|
-
),
|
|
21710
|
-
/* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold text-muted uppercase tracking-wider group-hover/label:text-primary transition-colors", children: "Push" })
|
|
21711
|
-
] }),
|
|
21712
|
-
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 cursor-pointer group/label", children: [
|
|
21713
|
-
/* @__PURE__ */ jsx(
|
|
21714
|
-
"input",
|
|
21715
|
-
{
|
|
21716
|
-
type: "checkbox",
|
|
21717
|
-
checked: getChannelSetting(notifType.type, "inApp"),
|
|
21718
|
-
onChange: (e) => updateChannelSetting(notifType.type, "inApp", e.target.checked),
|
|
21719
|
-
className: "w-4 h-4 text-primary border-slate-300 rounded-sm focus:ring-primary focus:ring-offset-0"
|
|
21720
|
-
}
|
|
21721
|
-
),
|
|
21722
|
-
/* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold text-muted uppercase tracking-wider group-hover/label:text-primary transition-colors", children: "In-App" })
|
|
21723
|
-
] })
|
|
21724
|
-
] })
|
|
21725
|
-
] })
|
|
21726
|
-
},
|
|
21727
|
-
notifType.type
|
|
21728
|
-
)) })
|
|
21729
|
-
}
|
|
21730
|
-
) })
|
|
21731
|
-
] }, category.name)) }),
|
|
21732
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-white rounded-2xl p-6 border border-slate-200 mb-8 shadow-xs", children: [
|
|
21733
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-4", children: [
|
|
21734
|
-
/* @__PURE__ */ jsx(Zap, { className: "h-5 w-5 text-accent" }),
|
|
21735
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-secondary", children: "Quick Actions" })
|
|
21542
|
+
/* @__PURE__ */ jsxs("div", { className: "hidden grid-cols-12 gap-4 border-b border-slate-100 pb-3 text-xs font-medium uppercase tracking-wider text-slate-400 sm:grid", children: [
|
|
21543
|
+
/* @__PURE__ */ jsx("div", { className: "col-span-8", children: "Topic" }),
|
|
21544
|
+
/* @__PURE__ */ jsx("div", { className: "col-span-2 text-center", children: "Email" }),
|
|
21545
|
+
/* @__PURE__ */ jsx("div", { className: "col-span-2 text-center", children: "Push" })
|
|
21546
|
+
] }),
|
|
21547
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-8 py-4", children: NOTIFICATION_CATEGORIES.map((category) => /* @__PURE__ */ jsxs("section", { children: [
|
|
21548
|
+
/* @__PURE__ */ jsx("h2", { className: "mb-6 text-sm font-semibold text-slate-900", children: category.name }),
|
|
21549
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-4", children: category.types.map((notifType) => /* @__PURE__ */ jsxs("div", { className: "group grid grid-cols-1 sm:grid-cols-12 gap-y-3 sm:gap-x-4 items-start sm:items-center", children: [
|
|
21550
|
+
/* @__PURE__ */ jsxs("div", { className: "col-span-8 pr-4", children: [
|
|
21551
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
21552
|
+
/* @__PURE__ */ jsx("span", { className: `text-sm font-medium ${notifType.isComingSoon ? "text-slate-400" : "text-slate-700"}`, children: notifType.label }),
|
|
21553
|
+
notifType.isComingSoon && /* @__PURE__ */ jsx("span", { className: "rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-slate-500", children: "Soon" })
|
|
21554
|
+
] }),
|
|
21555
|
+
/* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-slate-500", children: notifType.description })
|
|
21736
21556
|
] }),
|
|
21737
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
21738
|
-
/* @__PURE__ */
|
|
21739
|
-
|
|
21740
|
-
{
|
|
21741
|
-
variant: "outline-solid",
|
|
21742
|
-
size: "sm",
|
|
21743
|
-
onClick: () => disableAllChannel("email"),
|
|
21744
|
-
className: "rounded-xl border-slate-200 hover:bg-slate-50",
|
|
21745
|
-
children: "Disable All Emails"
|
|
21746
|
-
}
|
|
21747
|
-
),
|
|
21748
|
-
/* @__PURE__ */ jsx(
|
|
21749
|
-
Button,
|
|
21750
|
-
{
|
|
21751
|
-
variant: "outline-solid",
|
|
21752
|
-
size: "sm",
|
|
21753
|
-
onClick: () => disableAllChannel("push"),
|
|
21754
|
-
className: "rounded-xl border-slate-200 hover:bg-slate-50",
|
|
21755
|
-
children: "Disable All Push"
|
|
21756
|
-
}
|
|
21757
|
-
)
|
|
21758
|
-
] })
|
|
21759
|
-
] }),
|
|
21760
|
-
/* @__PURE__ */ jsx(AnimatePresence, { children: hasChanges && /* @__PURE__ */ jsx(
|
|
21761
|
-
motion.div,
|
|
21762
|
-
{
|
|
21763
|
-
initial: { opacity: 0, y: 100 },
|
|
21764
|
-
animate: { opacity: 1, y: 0 },
|
|
21765
|
-
exit: { opacity: 0, y: 100 },
|
|
21766
|
-
className: "fixed bottom-10 left-0 right-0 flex justify-center z-50 pointer-events-none",
|
|
21767
|
-
children: /* @__PURE__ */ jsxs("div", { className: "pointer-events-auto px-6 py-4 bg-secondary shadow-lg rounded-3xl flex items-center gap-8 max-w-xl mx-auto transform hover:scale-[1.02] transition-all duration-300 ease-out border border-white/10", children: [
|
|
21768
|
-
/* @__PURE__ */ jsxs("div", { className: "hidden sm:block", children: [
|
|
21769
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-bold text-white leading-tight tracking-wide italic", children: "Changes Pending" }),
|
|
21770
|
-
/* @__PURE__ */ jsx("p", { className: "text-[11px] text-white/60 font-medium", children: "Click to synchronize with account" })
|
|
21771
|
-
] }),
|
|
21557
|
+
/* @__PURE__ */ jsxs("div", { className: "col-span-4 grid grid-cols-2 gap-4", children: [
|
|
21558
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between sm:justify-center", children: [
|
|
21559
|
+
/* @__PURE__ */ jsx("span", { className: "sm:hidden text-xs text-slate-400", children: "Email" }),
|
|
21772
21560
|
/* @__PURE__ */ jsx(
|
|
21773
|
-
|
|
21561
|
+
Switch,
|
|
21774
21562
|
{
|
|
21775
|
-
|
|
21776
|
-
|
|
21777
|
-
disabled:
|
|
21778
|
-
|
|
21779
|
-
|
|
21780
|
-
|
|
21563
|
+
checked: getChannelSetting(notifType.type, "email"),
|
|
21564
|
+
onChange: (checked) => updateChannelSetting(notifType.type, "email", checked),
|
|
21565
|
+
disabled: notifType.isComingSoon
|
|
21566
|
+
}
|
|
21567
|
+
)
|
|
21568
|
+
] }),
|
|
21569
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between sm:justify-center", children: [
|
|
21570
|
+
/* @__PURE__ */ jsx("span", { className: "sm:hidden text-xs text-slate-400", children: "Push" }),
|
|
21571
|
+
/* @__PURE__ */ jsx(
|
|
21572
|
+
Switch,
|
|
21573
|
+
{
|
|
21574
|
+
checked: getChannelSetting(notifType.type, "push"),
|
|
21575
|
+
onChange: (checked) => updateChannelSetting(notifType.type, "push", checked),
|
|
21576
|
+
disabled: notifType.isComingSoon
|
|
21781
21577
|
}
|
|
21782
21578
|
)
|
|
21783
21579
|
] })
|
|
21580
|
+
] })
|
|
21581
|
+
] }, notifType.type)) })
|
|
21582
|
+
] }, category.name)) }),
|
|
21583
|
+
/* @__PURE__ */ jsx("div", { className: "mt-12 border-t border-slate-100 pt-8 text-center sm:text-left", children: /* @__PURE__ */ jsx(
|
|
21584
|
+
Button,
|
|
21585
|
+
{
|
|
21586
|
+
variant: "ghost",
|
|
21587
|
+
className: "text-xs text-slate-400 hover:text-red-600 px-0",
|
|
21588
|
+
onClick: () => {
|
|
21589
|
+
if (confirm("Are you sure you want to disable all notifications?")) {
|
|
21590
|
+
localSettings?.preferences ? [...localSettings.preferences] : [];
|
|
21591
|
+
alert("Feature to disable all coming in next update");
|
|
21592
|
+
}
|
|
21593
|
+
},
|
|
21594
|
+
children: "Disable all notifications"
|
|
21595
|
+
}
|
|
21596
|
+
) }),
|
|
21597
|
+
hasChanges && /* @__PURE__ */ jsxs("div", { className: "bg-white/80 backdrop-blur-sm fixed bottom-6 left-1/2 -translate-x-1/2 z-50 rounded-xl shadow-lg border border-slate-200 p-2 px-4 flex items-center gap-4 animate-in slide-in-from-bottom-2 fade-in duration-300", children: [
|
|
21598
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-slate-600", children: "Unsaved changes" }),
|
|
21599
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-slate-200" }),
|
|
21600
|
+
/* @__PURE__ */ jsx(
|
|
21601
|
+
Button,
|
|
21602
|
+
{
|
|
21603
|
+
onClick: handleSave,
|
|
21604
|
+
isLoading: isSaving,
|
|
21605
|
+
disabled: isSaving,
|
|
21606
|
+
variant: "primary",
|
|
21607
|
+
className: "h-8 rounded-lg px-4 text-xs font-medium bg-black text-white bg-slate-800 hover:bg-slate-700",
|
|
21608
|
+
children: "Save"
|
|
21784
21609
|
}
|
|
21785
|
-
)
|
|
21610
|
+
)
|
|
21786
21611
|
] })
|
|
21787
21612
|
] });
|
|
21788
21613
|
}
|