feat: edit commit page
This commit is contained in:
parent
73c88598e7
commit
05bda6a7a5
|
@ -1,3 +1,5 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
|
@ -25,7 +27,11 @@ export default function Page() {
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<CommitForm />
|
<CommitForm
|
||||||
|
onSubmit={() => {}}
|
||||||
|
btn1_content="Create"
|
||||||
|
btn2_content="Create and add another"
|
||||||
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
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 { dummyCommits } from "@/constants/data";
|
||||||
|
import { Commit } from "@/types/commit";
|
||||||
|
import CommitForm from "@/components/commit-form";
|
||||||
|
|
||||||
|
const breadcrumbItems = [
|
||||||
|
{ title: "Dashboard", link: "/dashboard" },
|
||||||
|
{ title: "Commits", link: "/dashboard/commits" },
|
||||||
|
{ title: "Edit" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function Page({ params }: { params: { id: string } }) {
|
||||||
|
const commit = dummyCommits.find((commit) => commit.id === params.id);
|
||||||
|
|
||||||
|
console.log(commit)
|
||||||
|
return (
|
||||||
|
<ScrollArea className="h-[calc(100vh-53px)]">
|
||||||
|
<div className="flex-1 space-y-4 p-4 md:p-8 pt-6">
|
||||||
|
<Breadcrumb items={breadcrumbItems} />
|
||||||
|
<div className="w-full h-full flex justify-center items-center">
|
||||||
|
<Card className="max-w-[700px] w-full">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle className="mb-4 font-bold text-xl">
|
||||||
|
Edit Commit
|
||||||
|
</CardTitle>
|
||||||
|
<Separator />
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent>
|
||||||
|
<CommitForm
|
||||||
|
commit={commit as Commit}
|
||||||
|
onSubmit={() => {}}
|
||||||
|
btn1_content="Save and continue editing"
|
||||||
|
btn2_content="Save changes"
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ScrollBar />
|
||||||
|
</ScrollArea>
|
||||||
|
);
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ import {
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { CommandList } from "cmdk";
|
import { CommandList } from "cmdk";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { Commit } from "@/types/commit";
|
||||||
|
|
||||||
const statuses = [
|
const statuses = [
|
||||||
"new",
|
"new",
|
||||||
|
@ -69,14 +70,34 @@ const defaultValues: Partial<DisplayFormValues> = {
|
||||||
commitDate: "",
|
commitDate: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function CommitForm() {
|
type Props = {
|
||||||
|
commit?: Commit;
|
||||||
|
onSubmit: () => void;
|
||||||
|
btn1_content: string;
|
||||||
|
btn2_content: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function CommitForm({
|
||||||
|
commit,
|
||||||
|
onSubmit: onFormSubmit,
|
||||||
|
btn1_content,
|
||||||
|
btn2_content,
|
||||||
|
}: Props) {
|
||||||
const [isStatusPopoverOpen, setIsStatusPopoverOpen] = useState(false);
|
const [isStatusPopoverOpen, setIsStatusPopoverOpen] = useState(false);
|
||||||
const [isTypePopoverOpen, setIsTypePopoverOpen] = useState(false);
|
const [isTypePopoverOpen, setIsTypePopoverOpen] = useState(false);
|
||||||
const [isEvaluationPopoverOpen, setIsEvaluationPopoverOpen] = useState(false);
|
const [isEvaluationPopoverOpen, setIsEvaluationPopoverOpen] = useState(false);
|
||||||
|
|
||||||
const form = useForm<DisplayFormValues>({
|
const form = useForm<DisplayFormValues>({
|
||||||
resolver: zodResolver(displayFormSchema),
|
resolver: zodResolver(displayFormSchema),
|
||||||
defaultValues,
|
defaultValues: {
|
||||||
|
id: commit?.id || "",
|
||||||
|
hash: commit?.hash || "",
|
||||||
|
status: commit?.status || "",
|
||||||
|
retryCount: commit?.retryCount || "",
|
||||||
|
type: commit?.type || "",
|
||||||
|
evaluation: commit?.evaluation || "",
|
||||||
|
commitDate: commit?.commitDate || "",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: DisplayFormValues) {
|
function onSubmit(data: DisplayFormValues) {
|
||||||
|
@ -88,6 +109,8 @@ export default function CommitForm() {
|
||||||
</pre>
|
</pre>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onFormSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -348,10 +371,10 @@ export default function CommitForm() {
|
||||||
|
|
||||||
<div className="flex items-center gap-4 flex-col sm:flex-row">
|
<div className="flex items-center gap-4 flex-col sm:flex-row">
|
||||||
<Button className="w-full" size="lg">
|
<Button className="w-full" size="lg">
|
||||||
Create
|
{btn1_content}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="secondary" className="w-full" size="lg">
|
<Button variant="secondary" className="w-full" size="lg">
|
||||||
Create and add another
|
{btn2_content}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -299,10 +299,10 @@ export const dummyEvaluations: Evaluation[] = [
|
||||||
|
|
||||||
export const dummyCommits: Commit[] = [
|
export const dummyCommits: Commit[] = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: "1",
|
||||||
hash: "9998211595b05c7f8555e4a129d7792bce7a8dd6_1",
|
hash: "9998211595b05c7f8555e4a129d7792bce7a8dd6_1",
|
||||||
status: "skills_extracted",
|
status: "skills_extracted",
|
||||||
retryCount: 0,
|
retryCount: "0",
|
||||||
type: "code",
|
type: "code",
|
||||||
evaluation:
|
evaluation:
|
||||||
"Uploaded at: 2023-09-20 00:00:00 - Uploader: jschultz@php.net - Developer: fabien@potencier.org - Status: finished",
|
"Uploaded at: 2023-09-20 00:00:00 - Uploader: jschultz@php.net - Developer: fabien@potencier.org - Status: finished",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
export interface Commit {
|
export interface Commit {
|
||||||
id: number;
|
id: string;
|
||||||
hash: string;
|
hash: string;
|
||||||
status: string;
|
status: string;
|
||||||
retryCount: number;
|
retryCount: string;
|
||||||
type: string;
|
type: string;
|
||||||
evaluation: string;
|
evaluation: string;
|
||||||
commitDate: string;
|
commitDate: string;
|
||||||
|
|
Loading…
Reference in New Issue