mirror of
https://github.com/SkalaraAI/skalara-core.git
synced 2025-04-09 23:20:15 -04:00
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
"use client";
|
|
import { useToast } from "@/components/ui/use-toast";
|
|
import { useRouter } from "next/navigation";
|
|
|
|
import * as z from "zod";
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
import { useForm } from "react-hook-form";
|
|
|
|
import {
|
|
Form,
|
|
FormControl,
|
|
FormDescription,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
FormMessage,
|
|
} from "@/components/ui/form";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
const createTaskSchema = z.object({
|
|
name: z.string().min(2, {
|
|
message: "Task name must be at least 2 characters.",
|
|
}),
|
|
description: z
|
|
.string()
|
|
.min(2, {
|
|
message: "Task description must be at least 2 characters.",
|
|
})
|
|
.optional(),
|
|
});
|
|
|
|
export function CreateTask() {
|
|
const { toast } = useToast();
|
|
const router = useRouter();
|
|
|
|
const form = useForm<z.infer<typeof createTaskSchema>>({
|
|
resolver: zodResolver(createTaskSchema),
|
|
defaultValues: {
|
|
name: "",
|
|
description: "",
|
|
},
|
|
});
|
|
|
|
async function createTask(values: z.infer<typeof createTaskSchema>) {
|
|
try {
|
|
// TODO: create task
|
|
} catch (err: any) {
|
|
console.error(err);
|
|
toast({
|
|
variant: "destructive",
|
|
title: "Uh oh! There was an error creating the task.",
|
|
description: err.error,
|
|
});
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h1>Create Task</h1>
|
|
</div>
|
|
);
|
|
}
|