fix: correct typing issue (#1715)

* fix(ntfy): display the current value of auth and fix types

When using the username/password as auth method, the saved value was not displayed properly because
of a wrong property name introduced by a missing type.

* fix: correct typing issue

---------

Co-authored-by: gauthier-th <mail@gauthierth.fr>
This commit is contained in:
fallenbagel
2025-06-14 01:14:12 +05:00
committed by GitHub
parent d4a6cb268a
commit bb95c7009f

View File

@@ -6,6 +6,7 @@ import globalMessages from '@app/i18n/globalMessages';
import defineMessages from '@app/utils/defineMessages';
import { isValidURL } from '@app/utils/urlValidationHelper';
import { ArrowDownOnSquareIcon, BeakerIcon } from '@heroicons/react/24/outline';
import type { NotificationAgentNtfy } from '@server/lib/settings';
import axios from 'axios';
import { Field, Form, Formik } from 'formik';
import { useState } from 'react';
@@ -44,7 +45,7 @@ const NotificationsNtfy = () => {
data,
error,
mutate: revalidate,
} = useSWR('/api/v1/settings/notifications/ntfy');
} = useSWR<NotificationAgentNtfy>('/api/v1/settings/notifications/ntfy');
const NotificationsNtfySchema = Yup.object().shape({
url: Yup.string()
@@ -78,15 +79,15 @@ const NotificationsNtfy = () => {
return (
<Formik
initialValues={{
enabled: data.enabled,
types: data.types,
url: data.options.url,
topic: data.options.topic,
authMethodUsernamePassword: data.options.authMethod,
username: data.options.username,
password: data.options.password,
authMethodToken: data.options.authMethodToken,
token: data.options.token,
enabled: data?.enabled,
types: data?.types,
url: data?.options.url,
topic: data?.options.topic,
authMethodUsernamePassword: data?.options.authMethodUsernamePassword,
username: data?.options.username,
password: data?.options.password,
authMethodToken: data?.options.authMethodToken,
token: data?.options.token,
}}
validationSchema={NotificationsNtfySchema}
onSubmit={async (values) => {
@@ -302,7 +303,7 @@ const NotificationsNtfy = () => {
</div>
)}
<NotificationTypeSelector
currentTypes={values.enabled ? values.types : 0}
currentTypes={values.enabled ? values.types || 0 : 0}
onUpdate={(newTypes) => {
setFieldValue('types', newTypes);
setFieldTouched('types');