@c-rex/components 0.1.19 → 0.1.21

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/components",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "files": [
5
5
  "src"
6
6
  ],
@@ -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
 
@@ -17,7 +17,6 @@ import { useTranslations } from "next-intl"
17
17
  import { LanguageAndCountries } from "@c-rex/interfaces"
18
18
  import { WILD_CARD_OPTIONS, OPERATOR_OPTIONS } from "@c-rex/constants"
19
19
  import { Switch } from "@c-rex/ui/switch"
20
- import { useSearchContext } from "@c-rex/contexts/search"
21
20
  import { useSearchSettingsStore } from "./stores/search-settings-store"
22
21
  import { OperatorType, WildCardType } from "@c-rex/types"
23
22
  import { useLanguageStore } from "./stores/language-store"
@@ -33,7 +32,6 @@ interface Languages {
33
32
 
34
33
  export const DialogFilter: FC<DialogFilterProps> = ({ trigger }) => {
35
34
  const t = useTranslations("filter");
36
- const { setLoading } = useSearchContext();
37
35
 
38
36
  const savedLike = useSearchSettingsStore((state) => state.like)
39
37
  const savedOperator = useSearchSettingsStore((state) => state.operator)
@@ -92,7 +90,6 @@ export const DialogFilter: FC<DialogFilterProps> = ({ trigger }) => {
92
90
  return
93
91
  }
94
92
 
95
- setLoading(true);
96
93
  setParams({
97
94
  page: 1,
98
95
  language: selectedLanguages.join(','),
@@ -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) {
@@ -8,7 +8,6 @@ import {
8
8
  PaginationPrevious,
9
9
  } from "@c-rex/ui/pagination"
10
10
  import { parseAsInteger, useQueryState } from "nuqs";
11
- import { useSearchContext } from "@c-rex/contexts/search";
12
11
 
13
12
  interface PaginationProps {
14
13
  totalPages: number;
@@ -17,7 +16,6 @@ interface PaginationProps {
17
16
 
18
17
  export const Pagination: FC<PaginationProps> = ({ totalPages, currentPage }) => {
19
18
  const disabledClass = "opacity-50 pointer-events-none";
20
- const { setLoading } = useSearchContext();
21
19
 
22
20
  const [_, setPage] = useQueryState('page',
23
21
  parseAsInteger.withOptions({
@@ -27,7 +25,6 @@ export const Pagination: FC<PaginationProps> = ({ totalPages, currentPage }) =>
27
25
  )
28
26
 
29
27
  const onChangePage = (pageNumber: number) => {
30
- setLoading(true);
31
28
  setPage(pageNumber);
32
29
  }
33
30
 
@@ -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 && favoritesDocuments[documentId]) {
38
- favoritesList = favoritesDocuments[documentId].topics;
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
- if (documentsCopy[id]) {
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
  }), {