@c-rex/components 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/breadcrumb.tsx
CHANGED
|
@@ -26,7 +26,7 @@ interface BreadcrumbProps {
|
|
|
26
26
|
export const Breadcrumb: FC<BreadcrumbProps> = ({ items, loading, lang }) => {
|
|
27
27
|
const t = useTranslations("breadcrumbs");
|
|
28
28
|
const device = useBreakpoint();
|
|
29
|
-
const isMobile = (device === DEVICE_OPTIONS.MOBILE || device === DEVICE_OPTIONS.TABLET);
|
|
29
|
+
const isMobile = device !== null && (device === DEVICE_OPTIONS.MOBILE || device === DEVICE_OPTIONS.TABLET);
|
|
30
30
|
|
|
31
31
|
if (!items) return null
|
|
32
32
|
|
package/src/left-sidebar.tsx
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from "@c-rex/ui/sidebar";
|
|
15
15
|
import { Skeleton } from "@c-rex/ui/skeleton";
|
|
16
16
|
import { TreeOfContent } from "@c-rex/interfaces";
|
|
17
|
-
import { useTranslations } from "next-intl";
|
|
18
17
|
import { cn } from "@c-rex/utils";
|
|
19
18
|
|
|
20
19
|
interface SidebarProps extends ComponentProps<typeof Sidebar> {
|
|
@@ -23,7 +22,6 @@ interface SidebarProps extends ComponentProps<typeof Sidebar> {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
export function LeftSidebar({ data, loading, className, lang, ...props }: SidebarProps) {
|
|
26
|
-
const t = useTranslations();
|
|
27
25
|
|
|
28
26
|
const tableOfContentGroup = (): JSX.Element | null => {
|
|
29
27
|
if (loading) {
|
package/src/right-sidebar.tsx
CHANGED
|
@@ -34,8 +34,8 @@ export function RightSidebar({
|
|
|
34
34
|
const isFavoriteDocument = Object.keys(favoritesDocuments).some((docId) => docId === documentId);
|
|
35
35
|
let favoritesList: Favorite[] = []
|
|
36
36
|
|
|
37
|
-
if (favoritesDocuments
|
|
38
|
-
favoritesList = favoritesDocuments[documentId]
|
|
37
|
+
if (Object.keys(favoritesDocuments).some(docId => docId === documentId)) {
|
|
38
|
+
favoritesList = favoritesDocuments[documentId]?.topics || []
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return (
|
|
@@ -43,16 +43,14 @@ export const useFavoritesStore = create<FavoritesStore>()(
|
|
|
43
43
|
}),
|
|
44
44
|
unfavoriteDocument: (id: string) =>
|
|
45
45
|
set((state) => {
|
|
46
|
-
let newFavorites = [...state.favorites];
|
|
47
46
|
const documentsCopy = { ...state.documents };
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const favoritesToRemove = documentsCopy[id].topics.map(topic => topic.id);
|
|
51
|
-
newFavorites = newFavorites.filter(fav => fav.id !== id && !favoritesToRemove.includes(fav.id));
|
|
52
|
-
|
|
53
|
-
delete documentsCopy[id];
|
|
47
|
+
if (!documentsCopy[id]) {
|
|
48
|
+
return state;
|
|
54
49
|
}
|
|
55
50
|
|
|
51
|
+
const favoritesToRemove = documentsCopy[id]?.topics.map(topic => topic.id) || [];
|
|
52
|
+
const newFavorites = state.favorites.filter(fav => fav.id !== id && !favoritesToRemove.includes(fav.id));
|
|
53
|
+
delete documentsCopy[id];
|
|
56
54
|
return { documents: documentsCopy, favorites: newFavorites };
|
|
57
55
|
}),
|
|
58
56
|
}), {
|