diff --git a/Containers/UserSettings/AppriseAlertSettings/AppriseAlertSettings.js b/Containers/UserSettings/AppriseAlertSettings/AppriseAlertSettings.js index 3696690..0ee0bfe 100644 --- a/Containers/UserSettings/AppriseAlertSettings/AppriseAlertSettings.js +++ b/Containers/UserSettings/AppriseAlertSettings/AppriseAlertSettings.js @@ -10,6 +10,8 @@ import { useForm } from 'react-hook-form'; //Components import Error from '../../../Components/UI/Error/Error'; import Switch from '../../../Components/UI/Switch/Switch'; +import AppriseURLs from './AppriseURLs/AppriseURLs'; +import AppriseMode from './AppriseMode/AppriseMode'; export default function AppriseAlertSettings() { //Var @@ -29,19 +31,27 @@ export default function AppriseAlertSettings() { const { register, handleSubmit, - formState: { errors, isSubmitting, isValid }, + formState: { errors }, + } = useForm({ mode: 'onBlur' }); + + const { + register: register2, + handleSubmit: handleSubmit2, + formState: { errors: errors2 }, } = useForm({ mode: 'onBlur' }); ////State const [checkIsLoading, setCheckIsLoading] = useState(true); const [testIsLoading, setTestIsLoading] = useState(false); const [formIsLoading, setFormIsLoading] = useState(false); - const [formIsSaved, setFormIsSaved] = useState(false); + const [urlsFormIsSaved, setUrlsFormIsSaved] = useState(false); + const [modeFormIsSaved, setModeFormIsSaved] = useState(false); const [error, setError] = useState(); const [disabled, setDisabled] = useState(false); const [checked, setChecked] = useState(); const [info, setInfo] = useState(false); const [appriseServicesList, setAppriseServicesList] = useState(); + const [displayStatelessURL, setDisplayStatelessURL] = useState(false); ////LifeCycle //Component did mount @@ -62,33 +72,6 @@ export default function AppriseAlertSettings() { } }; getAppriseAlert(); - - //Initial fetch to build the list of Apprise Services enabled - const getAppriseServices = async () => { - try { - const response = await fetch( - '/api/account/getAppriseServices', - { - method: 'GET', - headers: { - 'Content-type': 'application/json', - }, - } - ); - let servicesArray = (await response.json()).appriseServices; - const AppriseServicesListToText = () => { - let list = ''; - for (let service of servicesArray) { - list += service + '\n'; - } - return list; - }; - setAppriseServicesList(AppriseServicesListToText()); - } catch (error) { - console.log('Fetching Apprise services list failed.'); - } - }; - getAppriseServices(); }, []); ////Functions @@ -124,38 +107,6 @@ export default function AppriseAlertSettings() { } }; - //Form submit handler to modify Apprise services - const formSubmitHandler = async (data) => { - console.log(data); - // //Remove old error - // setError(); - // //Loading button on submit to avoid multiple send. - // setFormIsLoading(true); - // //POST API to update Apprise Services - // const response = await fetch('/api/account/updateAppriseServices', { - // method: 'PUT', - // headers: { - // 'Content-type': 'application/json', - // }, - // body: JSON.stringify(data), - // }); - // const result = await response.json(); - - // if (!response.ok) { - // setFormIsLoading(false); - // setError(result.message); - // setTimeout(() => setError(), 4000); - // } else { - // setFormIsLoading(false); - // setInfo(true); - // toast.success('Email edited !', toastOptions); - // } - - //TEST - setFormIsSaved(true); - setTimeout(() => setFormIsSaved(false), 3000); - }; - return ( <> {/* APPRISE ALERT */} @@ -165,6 +116,7 @@ export default function AppriseAlertSettings() {
+ {/* NOTIFY SWITCH */} {checkIsLoading ? ( )} -
-
- Apprise URLs -
-
- {formIsLoading && ( - - )} - {formIsSaved && ( -
- ✅ Apprise configuration has been saved. -
- )} -
-
-
-