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 {
|
try {
|
||||||
const result = await registerNotification();
|
const result = await registerNotification();
|
||||||
if ("error" in result && result.error) {
|
if ("error" in result && result.error) {
|
||||||
console.error(
|
console.error("Failed to unregister previous notifications:", result.error);
|
||||||
"Failed to unregister previous notifications:",
|
|
||||||
result.error
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
setPushEnabled(true);
|
setPushEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
@ -132,15 +129,10 @@ export default function NotificationSettings() {
|
||||||
|
|
||||||
const currentSubscriptionId = localStorage.getItem(STORAGE_KEY);
|
const currentSubscriptionId = localStorage.getItem(STORAGE_KEY);
|
||||||
const currentSubscription = notifications.find(
|
const currentSubscription = notifications.find(
|
||||||
(sub) => sub.id.toString() === currentSubscriptionId
|
(sub) => sub.id === currentSubscriptionId
|
||||||
);
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEvents(currentSubscription?.events || []);
|
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]);
|
}, [currentSubscription]);
|
||||||
|
|
||||||
async function handleDelete(subscriptionId: string) {
|
async function handleDelete(subscriptionId: string) {
|
||||||
|
|
@ -229,9 +221,9 @@ export default function NotificationSettings() {
|
||||||
{currentSubscription && (
|
{currentSubscription && (
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Configurer vos notifications</CardTitle>
|
<CardTitle>Select Notification Events</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
Choisissez les événements qui déclencheront une notification.
|
Choose which events you want to receive notifications for
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
|
|
@ -265,7 +257,7 @@ export default function NotificationSettings() {
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
updateSubscription(
|
updateSubscription(
|
||||||
currentSubscription.id,
|
currentSubscription.id,
|
||||||
events.filter((e) => e.enabled).map((e) => e.id)
|
events.map((event) => event.id)
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
toast.success(
|
toast.success(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue