feat: update supervisor - minor
This commit is contained in:
parent
6ebea4da2d
commit
131bec7b13
|
|
@ -0,0 +1,110 @@
|
||||||
|
"use client"
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from "@/components/ui/dialog"
|
||||||
|
import { CalendarIcon, Plus } from "lucide-react";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
|
import { useForm } from "react-hook-form"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/components/ui/form"
|
||||||
|
import { Input } from "@/components/ui/input"
|
||||||
|
import { toast } from "@/components/ui/use-toast"
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
|
import Image from "next/image";
|
||||||
|
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||||
|
import { Calendar } from "@/components/ui/calendar";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useTranslations } from "next-intl";
|
||||||
|
import { saveKnowledgeBaseCategory } from "@/service/master/knowledge-base";
|
||||||
|
|
||||||
|
const FormSchema = z.object({
|
||||||
|
name: z.string().min(2, {
|
||||||
|
message: "Name must be at least 2 characters.",
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
const CreateCategory = ({ onSuccess } : { onSuccess?: () => void } ) => {
|
||||||
|
const t = useTranslations("TodoApp")
|
||||||
|
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
|
||||||
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
|
resolver: zodResolver(FormSchema),
|
||||||
|
defaultValues: {
|
||||||
|
name: "",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
async function save(data: any) {
|
||||||
|
const reqData = {
|
||||||
|
name: data.name
|
||||||
|
}
|
||||||
|
const response = await saveKnowledgeBaseCategory(reqData);
|
||||||
|
if (response?.error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
toast({
|
||||||
|
title: "Task created successfully.",
|
||||||
|
});
|
||||||
|
if (onSuccess) {
|
||||||
|
onSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||||
|
save(data);
|
||||||
|
setIsDialogOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button fullWidth size="lg" className="dark:bg-background dark:text-foreground">
|
||||||
|
<Plus className="w-6 h-6 me-1.5" />
|
||||||
|
Add Category
|
||||||
|
</Button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader className="mb-4">
|
||||||
|
<DialogTitle>Add Category</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="name"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel className="text-default-700">Name</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="Enter Title" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Button type="submit">Submit</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CreateCategory;
|
||||||
|
|
@ -11,8 +11,9 @@ import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs";
|
||||||
import SiteBreadcrumb from "@/components/site-breadcrumb";
|
import SiteBreadcrumb from "@/components/site-breadcrumb";
|
||||||
import {getKnowledgeBaseCategoryList, getKnowledgeBaseList} from "@/service/master/knowledge-base";
|
import {getKnowledgeBaseCategoryList, getKnowledgeBaseList} from "@/service/master/knowledge-base";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Plus} from "lucide-react";
|
import {Plus, Trash2} from "lucide-react";
|
||||||
import {Button} from "@/components/ui/button";
|
import {Button} from "@/components/ui/button";
|
||||||
|
import CreateCategory from "./create-category";
|
||||||
|
|
||||||
const KnowledgeBase = () => {
|
const KnowledgeBase = () => {
|
||||||
const [categories, setCategories] = React.useState<any>([]);
|
const [categories, setCategories] = React.useState<any>([]);
|
||||||
|
|
@ -47,15 +48,9 @@ const KnowledgeBase = () => {
|
||||||
<Card className="lg:col-span-3 md:col-span-5 col-span-12 h-max">
|
<Card className="lg:col-span-3 md:col-span-5 col-span-12 h-max">
|
||||||
<CardContent className=" p-6">
|
<CardContent className=" p-6">
|
||||||
<TabsList className="md:flex-col gap-2 flex-wrap md:items-start justify-start">
|
<TabsList className="md:flex-col gap-2 flex-wrap md:items-start justify-start">
|
||||||
<Button
|
<CreateCategory onSuccess={fetchCategoryList} />
|
||||||
fullWidth
|
|
||||||
size="lg"
|
|
||||||
className="dark:bg-background dark:ring-background dark:text-foreground"
|
|
||||||
>
|
|
||||||
<Plus className="w-6 h-6 me-1.5"/>
|
|
||||||
Add Category
|
|
||||||
</Button>
|
|
||||||
{categories?.map((category: any, index: number) => (
|
{categories?.map((category: any, index: number) => (
|
||||||
|
<div>
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
key={index}
|
key={index}
|
||||||
value={`category-${index}`}
|
value={`category-${index}`}
|
||||||
|
|
@ -65,7 +60,14 @@ const KnowledgeBase = () => {
|
||||||
className="data-[state=active]:bg-secondary data-[state=active]:text-default rounded-md px-6 py-3 w-full justify-start"
|
className="data-[state=active]:bg-secondary data-[state=active]:text-default rounded-md px-6 py-3 w-full justify-start"
|
||||||
>
|
>
|
||||||
{category?.name}
|
{category?.name}
|
||||||
|
<div
|
||||||
|
className="absolute right-2 top-2 hidden group-hover:inline-flex"
|
||||||
|
// onClick={() => deleteCategory(category?.id)}
|
||||||
|
>
|
||||||
|
<Trash2 className="w-3.5 h-3.5 me-1" />
|
||||||
|
</div>
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
|
</div>
|
||||||
))}
|
))}
|
||||||
</TabsList>
|
</TabsList>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,23 @@ import React from "react";
|
||||||
import { Loader2 } from "lucide-react";
|
import { Loader2 } from "lucide-react";
|
||||||
import DashCodeLogo from "./dascode-logo";
|
import DashCodeLogo from "./dascode-logo";
|
||||||
import { useMounted } from "@/hooks/use-mounted";
|
import { useMounted } from "@/hooks/use-mounted";
|
||||||
|
import Image from "next/image";
|
||||||
const Loader = () => {
|
const Loader = () => {
|
||||||
const mounted = useMounted()
|
const mounted = useMounted()
|
||||||
return (
|
return (
|
||||||
mounted ? null : <div className=" h-screen flex items-center justify-center flex-col space-y-2">
|
mounted ? null : <div className=" h-screen flex items-center justify-center flex-col space-y-2">
|
||||||
<div className="flex gap-2 items-center ">
|
<div className="flex gap-2 items-center ">
|
||||||
<DashCodeLogo className=" text-default-900 h-8 w-8 [&>path:nth-child(3)]:text-background [&>path:nth-child(2)]:text-background" />
|
{/* <DashCodeLogo className=" text-default-900 h-8 w-8 [&>path:nth-child(3)]:text-background [&>path:nth-child(2)]:text-background" /> */}
|
||||||
<h1 className="text-xl font-semibold text-default-900 ">
|
<Image
|
||||||
|
src="/assets/mediahub-logo-min.png"
|
||||||
|
alt=""
|
||||||
|
width={80}
|
||||||
|
height={80}
|
||||||
|
className="mb-4 w-full h-full"
|
||||||
|
/>
|
||||||
|
{/* <h1 className="text-xl font-semibold text-default-900 ">
|
||||||
DashCode
|
DashCode
|
||||||
</h1>
|
</h1> */}
|
||||||
</div>
|
</div>
|
||||||
<span className=" inline-flex gap-1 items-center">
|
<span className=" inline-flex gap-1 items-center">
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
httpGetInterceptor,
|
httpGetInterceptor,
|
||||||
|
httpPostInterceptor,
|
||||||
} from "../http-config/http-interceptor-service";
|
} from "../http-config/http-interceptor-service";
|
||||||
|
|
||||||
export async function getKnowledgeBaseCategoryList() {
|
export async function getKnowledgeBaseCategoryList() {
|
||||||
|
|
@ -11,3 +12,8 @@ export async function getKnowledgeBaseList(id: number) {
|
||||||
const url = `knowledge-base?categoryId=${id}`;
|
const url = `knowledge-base?categoryId=${id}`;
|
||||||
return httpGetInterceptor(url);
|
return httpGetInterceptor(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function saveKnowledgeBaseCategory(data: any) {
|
||||||
|
const url = 'knowledge-base/category';
|
||||||
|
return httpPostInterceptor(url, data);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue