Download wp-calypso/client/sites/components/sites-dataviews/utils.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 716 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/components/sites-dataviews/utils.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/components/sites-dataviews/utils.ts
-
curl -L -o utils.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/components/sites-dataviews/utils.ts
716 Bytes
| import { DUMMY_DATA_VIEW_PREFIX } from './constants'; | |
| import type { SiteExcerptData } from '@automattic/sites'; | |
| const SORT_KEY_MAP = { | |
| site: 'alphabetically', | |
| 'last-publish': 'updatedAt', | |
| }; | |
| export function mapFieldIdToSortKey( fieldId: string ) { | |
| return SORT_KEY_MAP[ fieldId as keyof typeof SORT_KEY_MAP ] ?? fieldId; | |
| } | |
| export function getSitesPagination( | |
| allSites: SiteExcerptData[], | |
| perPage: number | |
| ): { | |
| totalItems: number; | |
| totalPages: number; | |
| } { | |
| const totalItems = allSites.length; | |
| const totalPages = Math.ceil( totalItems / perPage ); | |
| return { totalItems, totalPages }; | |
| } | |
| export function removeDummyDataViewPrefix( dataView: string ) { | |
| return dataView.replace( DUMMY_DATA_VIEW_PREFIX, '' ); | |
| } | |