chore: fix notification events
All checks were successful
Deploy to Netlify / Deploy to Netlify (push) Successful in 1m26s

This commit is contained in:
Nathan Lamy 2025-08-20 12:46:53 +02:00
parent 2e12b2cec7
commit aa88fbda44

View file

@ -132,11 +132,12 @@ 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 === currentSubscriptionId (sub) => sub.id.toString() === currentSubscriptionId
); );
useEffect(() => { useEffect(() => {
setEvents(currentSubscription?.events || []); setEvents(currentSubscription?.events || []);
if (pushEnabled && !currentSubscription) { // Remove pushEnabled if no current subscription (i.e., user unsubscribed)
if (!isLoading && !isError && pushEnabled && !currentSubscription) {
setPushEnabled(false); setPushEnabled(false);
localStorage.removeItem(STORAGE_KEY); localStorage.removeItem(STORAGE_KEY);
} }
@ -228,9 +229,9 @@ export default function NotificationSettings() {
{currentSubscription && ( {currentSubscription && (
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>Select Notification Events</CardTitle> <CardTitle>Configurer vos notifications</CardTitle>
<CardDescription> <CardDescription>
Choose which events you want to receive notifications for Choisissez les événements qui déclencheront une notification.
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
@ -264,7 +265,7 @@ export default function NotificationSettings() {
onClick={() => onClick={() =>
updateSubscription( updateSubscription(
currentSubscription.id, currentSubscription.id,
events.map((event) => event.id) events.filter((e) => e.enabled).map((e) => e.id)
) )
.then(() => { .then(() => {
toast.success( toast.success(