import React from 'react'; import { TableCheckbox } from '@/components/admin/AdminCheckbox'; import Spinner from '@/components/elements/Spinner'; import styled from 'styled-components/macro'; import tw from 'twin.macro'; import { PaginatedResult } from '@/api/http'; export const TableHead = ({ children }: { children: React.ReactNode }) => { return ( {children} ); }; export const TableHeader = ({ name }: { name: string }) => { return ( {name}
); }; export const TableBody = ({ children }: { children: React.ReactNode }) => { return ( {children} ); }; export const TableRow = ({ children }: { children: React.ReactNode }) => { return ( {children} ); }; interface Props { data: PaginatedResult; onPageSelect: (page: number) => void; children: React.ReactNode; } const PaginationButton = styled.button<{ active?: boolean }>` ${tw`relative items-center px-3 py-1 -ml-px text-sm font-normal leading-5 transition duration-150 ease-in-out border border-neutral-500 focus:z-10 focus:outline-none focus:border-primary-300 inline-flex`}; ${props => props.active ? tw`bg-neutral-500 text-neutral-50` : tw`bg-neutral-600 text-neutral-200 hover:text-neutral-300`}; `; const PaginationArrow = styled.button` ${tw`relative inline-flex items-center px-1 py-1 text-sm font-medium leading-5 transition duration-150 ease-in-out border border-neutral-500 bg-neutral-600 text-neutral-400 hover:text-neutral-200 focus:z-10 focus:outline-none focus:border-primary-300 active:bg-neutral-100 active:text-neutral-500`}; `; export function Pagination ({ data: { pagination }, onPageSelect, children }: Props) { const isFirstPage = pagination.currentPage === 1; const isLastPage = pagination.currentPage >= pagination.totalPages; /* const pages = []; const start = Math.max(pagination.currentPage - 2, 1); const end = Math.min(pagination.totalPages, pagination.currentPage + 5); for (let i = start; i <= start + 3; i++) { pages.push(i); } for (let i = end; i >= end - 3; i--) { pages.push(i); } */ const setPage = (page: number) => { if (page < 1 || page > pagination.totalPages) { return; } onPageSelect(page); }; return ( <> {children}

Showing {((pagination.currentPage - 1) * pagination.perPage) + 1} to {((pagination.currentPage - 1) * pagination.perPage) + pagination.count} of {pagination.total} results

{ isFirstPage && isLastPage ? null :
}
); } export const Loading = () => { return (
); }; export const NoItems = () => { return (
{'No

No items could be found, it's almost like they are hiding.

); }; interface Params { checked: boolean; onSelectAllClick: (e: React.ChangeEvent) => void; children: React.ReactNode; } export const ContentWrapper = ({ checked, onSelectAllClick, children }: Params) => { return ( <>
{children} ); }; export default ({ children }: { children: React.ReactNode }) => { return (
{children}
); };