import { Button } from '@/components/ui/Button'; import { Input } from '@/components/ui/Input'; import React, { useEffect } from 'react'; import { useForm } from 'react-hook-form'; import validator from 'validator'; export type SettingsFormValues = { dnsIp?: string; internalIp?: string; appsRepoUrl?: string; domain?: string; storagePath?: string; }; interface IProps { onSubmit: (values: SettingsFormValues) => void; initalValues?: Partial; loading?: boolean; submitErrors?: Record; } const validateFields = (values: SettingsFormValues) => { const errors: { [K in keyof SettingsFormValues]?: string } = {}; if (values.dnsIp && !validator.isIP(values.dnsIp)) { errors.dnsIp = 'Invalid IP address'; } if (values.internalIp && values.internalIp !== 'localhost' && !validator.isIP(values.internalIp)) { errors.internalIp = 'Invalid IP address'; } if (values.appsRepoUrl && !validator.isURL(values.appsRepoUrl)) { errors.appsRepoUrl = 'Invalid URL'; } if (values.domain && !validator.isFQDN(values.domain)) { errors.domain = 'Invalid domain'; } return errors; }; export const SettingsForm = (props: IProps) => { const { onSubmit, initalValues, loading, submitErrors } = props; const { register, handleSubmit, setValue, setError, formState: { errors, isDirty }, } = useForm(); useEffect(() => { if (initalValues && !isDirty) { Object.entries(initalValues).forEach(([key, value]) => { setValue(key as keyof SettingsFormValues, value); }); } }, [initalValues, isDirty, setValue]); useEffect(() => { if (submitErrors) { Object.entries(submitErrors).forEach(([key, value]) => { setError(key as keyof SettingsFormValues, { message: value }); }); } }, [submitErrors, setError]); const validate = (values: SettingsFormValues) => { const validationErrors = validateFields(values); Object.entries(validationErrors).forEach(([key, value]) => { if (value) { setError(key as keyof SettingsFormValues, { message: value }); } }); if (Object.keys(validationErrors).length === 0) { onSubmit(values); } }; return (

General settings

This will update your settings.json file. Make sure you know what you are doing before updating these values.

Make sure this domain contains a A record pointing to your IP.
IP address your server is listening on. Keep localhost for default
URL to the apps repository.
Path to the storage directory. Keep empty for default
); };