diff --git a/src/app/(dashboard)/dashboard/commits/add/page.tsx b/src/app/(dashboard)/dashboard/commits/add/page.tsx new file mode 100644 index 0000000..3bbcd70 --- /dev/null +++ b/src/app/(dashboard)/dashboard/commits/add/page.tsx @@ -0,0 +1,36 @@ +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; +import { Separator } from "@/components/ui/separator"; +import Breadcrumb from "@/components/breadcrumb"; +import CommitForm from "@/components/commit-form"; + +const breadcrumbItems = [ + { title: "Dashboard", link: "/dashboard" }, + { title: "Commits", link: "/dashboard/commits" }, + { title: "Create Commit" }, +]; + +export default function SettingsDisplayPage() { + return ( + +
+ +
+ + + + Create Commit + + + + + + + + +
+ +
+
+ ); +} diff --git a/src/components/commit-form.tsx b/src/components/commit-form.tsx new file mode 100644 index 0000000..7117d11 --- /dev/null +++ b/src/components/commit-form.tsx @@ -0,0 +1,360 @@ +"use client"; + +import { zodResolver } from "@hookform/resolvers/zod"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; + +import { Button } from "@/components/ui/button"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { toast } from "@/components/ui/use-toast"; +import { Input } from "./ui/input"; +import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover"; +import { CaretSortIcon, CheckIcon } from "@radix-ui/react-icons"; +import { + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, +} from "./ui/command"; +import { cn } from "@/lib/utils"; +import { CommandList } from "cmdk"; +import { useState } from "react"; + +const statuses = [ + "new", + "running", + "retry", + "skills_extracted", + "failed", + "too_big", +] as const; + +const evaluations = [ + "Uploaded at: 2023-09-20 00:00:00 - Uploader: jschultz@php.net - Developer: fabien@potencier.org - Status: finished", + "Uploaded at: 2023-09-27 00:00:00 - Uploader: jschultz@php.net - Developer: gamemaker0042@gmail.com - Status: finished", +] as const; + +const types = ["code", "merge"] as const; + +const displayFormSchema = z.object({ + id: z.string().trim().min(1, "ID is required"), + hash: z.string().trim().min(1, "Hash is required"), + status: z.string().trim().min(1, "Status is required"), + retryCount: z.string().trim().min(1, "Retry count is required"), + type: z.string().trim().min(1, "Type is required"), + evaluation: z.string().trim().min(1, "Evaluation is required"), + commitDate: z.string().refine((value) => /^\d{4}-\d{2}-\d{2}$/.test(value), { + message: "Commit date should be in the format YYYY-MM-DD", + }), +}); + +type DisplayFormValues = z.infer; + +// This can come from your database or API. +const defaultValues: Partial = { + id: "", + hash: "", + status: "", + retryCount: "", + type: "", + evaluation: "", + commitDate: "", +}; + +export default function CommitForm() { + const [isStatusPopoverOpen, setIsStatusPopoverOpen] = useState(false); + const [isTypePopoverOpen, setIsTypePopoverOpen] = useState(false); + const [isEvaluationPopoverOpen, setIsEvaluationPopoverOpen] = useState(false); + + const form = useForm({ + resolver: zodResolver(displayFormSchema), + defaultValues, + }); + + function onSubmit(data: DisplayFormValues) { + toast({ + title: "You submitted the following values:", + description: ( +
+          {JSON.stringify(data, null, 2)}
+        
+ ), + }); + } + + return ( +
+ + ( + + ID + + + + )} + /> + ( + + Hash + + + + )} + /> + + ( + + Status + + setIsStatusPopoverOpen(true)} + > + + + + + + + + + No status found. + + {statuses.map((status) => ( + { + form.setValue("status", status); + setIsStatusPopoverOpen(false); + }} + > + {status} + + + ))} + + + + + + + + )} + /> + + ( + + Retry Count + + + + )} + /> + + ( + + Type + + + + + + + + + + + No type found. + + {types.map((type) => ( + { + form.setValue("type", type); + setIsTypePopoverOpen(false); + }} + > + {type} + + + ))} + + + + + + + + )} + /> + ( + + Evaluation + + + + + + + + + + + No evaluation found. + + {evaluations.map((evaluation) => ( + { + form.setValue("evaluation", evaluation); + setIsEvaluationPopoverOpen(false); + }} + > + {evaluation} + + + ))} + + + + + + + + )} + /> + + ( + + Commit Date + + + + + + )} + /> + +
+ + +
+ + + ); +} diff --git a/src/components/commits-table/tools-table.tsx b/src/components/commits-table/tools-table.tsx index dd80345..b73413a 100644 --- a/src/components/commits-table/tools-table.tsx +++ b/src/components/commits-table/tools-table.tsx @@ -19,7 +19,7 @@ const ToolsTable = ({ commitsData }: { commitsData: Commit[] }) => { description="Manage Commits" />