Fix #140 and add notification type as webhook only

This commit is contained in:
Mo Tarbin 2025-02-23 19:42:04 -05:00
parent 2162b8c22d
commit e359b1c0a4
2 changed files with 40 additions and 52 deletions

View file

@ -150,18 +150,7 @@ const NotificationSetting = () => {
<Divider /> <Divider />
<Typography level='body-md'>Manage your Device Notificaiton</Typography> <Typography level='body-md'>Manage your Device Notificaiton</Typography>
<FormControl <FormControl orientation='horizontal'>
orientation='horizontal'
sx={{ width: 400, justifyContent: 'space-between' }}
>
<div>
<FormLabel>Device Notification</FormLabel>
<FormHelperText sx={{ mt: 0 }}>
{Capacitor.isNativePlatform()
? 'Receive notification on your device when a task is due'
: 'This feature is only available on mobile devices'}{' '}
</FormHelperText>
</div>
<Switch <Switch
disabled={!Capacitor.isNativePlatform()} disabled={!Capacitor.isNativePlatform()}
checked={deviceNotification} checked={deviceNotification}
@ -184,15 +173,16 @@ const NotificationSetting = () => {
}} }}
color={deviceNotification ? 'success' : 'neutral'} color={deviceNotification ? 'success' : 'neutral'}
variant={deviceNotification ? 'solid' : 'outlined'} variant={deviceNotification ? 'solid' : 'outlined'}
endDecorator={deviceNotification ? 'On' : 'Off'} sx={{ mr: 1 }}
slotProps={{
endDecorator: {
sx: {
minWidth: 24,
},
},
}}
/> />
<div>
<FormLabel>Device Notification</FormLabel>
<FormHelperText sx={{ mt: 0 }}>
{Capacitor.isNativePlatform()
? 'Receive notification on your device when a task is due'
: 'This feature is only available on mobile devices'}{' '}
</FormHelperText>
</div>
</FormControl> </FormControl>
{deviceNotification && ( {deviceNotification && (
<Card> <Card>
@ -329,17 +319,9 @@ const NotificationSetting = () => {
Notificaiton through other platform like Telegram or Pushover Notificaiton through other platform like Telegram or Pushover
</Typography> </Typography>
<FormControl <FormControl orientation='horizontal'>
orientation='horizontal'
sx={{ width: 400, justifyContent: 'space-between' }}
>
<div>
<FormLabel>Custom Notification</FormLabel>
<FormHelperText sx={{ mt: 0 }}>
Receive notification on other platform
</FormHelperText>
</div>
<Switch <Switch
sx={{ mr: 1 }}
checked={chatID !== 0} checked={chatID !== 0}
onClick={event => { onClick={event => {
event.preventDefault() event.preventDefault()
@ -360,15 +342,19 @@ const NotificationSetting = () => {
}} }}
color={chatID !== 0 ? 'success' : 'neutral'} color={chatID !== 0 ? 'success' : 'neutral'}
variant={chatID !== 0 ? 'solid' : 'outlined'} variant={chatID !== 0 ? 'solid' : 'outlined'}
endDecorator={chatID !== 0 ? 'On' : 'Off'} // endDecorator={chatID !== 0 ? 'On' : 'Off'}
slotProps={{ slotProps={{
endDecorator: { endDecorator: {
sx: { sx: {},
minWidth: 24,
},
}, },
}} }}
/> />
<div>
<FormLabel>Custom Notification</FormLabel>
<FormHelperText sx={{ mt: 0 }}>
Receive notification on other platform
</FormHelperText>
</div>
</FormControl> </FormControl>
{chatID !== 0 && ( {chatID !== 0 && (
<Box <Box
@ -386,6 +372,7 @@ const NotificationSetting = () => {
<Option value='0'>None</Option> <Option value='0'>None</Option>
<Option value='1'>Telegram</Option> <Option value='1'>Telegram</Option>
<Option value='2'>Pushover</Option> <Option value='2'>Pushover</Option>
<Option value='3'>Webhook</Option>
</Select> </Select>
{notificationTarget === '1' && ( {notificationTarget === '1' && (
<> <>

View file

@ -357,10 +357,11 @@ const Settings = () => {
</Chip> </Chip>
)} )}
</FormHelperText> </FormHelperText>
<> </FormControl>
{webhookURL !== null && ( {webhookURL !== null && (
<Typography level='title-sm'> <Box>
Webhook URL <Typography level='title-sm'>Webhook URL</Typography>
<Input <Input
value={webhookURL ? webhookURL : ''} value={webhookURL ? webhookURL : ''}
onChange={e => setWebhookURL(e.target.value)} onChange={e => setWebhookURL(e.target.value)}
@ -370,10 +371,10 @@ const Settings = () => {
mb: 1, mb: 1,
}} }}
/> />
{webhookError && (
<Typography level='body-sm' color='danger'> <Typography level='body-sm' color='danger'>
{webhookError} {webhookError}
</Typography> </Typography>
</Typography>
)} )}
<Button <Button
variant='soft' variant='soft'
@ -391,8 +392,8 @@ const Settings = () => {
> >
Save Save
</Button> </Button>
</> </Box>
</FormControl> )}
</> </>
)} )}
</div> </div>