diff --git a/application/src/components/services/add-service/types.ts b/application/src/components/services/add-service/types.ts index d3f8033..f12e623 100644 --- a/application/src/components/services/add-service/types.ts +++ b/application/src/components/services/add-service/types.ts @@ -25,6 +25,10 @@ export const useServiceSchema = () => { type: z.enum(["http", "ping", "tcp", "dns"]), url: z.string() .min(1, t("urlDomainHostRequired")) + .refine( + (value) => !/\s/.test(value), + t("spacesNotAllowed") + ) .refine( (value) => value.trim().length > 0, t("enterValidUrlHostnameDomain") diff --git a/application/src/components/ssl-domain/AddSSLCertificateForm.tsx b/application/src/components/ssl-domain/AddSSLCertificateForm.tsx index f13fd5d..c601acb 100644 --- a/application/src/components/ssl-domain/AddSSLCertificateForm.tsx +++ b/application/src/components/ssl-domain/AddSSLCertificateForm.tsx @@ -17,27 +17,33 @@ import { alertConfigService, AlertConfiguration } from "@/services/alertConfigSe import { sslNotificationTemplateService, SslNotificationTemplate } from "@/services/sslNotificationTemplateService"; import { useLanguage } from "@/contexts/LanguageContext"; -const formSchema = z.object({ - domain: z.string().min(1, "Domain is required"), - warning_threshold: z.coerce.number().int().min(1).max(365), - expiry_threshold: z.coerce.number().int().min(1).max(30), - notification_channels: z.array(z.string()).optional(), - alert_template: z.string().optional(), - check_interval: z.coerce.number().int().min(1).max(30).optional() -}); - interface AddSSLCertificateFormProps { onSubmit: (data: AddSSLCertificateDto) => Promise; onCancel: () => void; isPending?: boolean; } -export const AddSSLCertificateForm = ({ - onSubmit, +export const AddSSLCertificateForm = ({ + onSubmit, onCancel, - isPending = false + isPending = false }: AddSSLCertificateFormProps) => { const { t } = useLanguage(); + + const formSchema = z.object({ + domain: z.string() + .min(1, t("domain") + " is required") + .refine( + (value) => !/\s/.test(value), + t("spacesNotAllowed") + ), + warning_threshold: z.coerce.number().int().min(1).max(365), + expiry_threshold: z.coerce.number().int().min(1).max(30), + notification_channels: z.array(z.string()).optional(), + alert_template: z.string().optional(), + check_interval: z.coerce.number().int().min(1).max(30).optional() + }); + const [alertConfigs, setAlertConfigs] = useState([]); const [sslTemplates, setSslTemplates] = useState([]); const [isLoading, setIsLoading] = useState(false); @@ -78,7 +84,7 @@ export const AddSSLCertificateForm = ({ setIsLoading(false); } }; - + fetchData(); }, [t]); @@ -89,16 +95,16 @@ export const AddSSLCertificateForm = ({ domain: values.domain, warning_threshold: values.warning_threshold, expiry_threshold: values.expiry_threshold, - notification_channel: values.notification_channels && values.notification_channels.length > 0 - ? values.notification_channels.join(',') + notification_channel: values.notification_channels && values.notification_channels.length > 0 + ? values.notification_channels.join(',') : '', - notification_id: values.notification_channels && values.notification_channels.length > 0 - ? values.notification_channels.join(',') + notification_id: values.notification_channels && values.notification_channels.length > 0 + ? values.notification_channels.join(',') : '', template_id: values.alert_template && values.alert_template !== 'none' ? values.alert_template : '', check_interval: values.check_interval }; - + await onSubmit(certData); form.reset(); } catch (error) { @@ -136,7 +142,7 @@ export const AddSSLCertificateForm = ({ )} /> - +
)} /> - )} /> - {t('notificationChannel')} (Multi-select)
-