import React, { ReactElement } from 'react';
import LayoutAuthenticated from '../../layouts/Authenticated';
import { fetch } from '../../stores/users/usersSlice';
import EntityRecordViewPage from '../../components/EntityPage/EntityRecordViewPage';

const UsersView = () => (
  <EntityRecordViewPage
    singularLabel="User"
    pluralLabel="Users"
    stateKey="users"
    recordKey="users"
    fetchRecord={fetch}
    listHref="/users/users-list"
    editHref={(id) => `/users/users-edit/?id=${id ?? ''}`}
  />
);

UsersView.getLayout = function getLayout(page: ReactElement) {
  return <LayoutAuthenticated permission={'READ_USERS'}>{page}</LayoutAuthenticated>;
};

export default UsersView;
