import { FormField, FormItem, FormLabel, FormControl, } from "@/components/ui/form.tsx"; import { Input } from "@/components/ui/input.tsx"; import { Button } from "@/components/ui/button.tsx"; import React from "react"; import { useTranslation } from "react-i18next"; import type { CredentialGeneralTabProps } from "./shared/tab-types"; export function CredentialGeneralTab({ form, folders, tagInput, setTagInput, folderDropdownOpen, setFolderDropdownOpen, folderInputRef, folderDropdownRef, filteredFolders, handleFolderClick, }: CredentialGeneralTabProps) { const { t } = useTranslation(); return ( <> {t("credentials.basicInformation")}
( {t("credentials.credentialName")} )} /> ( {t("credentials.username")} )} />
{t("credentials.organization")}
( {t("credentials.description")} )} /> ( {t("credentials.folder")} setFolderDropdownOpen(true)} onChange={(e) => { field.onChange(e); setFolderDropdownOpen(true); }} /> {folderDropdownOpen && filteredFolders.length > 0 && (
{filteredFolders.map((folder) => ( ))}
)}
)} /> ( {t("credentials.tags")}
{(field.value || []).map((tag: string, idx: number) => ( {tag} ))} setTagInput(e.target.value)} onKeyDown={(e) => { if (e.key === " " && tagInput.trim() !== "") { e.preventDefault(); const currentTags = field.value || []; if (!currentTags.includes(tagInput.trim())) { field.onChange([...currentTags, tagInput.trim()]); } setTagInput(""); } else if (e.key === "Enter" && tagInput.trim() !== "") { e.preventDefault(); const currentTags = field.value || []; if (!currentTags.includes(tagInput.trim())) { field.onChange([...currentTags, tagInput.trim()]); } setTagInput(""); } else if ( e.key === "Backspace" && tagInput === "" && (field.value || []).length > 0 ) { const currentTags = field.value || []; field.onChange(currentTags.slice(0, -1)); } }} placeholder={t("credentials.addTagsSpaceToAdd")} />
)} />
); }