mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
feat: add delete buttons for categories and tags in combobox dropdown
- Add onDelete prop to ColoredItemCombobox with X button per item - Wire up deleteCategory/deleteTag API calls in AdminNewsCreate - Auto-clear selection if the deleted item was selected - Spinner on delete, haptic feedback, i18n aria-label
This commit is contained in:
@@ -445,6 +445,22 @@ export default function AdminNewsCreate() {
|
||||
[queryClient],
|
||||
);
|
||||
|
||||
const handleDeleteCategory = useCallback(
|
||||
async (item: { id: number }) => {
|
||||
await newsApi.deleteCategory(item.id);
|
||||
await queryClient.invalidateQueries({ queryKey: ['admin', 'news', 'categories'] });
|
||||
},
|
||||
[queryClient],
|
||||
);
|
||||
|
||||
const handleDeleteTag = useCallback(
|
||||
async (item: { id: number }) => {
|
||||
await newsApi.deleteTag(item.id);
|
||||
await queryClient.invalidateQueries({ queryKey: ['admin', 'news', 'tags'] });
|
||||
},
|
||||
[queryClient],
|
||||
);
|
||||
|
||||
// Fetch article for editing
|
||||
const { data: articleData, isLoading: isLoadingArticle } = useQuery({
|
||||
queryKey: ['admin', 'news', 'article', articleId],
|
||||
@@ -626,6 +642,7 @@ export default function AdminNewsCreate() {
|
||||
value={selectedCategory}
|
||||
onChange={setSelectedCategory}
|
||||
onCreateNew={handleCreateCategory}
|
||||
onDelete={handleDeleteCategory}
|
||||
placeholder={t('news.admin.combobox.selectCategory')}
|
||||
/>
|
||||
</div>
|
||||
@@ -636,6 +653,7 @@ export default function AdminNewsCreate() {
|
||||
value={selectedTag}
|
||||
onChange={setSelectedTag}
|
||||
onCreateNew={handleCreateTag}
|
||||
onDelete={handleDeleteTag}
|
||||
placeholder={t('news.admin.combobox.selectTag')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user