feat(tags): add tag management interfaces and update related schemas
This commit is contained in:
@@ -5,15 +5,15 @@ import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
|
||||
export type TaskTagFormValues = {
|
||||
export type TagFormValues = {
|
||||
name: string;
|
||||
slug: string;
|
||||
color: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
type TaskTagFormProps = {
|
||||
initialValues?: TaskTagFormValues;
|
||||
type TagFormProps = {
|
||||
initialValues?: TagFormValues;
|
||||
onSubmit: (values: {
|
||||
name: string;
|
||||
slug: string;
|
||||
@@ -26,7 +26,7 @@ type TaskTagFormProps = {
|
||||
isSubmitting: boolean;
|
||||
};
|
||||
|
||||
const DEFAULT_VALUES: TaskTagFormValues = {
|
||||
const DEFAULT_VALUES: TagFormValues = {
|
||||
name: "",
|
||||
slug: "",
|
||||
color: "9e9e9e",
|
||||
@@ -51,14 +51,14 @@ const extractErrorMessage = (error: unknown, fallback: string) => {
|
||||
return fallback;
|
||||
};
|
||||
|
||||
export function TaskTagForm({
|
||||
export function TagForm({
|
||||
initialValues,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
submitLabel,
|
||||
submittingLabel,
|
||||
isSubmitting,
|
||||
}: TaskTagFormProps) {
|
||||
}: TagFormProps) {
|
||||
const resolvedInitial = initialValues ?? DEFAULT_VALUES;
|
||||
const [name, setName] = useState(() => resolvedInitial.name);
|
||||
const [slug, setSlug] = useState(() => resolvedInitial.slug);
|
||||
@@ -10,21 +10,21 @@ import {
|
||||
useReactTable,
|
||||
} from "@tanstack/react-table";
|
||||
|
||||
import { type TaskTagRead } from "@/api/generated/model";
|
||||
import { type TagRead } from "@/api/generated/model";
|
||||
import {
|
||||
DataTable,
|
||||
type DataTableEmptyState,
|
||||
} from "@/components/tables/DataTable";
|
||||
import { dateCell } from "@/components/tables/cell-formatters";
|
||||
|
||||
type TaskTagsTableProps = {
|
||||
tags: TaskTagRead[];
|
||||
type TagsTableProps = {
|
||||
tags: TagRead[];
|
||||
isLoading?: boolean;
|
||||
sorting?: SortingState;
|
||||
onSortingChange?: OnChangeFn<SortingState>;
|
||||
stickyHeader?: boolean;
|
||||
onEdit?: (tag: TaskTagRead) => void;
|
||||
onDelete?: (tag: TaskTagRead) => void;
|
||||
onEdit?: (tag: TagRead) => void;
|
||||
onDelete?: (tag: TagRead) => void;
|
||||
emptyState?: Omit<DataTableEmptyState, "icon"> & {
|
||||
icon?: DataTableEmptyState["icon"];
|
||||
};
|
||||
@@ -52,7 +52,7 @@ const normalizeColor = (value?: string | null) => {
|
||||
return cleaned;
|
||||
};
|
||||
|
||||
export function TaskTagsTable({
|
||||
export function TagsTable({
|
||||
tags,
|
||||
isLoading = false,
|
||||
sorting,
|
||||
@@ -61,7 +61,7 @@ export function TaskTagsTable({
|
||||
onEdit,
|
||||
onDelete,
|
||||
emptyState,
|
||||
}: TaskTagsTableProps) {
|
||||
}: TagsTableProps) {
|
||||
const [internalSorting, setInternalSorting] = useState<SortingState>([
|
||||
{ id: "name", desc: false },
|
||||
]);
|
||||
@@ -72,7 +72,7 @@ export function TaskTagsTable({
|
||||
setInternalSorting(updater);
|
||||
});
|
||||
|
||||
const columns = useMemo<ColumnDef<TaskTagRead>[]>(
|
||||
const columns = useMemo<ColumnDef<TagRead>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "name",
|
||||
Reference in New Issue
Block a user