// Components import Table from '@src/components/Table'; import Message from '@src/components/Message'; import Search from '@src/components/Search'; import SortBy from '@src/components/SortBy'; import OrderBy from '@src/components/OrderBy'; // Constants import { ORDERBY_OPTIONS, USER_PAGE } from '@src/constants/commons'; // Styled import Direction from '@src/commons/styles/Direction'; import { StyledOperationTable } from './styled'; import Spinner from '@src/commons/styles/Spinner'; // Hooks import { useUsers } from '@src/hooks/users/useUsers'; import { ColumnProps } from '@src/types/common'; import { IUser } from '@src/types/user'; interface IUserTable extends Omit{ isBooked: string; onClick: () => void; } const UserTable = () => { const columns: ColumnProps[] = [ { key: 'id', title: 'Id', width: 10, }, { key: 'name', title: 'Name', width: 35, }, { key: 'phone', title: 'Phone', width: 30, }, { key: 'isBooked', title: 'Is Booked', width: 20, }, ]; const { isLoading, users, count } = useUsers(); const tempUsers = users?.map((user) => ({ ...user, isBooked: user.isBooked ? 'Yes' : 'No', onClick: () => console.log(user), })); return ( <> {isLoading && } {tempUsers && tempUsers.length ? ( columns={columns} rows={tempUsers} count={count}/> ) : ( !isLoading && No data to show here! )} ); }; export default UserTable;