mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: stop force redirect to create collection form
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { DisplayPreferences } from '#shared/types/index';
|
||||
import { SimpleGrid, Stack, StyleProp, useCombobox } from '@mantine/core';
|
||||
import { SimpleGrid, Stack, StyleProp } from '@mantine/core';
|
||||
import { LinkItem } from '~/components/dashboard/link/item/link_item';
|
||||
import { NoLink } from '~/components/dashboard/link/no_link/no_link';
|
||||
import { useActiveCollection } from '~/hooks/collections/use_active_collection';
|
||||
@@ -15,13 +15,9 @@ export function LinkList({ hideMenu = false }: LinkListProps) {
|
||||
const favoriteLinks = useFavoriteLinks();
|
||||
const { displayPreferences } = useDisplayPreferences();
|
||||
|
||||
const combobox = useCombobox({
|
||||
onDropdownClose: () => combobox.resetSelectedOption(),
|
||||
});
|
||||
|
||||
const links = activeCollection?.links || favoriteLinks;
|
||||
|
||||
if (activeCollection?.links.length === 0) {
|
||||
if (links.length === 0) {
|
||||
return <NoLink hideMenu={hideMenu} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,21 +12,27 @@ interface NoLinkProps extends LinkListProps {}
|
||||
export function NoLink({ hideMenu }: NoLinkProps) {
|
||||
const { t } = useTranslation('common');
|
||||
const activeCollection = useActiveCollection();
|
||||
const isFavorite = !activeCollection?.id;
|
||||
|
||||
const noLinkForCollection = t(
|
||||
'home:no-link',
|
||||
{ name: activeCollection?.name ?? '' } as any,
|
||||
{
|
||||
interpolation: { escapeValue: false },
|
||||
}
|
||||
);
|
||||
|
||||
const noLinkForFavorite = t('home:no-link-favorite');
|
||||
|
||||
return (
|
||||
<Box className={styles.noCollection} p="xl">
|
||||
<Text
|
||||
className={styles.text}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: t(
|
||||
'home:no-link',
|
||||
{ name: activeCollection?.name ?? '' } as any,
|
||||
{
|
||||
interpolation: { escapeValue: false },
|
||||
}
|
||||
),
|
||||
__html: isFavorite ? noLinkForFavorite : noLinkForCollection,
|
||||
}}
|
||||
/>
|
||||
{!hideMenu && (
|
||||
{!hideMenu && !isFavorite && (
|
||||
<Anchor
|
||||
component={Link}
|
||||
href={appendCollectionId(
|
||||
|
||||
Reference in New Issue
Block a user