Updated names for uniformity
This commit is contained in:
@@ -15,12 +15,12 @@ const BookmarkSettings = () => {
|
||||
categoryIndex: 0,
|
||||
filterName: '',
|
||||
};
|
||||
const linksEndpoint = 'api/links';
|
||||
const { data: linkData, isFetched: linksIsFetched } = useQueryAPI({
|
||||
endpoint: linksEndpoint,
|
||||
const bookmarksEndpoint = 'api/bookmarks';
|
||||
const { data: bookmarkData, isFetched: bookmarksIsFetched } = useQueryAPI({
|
||||
endpoint: bookmarksEndpoint,
|
||||
});
|
||||
const [bookmarks, setBookmarks] = useState<Bookmark[]>([]);
|
||||
const categoriesEndpoint = 'api/categories';
|
||||
const categoriesEndpoint = 'api/bookmarkCategories';
|
||||
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
||||
endpoint: categoriesEndpoint,
|
||||
});
|
||||
@@ -60,10 +60,10 @@ const BookmarkSettings = () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (linkData && linksIsFetched) {
|
||||
setBookmarks(linkData);
|
||||
if (bookmarkData && bookmarksIsFetched) {
|
||||
setBookmarks(bookmarkData);
|
||||
}
|
||||
}, [linksIsFetched, linkData]);
|
||||
}, [bookmarksIsFetched, bookmarkData]);
|
||||
|
||||
useEffect(() => {
|
||||
if (groupData && groupsIsFetched) {
|
||||
@@ -98,7 +98,11 @@ const BookmarkSettings = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (groupList.length > 0 && groupList !== groups) {
|
||||
mutateAsync({ method: 'PATCH', endpoint: 'api/categoryOrder', body: groupList });
|
||||
mutateAsync({
|
||||
method: 'PATCH',
|
||||
endpoint: 'api/bookmarkCategoryOrder',
|
||||
body: groupList,
|
||||
});
|
||||
}
|
||||
}, [groupList]);
|
||||
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
import {
|
||||
ActionIcon,
|
||||
Button,
|
||||
Card,
|
||||
Group,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Tooltip,
|
||||
} from '@mantine/core';
|
||||
import { ActionIcon, Card, Group, Stack, Text, TextInput, Tooltip } from '@mantine/core';
|
||||
import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
|
||||
import { useCommonHooks, useMutationAPI } from 'hooks';
|
||||
import { useEffect, useState } from 'react';
|
||||
@@ -33,7 +24,7 @@ function DebouncedBookmarkItem({
|
||||
};
|
||||
useEffect(() => {
|
||||
if (Object.keys(debounced).length) {
|
||||
mutateAsync({ method: 'PATCH', endpoint: 'api/links', body: debounced });
|
||||
mutateAsync({ method: 'PATCH', endpoint: 'api/bookmarks', body: debounced });
|
||||
}
|
||||
}, [debounced]);
|
||||
|
||||
@@ -48,6 +39,7 @@ function DebouncedBookmarkItem({
|
||||
<DeleteItemModal
|
||||
modalOpened={modalOpened}
|
||||
handleClose={handleClose}
|
||||
handleDelete={() => handleDelete(bookmark, 'api/bookmarks')}
|
||||
body={
|
||||
<Stack gap={0} w={'100%'} h={'150px'} align='center'>
|
||||
<Text>Are you sure you want to delete this bookmark?</Text>
|
||||
@@ -63,25 +55,6 @@ function DebouncedBookmarkItem({
|
||||
}}
|
||||
>{`"${bookmark.name}"`}</Text>
|
||||
<Text c='red'>This action cannot be undone!</Text>
|
||||
<Group pos={'absolute'} bottom={8}>
|
||||
<Button
|
||||
color={'red'}
|
||||
styles={{ label: { color: 'black' } }}
|
||||
onClick={() => {
|
||||
handleDelete(bookmark, 'api/links');
|
||||
handleClose();
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
<Button
|
||||
color={'grey'}
|
||||
styles={{ label: { color: 'black' } }}
|
||||
onClick={handleClose}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
}
|
||||
title='Delete Bookmark'
|
||||
|
||||
@@ -72,7 +72,11 @@ function DebouncedGroupSettingsItem({
|
||||
|
||||
useEffect(() => {
|
||||
if (Object.keys(debounced).length) {
|
||||
mutateAsync({ method: 'PATCH', endpoint: 'api/categories', body: debounced });
|
||||
mutateAsync({
|
||||
method: 'PATCH',
|
||||
endpoint: 'api/bookmarkCategories',
|
||||
body: debounced,
|
||||
});
|
||||
setUpdate({});
|
||||
}
|
||||
}, [debounced]);
|
||||
@@ -85,7 +89,7 @@ function DebouncedGroupSettingsItem({
|
||||
|
||||
useEffect(() => {
|
||||
if (bookmarkList && bookmarkList !== bookmarks) {
|
||||
mutateAsync({ method: 'PATCH', endpoint: 'api/linkOrder', body: bookmarkList });
|
||||
mutateAsync({ method: 'PATCH', endpoint: 'api/bookmarkOrder', body: bookmarkList });
|
||||
}
|
||||
}, [bookmarkList]);
|
||||
|
||||
@@ -94,6 +98,10 @@ function DebouncedGroupSettingsItem({
|
||||
<DeleteItemModal
|
||||
modalOpened={modalOpened}
|
||||
handleClose={closeModal}
|
||||
handleDelete={() => {
|
||||
handleDelete(bookmarks, 'api/bookmarks');
|
||||
handleDelete(group, 'api/bookmarkCategories');
|
||||
}}
|
||||
title='Delete message'
|
||||
body={
|
||||
<Stack gap={0} w={'100%'} h={'175px'} align='center'>
|
||||
@@ -113,28 +121,6 @@ function DebouncedGroupSettingsItem({
|
||||
This will also delete all bookmarks in this group!
|
||||
</Text>
|
||||
<Text c='red'>This action cannot be undone!</Text>
|
||||
<Group pos={'absolute'} bottom={8}>
|
||||
<Button
|
||||
color={'red'}
|
||||
styles={{ label: { color: 'black' } }}
|
||||
onClick={() => {
|
||||
handleDelete(bookmarks, 'api/links');
|
||||
handleDelete(group, 'api/categories');
|
||||
closeModal();
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
<Button
|
||||
color={'var(--color-text-acc)'}
|
||||
styles={{ label: { color: 'var(--color-text-pri)' } }}
|
||||
onClick={() => {
|
||||
closeModal();
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
}
|
||||
/>
|
||||
@@ -401,7 +387,7 @@ function DebouncedGroupSettingsItem({
|
||||
if (newBookmark) {
|
||||
mutateAsync({
|
||||
method: 'POST',
|
||||
endpoint: 'api/links',
|
||||
endpoint: 'api/bookmarks',
|
||||
body: { ...newBookmark, index: bookmarks.length },
|
||||
});
|
||||
setPopoverOpened(false);
|
||||
|
||||
Reference in New Issue
Block a user