This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

refactor: replace duplicate sortOrderMap with shared getCardsSortParams util

+6 -18
+3 -8
src/webapp/features/cards/containers/cardsContainerContent/CardsContainerContent.tsx
··· 1 1 'use client'; 2 2 3 - import { CardSortField, SortOrder, UrlType } from '@semble/types'; 3 + import { CardSortField, UrlType } from '@semble/types'; 4 4 import CardsContainerSkeleton from '../cardsContainer/Skeleton.CardsContainer'; 5 5 import CardsContainerError from '../cardsContainer/Error.CardsContainer'; 6 6 import { Container, Divider, Grid, Stack } from '@mantine/core'; ··· 14 14 import { useUserSettings } from '@/features/settings/lib/queries/useUserSettings'; 15 15 import { useSearchParams, usePathname } from 'next/navigation'; 16 16 import { CardSaveSource } from '@/features/analytics/types'; 17 + import { getCardsSortParams } from '../../lib/utils'; 17 18 18 19 interface Props { 19 20 handle: string; 20 21 } 21 22 22 - const sortOrderMap: Record<CardSortField, SortOrder> = { 23 - [CardSortField.UPDATED_AT]: SortOrder.DESC, 24 - [CardSortField.CREATED_AT]: SortOrder.ASC, 25 - [CardSortField.LIBRARY_COUNT]: SortOrder.DESC, 26 - }; 27 - 28 23 export default function CardsContainerContent(props: Props) { 29 24 const pathname = usePathname(); 30 25 const { desktopOpened } = useNavbarContext(); ··· 46 41 } = useCards({ 47 42 didOrHandle: props.handle, 48 43 sortBy: sortBy, 49 - sortOrder: sortOrderMap[sortBy], 44 + sortOrder: getCardsSortParams(sortBy).sortOrder, 50 45 urlType: selectedUrlType, 51 46 }); 52 47
+3 -10
src/webapp/features/collections/containers/collectionContainerContent/CollectionContainerContent.tsx
··· 5 5 import { Fragment, useState } from 'react'; 6 6 import { useUserSettings } from '@/features/settings/lib/queries/useUserSettings'; 7 7 import { useAuth } from '@/hooks/useAuth'; 8 - import { CardSortField, SortOrder, UrlType } from '@semble/types'; 8 + import { CardSortField, UrlType } from '@semble/types'; 9 9 import { 10 10 Anchor, 11 11 Box, ··· 23 23 import { FiPlus } from 'react-icons/fi'; 24 24 import { useSearchParams, usePathname } from 'next/navigation'; 25 25 import { CardSaveSource } from '@/features/analytics/types'; 26 + import { getCardsSortParams } from '@/features/cards/lib/utils'; 26 27 27 28 interface Props { 28 29 rkey: string; 29 30 handle: string; 30 - sortBy?: CardSortField; 31 - sortOrder?: SortOrder; 32 31 } 33 32 34 - const sortOrderMap: Record<CardSortField, SortOrder> = { 35 - [CardSortField.UPDATED_AT]: SortOrder.DESC, 36 - [CardSortField.CREATED_AT]: SortOrder.ASC, 37 - [CardSortField.LIBRARY_COUNT]: SortOrder.DESC, 38 - }; 39 - 40 33 export default function CollectionContainerContent(props: Props) { 41 34 const pathname = usePathname(); 42 35 const { desktopOpened } = useNavbarContext(); ··· 55 48 rkey: props.rkey, 56 49 handle: props.handle, 57 50 sortBy: sortBy, 58 - sortOrder: sortOrderMap[sortBy], 51 + sortOrder: getCardsSortParams(sortBy).sortOrder, 59 52 urlType: selectedUrlType, 60 53 }); 61 54