Updates to bookmarks
This commit is contained in:
@@ -34,6 +34,8 @@ function Applications({ contentType }: { contentType: string[] }) {
|
|||||||
return -1;
|
return -1;
|
||||||
case 'Custom':
|
case 'Custom':
|
||||||
return a.index > b.index ? 1 : -1;
|
return a.index > b.index ? 1 : -1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
?.filter(
|
?.filter(
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ function Bookmarks({ contentType }: { contentType: string[] }) {
|
|||||||
return -1;
|
return -1;
|
||||||
case 'Custom':
|
case 'Custom':
|
||||||
return a.categoryIndex > b.categoryIndex ? 1 : -1;
|
return a.categoryIndex > b.categoryIndex ? 1 : -1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
?.filter(
|
?.filter(
|
||||||
@@ -84,18 +86,21 @@ function Bookmarks({ contentType }: { contentType: string[] }) {
|
|||||||
gridTemplateColumns: `repeat(${bookmarkDensity}, 1fr)`,
|
gridTemplateColumns: `repeat(${bookmarkDensity}, 1fr)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{groups.map((category: BookmarkGroup) => {
|
{groups
|
||||||
return (
|
.filter((category: BookmarkGroup) => category.enabled === 1)
|
||||||
<BookmarkGroups
|
.map((category: BookmarkGroup) => {
|
||||||
key={category.categoryName}
|
return (
|
||||||
category={category.categoryName}
|
<BookmarkGroups
|
||||||
bookmarks={bookmarks.filter(
|
key={category.categoryName}
|
||||||
(bookmark: Bookmark) => bookmark.category === category.categoryName,
|
category={category.categoryName}
|
||||||
)}
|
bookmarks={bookmarks.filter(
|
||||||
bookmarkScale={bookmarkScale}
|
(bookmark: Bookmark) =>
|
||||||
/>
|
bookmark.category === category.categoryName,
|
||||||
);
|
)}
|
||||||
})}
|
bookmarkScale={bookmarkScale}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Card, Group, Stack, Text, TextInput } from '@mantine/core';
|
import { Card, Group, Select, Stack, Text, TextInput } from '@mantine/core';
|
||||||
import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
|
import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
|
||||||
import { DeleteItemModal, ManagementPill } from 'components';
|
import { DeleteItemModal, ManagementPill } from 'components';
|
||||||
import { useCommonHooks, useMutationAPI } from 'hooks';
|
import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { cardClasses, textInputClasses } from 'styles';
|
import { cardClasses, selectClasses, textInputClasses } from 'styles';
|
||||||
import type { Bookmark } from 'types';
|
import type { Bookmark, BookmarkGroup } from 'types';
|
||||||
|
|
||||||
function DebouncedBookmarkItem({
|
function DebouncedBookmarkItem({
|
||||||
bookmarkItem,
|
bookmarkItem,
|
||||||
@@ -16,8 +16,11 @@ function DebouncedBookmarkItem({
|
|||||||
const { handleDelete, isMobile, theme } = useCommonHooks();
|
const { handleDelete, isMobile, theme } = useCommonHooks();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
|
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
||||||
|
endpoint: 'api/bookmarkCategories',
|
||||||
|
});
|
||||||
const [bookmark, setBookmark] = useState<Bookmark>(bookmarkItem);
|
const [bookmark, setBookmark] = useState<Bookmark>(bookmarkItem);
|
||||||
|
const [groups, setGroups] = useState<BookmarkGroup[]>([]);
|
||||||
const [update, setUpdate] = useState<any>({});
|
const [update, setUpdate] = useState<any>({});
|
||||||
const [debounced] = useDebouncedValue(update, 1000);
|
const [debounced] = useDebouncedValue(update, 1000);
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
@@ -36,6 +39,16 @@ function DebouncedBookmarkItem({
|
|||||||
}
|
}
|
||||||
}, [update]);
|
}, [update]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (groupData) {
|
||||||
|
setGroups(
|
||||||
|
groupData.sort(
|
||||||
|
(a: BookmarkGroup, b: BookmarkGroup) => a.categoryName > b.categoryName,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [groupData, groupsIsFetched]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
p={isMobile ? 'xl' : undefined}
|
p={isMobile ? 'xl' : undefined}
|
||||||
@@ -75,7 +88,11 @@ function DebouncedBookmarkItem({
|
|||||||
}}
|
}}
|
||||||
openModal={openModal}
|
openModal={openModal}
|
||||||
/>
|
/>
|
||||||
<Group justify='center' style={{ flexDirection: isMobile ? 'column' : 'row' }}>
|
<Group
|
||||||
|
justify='space-between'
|
||||||
|
pos={'relative'}
|
||||||
|
style={{ flexDirection: isMobile ? 'column' : 'row' }}
|
||||||
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
label={'Name'}
|
label={'Name'}
|
||||||
className={textInputClasses.settingsItem}
|
className={textInputClasses.settingsItem}
|
||||||
@@ -95,16 +112,29 @@ function DebouncedBookmarkItem({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<Select
|
||||||
label={'Category'}
|
label={'Category'}
|
||||||
className={textInputClasses.settingsItem}
|
className={selectClasses.settingsItem}
|
||||||
classNames={textInputClasses}
|
classNames={{
|
||||||
defaultValue={bookmark.category}
|
wrapper: selectClasses.menuSelectWrapper,
|
||||||
onChange={(event) => {
|
input: selectClasses.menuSelectInput,
|
||||||
setUpdate({
|
label: selectClasses.menuSelectLabel,
|
||||||
...bookmark,
|
options: selectClasses.menuSelectOptions,
|
||||||
category: event.target.value,
|
option: selectClasses.menuSelectOption,
|
||||||
});
|
dropdown: selectClasses.dropdown,
|
||||||
|
}}
|
||||||
|
mt={'.75rem'}
|
||||||
|
limit={100}
|
||||||
|
defaultSearchValue={bookmark?.category}
|
||||||
|
data={groups.map((group) => {
|
||||||
|
return {
|
||||||
|
label: group.categoryName,
|
||||||
|
value: group.categoryName,
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
defaultValue={bookmark?.category}
|
||||||
|
comboboxProps={{
|
||||||
|
zIndex: 3000,
|
||||||
}}
|
}}
|
||||||
styles={
|
styles={
|
||||||
theme.textShadowsEnabled
|
theme.textShadowsEnabled
|
||||||
@@ -113,6 +143,16 @@ function DebouncedBookmarkItem({
|
|||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
onChange={(value: string | null) => {
|
||||||
|
setUpdate({
|
||||||
|
...bookmark,
|
||||||
|
category: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
searchable
|
||||||
|
maxDropdownHeight={175}
|
||||||
|
onDropdownOpen={() => setIsOpen(true)}
|
||||||
|
onDropdownClose={() => setIsOpen(false)}
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group justify='center' style={{ flexDirection: isMobile ? 'column' : 'row' }}>
|
<Group justify='center' style={{ flexDirection: isMobile ? 'column' : 'row' }}>
|
||||||
|
|||||||
@@ -15,15 +15,14 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
Tooltip,
|
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { isNotEmpty, useForm } from '@mantine/form';
|
import { isNotEmpty, useForm } from '@mantine/form';
|
||||||
import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
|
import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
|
||||||
import { DeleteItemModal } from 'components';
|
import { DeleteItemModal, ManagementPill } from 'components';
|
||||||
import { useCommonHooks, useMutationAPI } from 'hooks';
|
import { useCommonHooks, useMutationAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { FaChevronLeft } from 'react-icons/fa';
|
import { FaChevronLeft } from 'react-icons/fa';
|
||||||
import { FiPlus, FiTrash } from 'react-icons/fi';
|
import { FiPlus } from 'react-icons/fi';
|
||||||
import { buttonClasses, cardClasses, popoverClasses, textInputClasses } from 'styles';
|
import { buttonClasses, cardClasses, popoverClasses, textInputClasses } from 'styles';
|
||||||
import type { Bookmark, BookmarkGroup } from 'types';
|
import type { Bookmark, BookmarkGroup } from 'types';
|
||||||
import BookmarkSettingsItem from './BookmarkSettingsItem';
|
import BookmarkSettingsItem from './BookmarkSettingsItem';
|
||||||
@@ -145,7 +144,7 @@ function DebouncedGroupSettingsItem({
|
|||||||
mt={'-1.5rem'}
|
mt={'-1.5rem'}
|
||||||
>
|
>
|
||||||
<Stack gap={0}>
|
<Stack gap={0}>
|
||||||
<Group gap={0} align='end' justify='space-between'>
|
<Group w={'100%'} gap={8} align='end' justify='center' pos={'relative'}>
|
||||||
<TextInput
|
<TextInput
|
||||||
label={'Name'}
|
label={'Name'}
|
||||||
w={isMobile ? undefined : '56%'}
|
w={isMobile ? undefined : '56%'}
|
||||||
@@ -186,49 +185,53 @@ function DebouncedGroupSettingsItem({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Tooltip
|
<Text
|
||||||
c={'var(--mantine-color-primary-0)'}
|
style={{
|
||||||
bg={'var(--mantine-color-background-0)'}
|
width: '30px',
|
||||||
bd={'solid 1px var(--mantine-color-border-0)'}
|
height: '30px',
|
||||||
label={'Delete'}
|
borderRadius: '100%',
|
||||||
|
backgroundColor: 'var(--mantine-color-accent-0)',
|
||||||
|
fontSize: '1.25rem',
|
||||||
|
textAlign: 'center',
|
||||||
|
textJustify: 'auto',
|
||||||
|
marginBottom: '.5rem',
|
||||||
|
marginLeft: '.5rem',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ActionIcon
|
{bookmarks.length}
|
||||||
color='red'
|
</Text>
|
||||||
size={'2.75rem'}
|
|
||||||
onClick={() => {
|
|
||||||
openModal();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<FiTrash color='black' />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
width: '30px',
|
|
||||||
height: '30px',
|
|
||||||
borderRadius: '100%',
|
|
||||||
backgroundColor: 'var(--mantine-color-accent-0)',
|
|
||||||
position: 'absolute',
|
|
||||||
top: isMobile ? 156 : 78,
|
|
||||||
right: 22,
|
|
||||||
zIndex: 10,
|
|
||||||
fontSize: '1.25rem',
|
|
||||||
textAlign: 'center',
|
|
||||||
textJustify: 'auto',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{bookmarks.length}
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card.Section>
|
</Card.Section>
|
||||||
<Card.Section mt={'1rem'} p={'1rem'}>
|
<Card.Section mt={'1rem'} p={'1rem'}>
|
||||||
<Stack>
|
<Stack pos={'relative'}>
|
||||||
|
<Group
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
width: '100%',
|
||||||
|
right: '6rem',
|
||||||
|
top: '-3.25rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ManagementPill
|
||||||
|
enabled={group.enabled}
|
||||||
|
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setUpdate({
|
||||||
|
...group,
|
||||||
|
enabled: event.target.checked ? 1 : 0,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
openModal={openModal}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
<DragDropContext onDragEnd={onDragEnd}>
|
<DragDropContext onDragEnd={onDragEnd}>
|
||||||
<Droppable droppableId={`${bookmarkGroup.id}`}>
|
<Droppable droppableId={`${bookmarkGroup.id}`}>
|
||||||
{(provided: DroppableProvided) => (
|
{(provided: DroppableProvided) => (
|
||||||
<Stack ref={provided.innerRef} {...provided.droppableProps}>
|
<Stack
|
||||||
|
pos={'relative'}
|
||||||
|
ref={provided.innerRef}
|
||||||
|
{...provided.droppableProps}
|
||||||
|
>
|
||||||
{bookmarks.map((bookmark: Bookmark) => (
|
{bookmarks.map((bookmark: Bookmark) => (
|
||||||
<Draggable
|
<Draggable
|
||||||
key={bookmark.id}
|
key={bookmark.id}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export function ThemeModal({
|
|||||||
if (playlist.themeList.includes(`${selectedTheme.id}`)) {
|
if (playlist.themeList.includes(`${selectedTheme.id}`)) {
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ export function Themes() {
|
|||||||
if (t.backgroundImage !== 'none') {
|
if (t.backgroundImage !== 'none') {
|
||||||
return t.backgroundImage;
|
return t.backgroundImage;
|
||||||
}
|
}
|
||||||
|
return undefined;
|
||||||
})
|
})
|
||||||
.map((t) => t.backgroundImage),
|
.map((t) => t.backgroundImage),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ export interface BookmarkGroup {
|
|||||||
categoryName: string;
|
categoryName: string;
|
||||||
categoryIndex: number;
|
categoryIndex: number;
|
||||||
filterName: string;
|
filterName: string;
|
||||||
|
enabled: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user