aboutsummaryrefslogtreecommitdiffstats
path: root/src/views/Settings/NotificationSetting.jsx
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-06-30 18:55:39 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-06-30 18:55:39 -0400
commit2657469964e24ffbeb905024532120395f6e797c (patch)
tree2fe9db8a4ecfa92d854ca94f7586d81163c8bd25 /src/views/Settings/NotificationSetting.jsx
downloaddonetick-frontend-2657469964e24ffbeb905024532120395f6e797c.tar.gz
donetick-frontend-2657469964e24ffbeb905024532120395f6e797c.tar.bz2
donetick-frontend-2657469964e24ffbeb905024532120395f6e797c.zip
move to Donetick Org, First commit frontend
Diffstat (limited to '')
-rw-r--r--src/views/Settings/NotificationSetting.jsx90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/views/Settings/NotificationSetting.jsx b/src/views/Settings/NotificationSetting.jsx
new file mode 100644
index 0000000..4ead3b9
--- /dev/null
+++ b/src/views/Settings/NotificationSetting.jsx
@@ -0,0 +1,90 @@
+import { Button, Divider, Input, Option, Select, Typography } from '@mui/joy'
+import { useContext, useEffect, useState } from 'react'
+import { UserContext } from '../../contexts/UserContext'
+import { GetUserProfile, UpdateUserDetails } from '../../utils/Fetcher'
+
+const NotificationSetting = () => {
+ const { userProfile, setUserProfile } = useContext(UserContext)
+ useEffect(() => {
+ if (!userProfile) {
+ GetUserProfile().then(resp => {
+ resp.json().then(data => {
+ setUserProfile(data.res)
+ setChatID(data.res.chatID)
+ })
+ })
+ }
+ }, [])
+ const [chatID, setChatID] = useState(userProfile?.chatID)
+
+ return (
+ <div className='grid gap-4 py-4' id='notifications'>
+ <Typography level='h3'>Notification Settings</Typography>
+ <Divider />
+ <Typography level='body-md'>Manage your notification settings</Typography>
+
+ <Select defaultValue='telegram' sx={{ maxWidth: '200px' }} disabled>
+ <Option value='telegram'>Telegram</Option>
+ <Option value='discord'>Discord</Option>
+ </Select>
+
+ <Typography level='body-xs'>
+ You need to initiate a message to the bot in order for the Telegram
+ notification to work{' '}
+ <a
+ style={{
+ textDecoration: 'underline',
+ color: '#0891b2',
+ }}
+ href='https://t.me/DonetickBot'
+ >
+ Click here
+ </a>{' '}
+ to start a chat
+ </Typography>
+
+ <Input
+ value={chatID}
+ onChange={e => setChatID(e.target.value)}
+ placeholder='User ID / Chat ID'
+ sx={{
+ width: '200px',
+ }}
+ />
+ <Typography mt={0} level='body-xs'>
+ If you don't know your Chat ID, start chat with userinfobot and it will
+ send you your Chat ID.{' '}
+ <a
+ style={{
+ textDecoration: 'underline',
+ color: '#0891b2',
+ }}
+ href='https://t.me/userinfobot'
+ >
+ Click here
+ </a>{' '}
+ to start chat with userinfobot{' '}
+ </Typography>
+
+ <Button
+ sx={{
+ width: '110px',
+ mb: 1,
+ }}
+ onClick={() => {
+ UpdateUserDetails({
+ chatID: Number(chatID),
+ }).then(resp => {
+ resp.json().then(data => {
+ setUserProfile(data)
+ })
+ })
+ }}
+ >
+ Save
+ </Button>
+ </div>
+ )
+}
+
+export default NotificationSetting