This commit is contained in:
@@ -48,7 +48,7 @@ function DebouncedGroupSettingsItem({
|
||||
const [popoverOpened, setPopoverOpened] = useState(false);
|
||||
const { mutateAsync } = useMutationAPI();
|
||||
const [group, setGroup] = useState<BookmarkGroup>(bookmarkGroup);
|
||||
const [update, setUpdate] = useState<any>({});
|
||||
const [update, setUpdate] = useState<BookmarkGroup>();
|
||||
const [debounced] = useDebouncedValue(update, 1000);
|
||||
const [newBookmark, setNewBookmark] = useState<Bookmark>({
|
||||
id: undefined,
|
||||
@@ -89,18 +89,18 @@ function DebouncedGroupSettingsItem({
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (Object.keys(debounced).length) {
|
||||
if (debounced && Object.keys(debounced).length) {
|
||||
mutateAsync({
|
||||
method: 'PATCH',
|
||||
endpoint: 'api/bookmarkCategories',
|
||||
body: debounced,
|
||||
});
|
||||
setUpdate({});
|
||||
setUpdate(undefined);
|
||||
}
|
||||
}, [debounced]);
|
||||
|
||||
useEffect(() => {
|
||||
if (update !== group && Object.keys(update).length) {
|
||||
if (update && update !== group && Object.keys(update).length) {
|
||||
setGroup(update);
|
||||
}
|
||||
}, [update]);
|
||||
@@ -113,28 +113,30 @@ function DebouncedGroupSettingsItem({
|
||||
|
||||
return (
|
||||
<Card w={'400px'} className={cardClasses.settingsItem} classNames={cardClasses}>
|
||||
<DeleteItemModal
|
||||
modalOpened={modalOpened}
|
||||
handleClose={closeModal}
|
||||
handleDelete={() => {
|
||||
bookmarks.length > 0 && handleDelete(bookmarks, 'api/bookmarks');
|
||||
handleDelete(group, 'api/bookmarkCategories');
|
||||
}}
|
||||
title='Delete message'
|
||||
body={
|
||||
<Stack gap={0} w={'100%'} h={'175px'} align='center'>
|
||||
<Text>Are you sure you want to delete this bookmark group?</Text>
|
||||
<Text
|
||||
className={textClasses.deleteItem}
|
||||
classNames={textClasses}
|
||||
>{`"${group.categoryName}"`}</Text>
|
||||
<Text style={{ fontWeight: 'bold', textTransform: 'uppercase' }}>
|
||||
This will also delete all bookmarks in this group!
|
||||
</Text>
|
||||
<Text c='red'>This action cannot be undone!</Text>
|
||||
</Stack>
|
||||
}
|
||||
/>
|
||||
{modalOpened && (
|
||||
<DeleteItemModal
|
||||
modalOpened={modalOpened}
|
||||
handleClose={closeModal}
|
||||
handleDelete={() => {
|
||||
bookmarks.length > 0 && handleDelete(bookmarks, 'api/bookmarks');
|
||||
handleDelete(group, 'api/bookmarkCategories');
|
||||
}}
|
||||
title='Delete message'
|
||||
body={
|
||||
<Stack gap={0} w={'100%'} h={'175px'} align='center'>
|
||||
<Text>Are you sure you want to delete this bookmark group?</Text>
|
||||
<Text
|
||||
className={textClasses.deleteItem}
|
||||
classNames={textClasses}
|
||||
>{`"${group.categoryName}"`}</Text>
|
||||
<Text style={{ fontWeight: 'bold', textTransform: 'uppercase' }}>
|
||||
This will also delete all bookmarks in this group!
|
||||
</Text>
|
||||
<Text c='red'>This action cannot be undone!</Text>
|
||||
</Stack>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<Card.Section
|
||||
p={'1rem'}
|
||||
pt={0}
|
||||
|
||||
Reference in New Issue
Block a user