-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Feature/disable email notifications #903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Eshwar1212-maker
wants to merge
9
commits into
gitroomhq:main
Choose a base branch
from
Eshwar1212-maker:feature/disable-email-notifications
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2ee4ed2
Added API CRUD endpoint to toggle users email notificatios
Eshwar1212-maker 3e4e01b
Finishing feature for disabling email noti's
Eshwar1212-maker 15be1e0
Pushing email notifications component
Eshwar1212-maker b6aacb9
Merge main into feature/disable-email-notifications
Eshwar1212-maker 3a2e624
Removed unnecesarry comments
Eshwar1212-maker 7a57fbd
Update apps/backend/src/api/routes/settings.controller.ts
Eshwar1212-maker 3fd14be
Update libraries/nestjs-libraries/src/database/prisma/notifications/n…
Eshwar1212-maker fe32679
Fixed formmating issues copilot showed on the review
Eshwar1212-maker 1f2a709
Changed a tab in settings from email notificaitons to notifications
Eshwar1212-maker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
apps/frontend/src/components/settings/email.notifications.component.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React, { FC, useCallback } from 'react'; | ||
import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; | ||
import useSWR from 'swr'; | ||
import { Button } from '@gitroom/react/form/button'; | ||
import { useToaster } from '@gitroom/react/toaster/toaster'; | ||
import { useT } from '@gitroom/react/translation/get.transation.service.client'; | ||
|
||
export const EmailNotificationsComponent: FC = () => { | ||
const fetch = useFetch(); | ||
const toast = useToaster(); | ||
const t = useT(); | ||
|
||
const load = useCallback(async () => { | ||
return (await fetch('/settings/email-notifications')).json(); | ||
}, []); | ||
|
||
const { data, mutate } = useSWR('email-notifications', load); | ||
|
||
const toggle = useCallback(async () => { | ||
try { | ||
const res = await fetch('/settings/email-notifications', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ | ||
enabled: !data?.enabled, | ||
}), | ||
}); | ||
|
||
if (!res.ok) throw new Error('Failed to update'); | ||
|
||
toast.show( | ||
t( | ||
'email_notifications_updated', | ||
'Email notifications updated successfully' | ||
), | ||
'success' | ||
); | ||
mutate(); | ||
} catch (err) { | ||
toast.show( | ||
t('email_notifications_failed', 'Failed to update email notifications'), | ||
'warning' | ||
); | ||
} | ||
}, [data, mutate]); | ||
|
||
return ( | ||
<div className="flex flex-col"> | ||
<h3 className="text-[20px]"> | ||
{t('email_notifications', 'Email Notifications')} | ||
</h3> | ||
<div className="text-customColor18 mt-[4px]"> | ||
{t( | ||
'control_email_settings', | ||
'Enable or disable whether you want to receive email notifications.' | ||
)} | ||
</div> | ||
<div className="my-[16px] bg-sixth border-fifth border rounded-[4px] p-[24px] flex items-center justify-between"> | ||
<div className="flex flex-col"> | ||
<div className="text-[16px] font-medium"> | ||
{t('receive_emails', 'Receive emails?')} | ||
</div> | ||
<div className="text-customColor18 text-sm"> | ||
{t( | ||
'receive_emails_description', | ||
'You’ll be notified by email when necessary updates occur.' | ||
)} | ||
</div> | ||
</div> | ||
<Button onClick={toggle}> | ||
{data?.enabled ? t('disable', 'Disable') : t('enable', 'Enable')} | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.