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