Skip to content

Commit

Permalink
formatting & update type
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyadeorukhkar committed Feb 2, 2024
1 parent ae2091a commit 214c2eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
10 changes: 3 additions & 7 deletions packages/blade/src/components/Table/TablePagination.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import styled from 'styled-components';
import { useTableContext } from './TableContext';
import { ComponentIds } from './componentIds';
import { tablePagination } from './tokens';
import type {
TablePaginationCommonProps,
TablePaginationProps,
TablePaginationType,
} from './types';
import type { TablePaginationCommonProps, TablePaginationProps } from './types';
import isUndefined from '~utils/lodashButBetter/isUndefined';
import getIn from '~utils/lodashButBetter/get';
import BaseBox from '~components/Box/BaseBox';
Expand Down Expand Up @@ -146,7 +142,7 @@ const getPaginationButtons = ({
};
};

const _TablePagination = <T extends { paginationType: TablePaginationType }>({
const _TablePagination = ({
currentPage: controlledCurrentPage,
onPageChange,
onPageSizeChange,
Expand All @@ -157,7 +153,7 @@ const _TablePagination = <T extends { paginationType: TablePaginationType }>({
label,
totalItemCount,
paginationType = 'client',
}: TablePaginationProps<T>): React.ReactElement => {
}: TablePaginationProps): React.ReactElement => {
const {
setPaginationPage,
currentPaginationState,
Expand Down
32 changes: 16 additions & 16 deletions packages/blade/src/components/Table/docs/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1828,10 +1828,10 @@ import {
TableRow,
TableCell,
TablePagination,
} from '@razorpay/blade/components';
import React, { useEffect, useState } from 'react';
type APIResult = {
} from '@razorpay/blade/components';
import React, { useEffect, useState } from 'react';
type APIResult = {
info: {
count: number;
pages: number;
Expand All @@ -1843,9 +1843,9 @@ import {
status: string;
origin: { name: string };
}[];
};
const fetchData = async ({ page }: { page: number }): Promise<APIResult> => {
};
const fetchData = async ({ page }: { page: number }): Promise<APIResult> => {
const response = await fetch(
\`https://rickandmortyapi.com/api/character?page=\${page}\`,
{
Expand All @@ -1855,15 +1855,15 @@ import {
);
const result = await response.json();
return result as APIResult;
};
function App(): React.ReactElement {
};
function App(): React.ReactElement {
const [apiData, setApiData] = useState<{ nodes: APIResult['results'] }>({
nodes: [],
});
const [dataCount, setDataCount] = useState<number>(0);
const [isRefreshing, setIsRefreshing] = useState<boolean>(false);
useEffect(() => {
if (apiData.nodes.length === 0) {
fetchData({ page: 1 }).then((res) => {
Expand All @@ -1874,7 +1874,7 @@ import {
});
}
}, []);
const handlePageChange = ({ page }: { page: number }) => {
setIsRefreshing(true);
fetchData({ page: page + 1 }).then((res) => {
Expand All @@ -1888,7 +1888,7 @@ import {
setIsRefreshing(false);
});
};
return (
<Box
backgroundColor="surface.background.level2.lowContrast"
Expand Down Expand Up @@ -1934,9 +1934,9 @@ import {
</Table>
</Box>
);
}
export default App;
}
export default App;
`;

export {
Expand Down
11 changes: 2 additions & 9 deletions packages/blade/src/components/Table/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,8 @@ type TablePaginationClientProps = TablePaginationCommonProps & {
onPageChange?: ({ page }: { page: number }) => void;
};

type TablePaginationProps<T> = T extends {
paginationType: infer TablePaginationType;
}
? TablePaginationType extends 'server'
? TablePaginationServerProps
: TablePaginationType extends 'client'
? TablePaginationClientProps
: T
: T;
type TablePaginationProps = TablePaginationCommonProps &
(TablePaginationServerProps | TablePaginationClientProps);

type TableToolbarProps = {
/**
Expand Down

0 comments on commit 214c2eb

Please sign in to comment.