chore: fix notification events
All checks were successful
Deploy to Netlify / Deploy to Netlify (push) Successful in 1m26s
All checks were successful
Deploy to Netlify / Deploy to Netlify (push) Successful in 1m26s
This commit is contained in:
parent
2e12b2cec7
commit
aa88fbda44
1 changed files with 6 additions and 5 deletions
|
|
@ -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(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue