Compare commits
No commits in common. "aa88fbda44915062fe2beae8f9c517c2660a223f" and "67407a1426395fa7947052f1067da3a1199921f9" have entirely different histories.
aa88fbda44
...
67407a1426
1 changed files with 5 additions and 13 deletions
|
|
@ -98,10 +98,7 @@ export default function NotificationSettings() {
|
|||
try {
|
||||
const result = await registerNotification();
|
||||
if ("error" in result && result.error) {
|
||||
console.error(
|
||||
"Failed to unregister previous notifications:",
|
||||
result.error
|
||||
);
|
||||
console.error("Failed to unregister previous notifications:", result.error);
|
||||
} else {
|
||||
setPushEnabled(true);
|
||||
}
|
||||
|
|
@ -132,15 +129,10 @@ export default function NotificationSettings() {
|
|||
|
||||
const currentSubscriptionId = localStorage.getItem(STORAGE_KEY);
|
||||
const currentSubscription = notifications.find(
|
||||
(sub) => sub.id.toString() === currentSubscriptionId
|
||||
(sub) => sub.id === currentSubscriptionId
|
||||
);
|
||||
useEffect(() => {
|
||||
setEvents(currentSubscription?.events || []);
|
||||
// Remove pushEnabled if no current subscription (i.e., user unsubscribed)
|
||||
if (!isLoading && !isError && pushEnabled && !currentSubscription) {
|
||||
setPushEnabled(false);
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
}
|
||||
}, [currentSubscription]);
|
||||
|
||||
async function handleDelete(subscriptionId: string) {
|
||||
|
|
@ -229,9 +221,9 @@ export default function NotificationSettings() {
|
|||
{currentSubscription && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Configurer vos notifications</CardTitle>
|
||||
<CardTitle>Select Notification Events</CardTitle>
|
||||
<CardDescription>
|
||||
Choisissez les événements qui déclencheront une notification.
|
||||
Choose which events you want to receive notifications for
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
|
|
@ -265,7 +257,7 @@ export default function NotificationSettings() {
|
|||
onClick={() =>
|
||||
updateSubscription(
|
||||
currentSubscription.id,
|
||||
events.filter((e) => e.enabled).map((e) => e.id)
|
||||
events.map((event) => event.id)
|
||||
)
|
||||
.then(() => {
|
||||
toast.success(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue