import {DetailsSidebarSectionHeader} from '@app/drive/details-sidebar/details-sidebar-section-header'; import {Trans} from '@common/i18n/trans'; import {DriveEntry} from '@app/drive/files/drive-entry'; import { ChipField, ChipValue, } from '@common/ui/forms/input-field/chip-field/chip-field'; import React, {useState} from 'react'; import {Item} from '@common/ui/forms/listbox/item'; import {useTrans} from '@common/i18n/use-trans'; import {message} from '@common/i18n/message'; import {useSyncEntryTags} from '@app/drive/details-sidebar/requests/use-sync-entry-tags'; import {useFileEntryTags} from '@app/drive/details-sidebar/requests/use-file-entry-tags'; import {useNavigate} from '@common/utils/hooks/use-navigate'; interface Props { entry: DriveEntry; } export function DetailsSidebarTags({entry}: Props) { // use key={entry.id} to force re-render tag chip field when entry changes return (
); } function TagChipField({entry}: Props) { const {trans} = useTrans(); const navigate = useNavigate(); const syncTags = useSyncEntryTags(); const [inputValue, setInputValue] = useState(''); const [value, setValue] = useState(entry.tags || []); const {data, isLoading} = useFileEntryTags(inputValue); const handleChange = (newTags: ChipValue[]) => { setValue(newTags); if (!syncTags.isPending) { syncTags.mutate({tags: newTags, entry}); } }; return ( { navigate(`/drive/search?query=${chip.name}`); }} > {data?.results.map(result => ( {result.name} ))} ); }