refactor: use correct namings

This commit is contained in:
Nicolas Meienberger
2025-11-02 16:05:22 +01:00
parent 3befa127d7
commit 8f447ac58d
10 changed files with 505 additions and 53 deletions

View File

@@ -4,8 +4,7 @@ import { type } from "arktype";
import { useForm } from "react-hook-form";
import { listRepositoriesOptions } from "~/api-client/@tanstack/react-query.gen";
import { RepositoryIcon } from "~/components/repository-icon";
import { Button } from "~/components/ui/button";
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "~/components/ui/card";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "~/components/ui/card";
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "~/components/ui/form";
import { Input } from "~/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "~/components/ui/select";
@@ -46,6 +45,7 @@ type Props = {
onSubmit: (data: BackupScheduleFormValues) => void;
loading?: boolean;
summaryContent?: React.ReactNode;
formId: string;
};
const backupScheduleToFormValues = (schedule?: BackupSchedule): BackupScheduleFormValues | undefined => {
@@ -73,7 +73,7 @@ const backupScheduleToFormValues = (schedule?: BackupSchedule): BackupScheduleFo
};
};
export const CreateScheduleForm = ({ initialValues, onSubmit, volume, loading }: Props) => {
export const CreateScheduleForm = ({ initialValues, formId, onSubmit, volume }: Props) => {
const form = useForm<BackupScheduleFormValues>({
resolver: arktypeResolver(cleanSchema as unknown as typeof formSchema),
defaultValues: backupScheduleToFormValues(initialValues),
@@ -91,6 +91,7 @@ export const CreateScheduleForm = ({ initialValues, onSubmit, volume, loading }:
<form
onSubmit={form.handleSubmit(onSubmit)}
className="grid gap-4 xl:grid-cols-[minmax(0,_2.3fr)_minmax(320px,_1fr)]"
id={formId}
>
<div className="grid gap-4">
<Card>
@@ -335,11 +336,6 @@ export const CreateScheduleForm = ({ initialValues, onSubmit, volume, loading }:
)}
/>
</CardContent>
<CardFooter className="border-t pt-6">
<Button type="submit" className="ml-auto" variant="default" loading={loading}>
{initialValues ? "Update schedule" : "Create schedule"}
</Button>
</CardFooter>
</Card>
</div>
<div className="h-full">

View File

@@ -58,7 +58,9 @@ export const ScheduleSummary = (props: Props) => {
<CardHeader className="flex flex-row items-center justify-between gap-4">
<div>
<CardTitle>Backup schedule</CardTitle>
<CardDescription>Automated backup configuration for {volume.name}</CardDescription>
<CardDescription>
Automated backup configuration for volume <strong className="text-strong-accent">{volume.name}</strong>
</CardDescription>
</div>
<div className="flex items-center gap-2">
<OnOff isOn={schedule.enabled} toggle={handleToggleEnabled} enabledLabel="Enabled" disabledLabel="Paused" />
@@ -79,7 +81,7 @@ export const ScheduleSummary = (props: Props) => {
</div>
<div>
<p className="text-xs uppercase text-muted-foreground">Repository</p>
<p className="font-medium">{summary.repositoryLabel}</p>
<p className="font-medium">{repository.name}</p>
</div>
<div>
<p className="text-xs uppercase text-muted-foreground">Last backup</p>