mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
Changes from category
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import * as React from "react";
|
import { Tag } from "lucide-react";
|
||||||
import { Autocomplete } from "@/components/ui/autocomplete";
|
import { Autocomplete } from "@/components/ui/autocomplete";
|
||||||
|
|
||||||
interface CategoryAutocompleteProps {
|
interface CategoryAutocompleteProps {
|
||||||
@@ -10,6 +10,7 @@ interface CategoryAutocompleteProps {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
error?: boolean;
|
||||||
"data-testid"?: string;
|
"data-testid"?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ export function CategoryAutocomplete({
|
|||||||
placeholder = "Select or type a category...",
|
placeholder = "Select or type a category...",
|
||||||
className,
|
className,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
|
error = false,
|
||||||
"data-testid": testId,
|
"data-testid": testId,
|
||||||
}: CategoryAutocompleteProps) {
|
}: CategoryAutocompleteProps) {
|
||||||
return (
|
return (
|
||||||
@@ -28,10 +30,14 @@ export function CategoryAutocomplete({
|
|||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
options={suggestions}
|
options={suggestions}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
searchPlaceholder="Search category..."
|
searchPlaceholder="Search or type new category..."
|
||||||
emptyMessage="No category found."
|
emptyMessage="No category found."
|
||||||
className={className}
|
className={className}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
error={error}
|
||||||
|
icon={Tag}
|
||||||
|
allowCreate
|
||||||
|
createLabel={(v) => `Create "${v}"`}
|
||||||
data-testid={testId}
|
data-testid={testId}
|
||||||
itemTestIdPrefix="category-option"
|
itemTestIdPrefix="category-option"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -57,3 +57,22 @@ export async function getCategoryOption(
|
|||||||
.replace(/\s+/g, "-")}`;
|
.replace(/\s+/g, "-")}`;
|
||||||
return page.locator(`[data-testid="${optionTestId}"]`);
|
return page.locator(`[data-testid="${optionTestId}"]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Click the "Create new" option for a category that doesn't exist
|
||||||
|
*/
|
||||||
|
export async function clickCreateNewCategoryOption(
|
||||||
|
page: Page
|
||||||
|
): Promise<void> {
|
||||||
|
const option = page.locator('[data-testid="category-option-create-new"]');
|
||||||
|
await option.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "Create new" option element for categories
|
||||||
|
*/
|
||||||
|
export async function getCreateNewCategoryOption(
|
||||||
|
page: Page
|
||||||
|
): Promise<Locator> {
|
||||||
|
return page.locator('[data-testid="category-option-create-new"]');
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user