Standardize the healch check form between the two

This commit is contained in:
Owen
2026-04-16 16:20:30 -07:00
parent 5fcb80a193
commit a9d68bd0cf
8 changed files with 462 additions and 552 deletions

View File

@@ -25,16 +25,19 @@ type HealthCheckFormFieldsProps = {
form: UseFormReturn<any>;
onFieldChange?: (fieldName: string, value: any) => void;
showNameField?: boolean;
hideEnabledField?: boolean;
};
export function HealthCheckFormFields({
form,
onFieldChange,
showNameField
showNameField,
hideEnabledField
}: HealthCheckFormFieldsProps) {
const t = useTranslations();
const watchedEnabled = form.watch("hcEnabled");
const showFields = hideEnabledField || watchedEnabled;
const watchedMode = form.watch("hcMode");
const handleChange = (fieldName: string, value: any, fieldOnChange: (v: any) => void) => {
@@ -67,30 +70,32 @@ export function HealthCheckFormFields({
)}
{/* Enable Health Checks */}
<FormField
control={form.control}
name="hcEnabled"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<FormLabel>{t("enableHealthChecks")}</FormLabel>
<FormDescription>
{t("enableHealthChecksDescription")}
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={(value) =>
handleChange("hcEnabled", value, field.onChange)
}
/>
</FormControl>
</FormItem>
)}
/>
{!hideEnabledField && (
<FormField
control={form.control}
name="hcEnabled"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<FormLabel>{t("enableHealthChecks")}</FormLabel>
<FormDescription>
{t("enableHealthChecksDescription")}
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={(value) =>
handleChange("hcEnabled", value, field.onChange)
}
/>
</FormControl>
</FormItem>
)}
/>
)}
{watchedEnabled && (
{showFields && (
<div className="space-y-4">
{/* Mode */}
<FormField