-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from kitcc-org/70-users-list-page
ユーザー一覧の実装
- Loading branch information
Showing
21 changed files
with
386 additions
and
55 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
frontend/app/components/book-detail/BookDetailControlButtons.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
frontend/app/components/common/pagination/PaginationComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Blockquote, Center } from '@mantine/core'; | ||
import { FaInfoCircle } from 'react-icons/fa'; | ||
|
||
interface NoUserComponentProps { | ||
color?: string; | ||
} | ||
|
||
const NoUserComponent = ({ color }: NoUserComponentProps) => { | ||
return ( | ||
<Center h="70dh" w="100%"> | ||
<Blockquote color={color ?? 'blue'} icon={<FaInfoCircle />} mt="xl"> | ||
ユーザーが存在しません。 | ||
</Blockquote> | ||
</Center> | ||
); | ||
}; | ||
|
||
export default NoUserComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Button } from '@mantine/core'; | ||
import { RiUserAddFill } from 'react-icons/ri'; | ||
|
||
const UserAddButton = () => { | ||
return ( | ||
<Button | ||
color="blue" | ||
variant="filled" | ||
radius="xl" | ||
leftSection={<RiUserAddFill />} | ||
component="a" | ||
href="users/add" | ||
> | ||
ユーザー追加 | ||
</Button> | ||
); | ||
}; | ||
|
||
export default UserAddButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Button } from '@mantine/core'; | ||
|
||
interface UserDeleteButtonProps { | ||
id: number; | ||
handleDeleteUserButtonClick: (id: number) => void; | ||
} | ||
|
||
const UserDeleteButton = ({ | ||
id, | ||
handleDeleteUserButtonClick, | ||
}: UserDeleteButtonProps) => { | ||
return ( | ||
<Button | ||
color="red" | ||
variant="light" | ||
bd="solid 2px" | ||
onClick={() => handleDeleteUserButtonClick(id)} | ||
> | ||
削除 | ||
</Button> | ||
); | ||
}; | ||
|
||
export default UserDeleteButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Container, Stack } from '@mantine/core'; | ||
import UsersListTitle from './UsersListTitle'; | ||
import ContentsHeader from '../common/pagination/ContentsHeader'; | ||
import type { PaginationProps } from '~/types/paginatiion'; | ||
import PaginationComponent from '../common/pagination/PaginationComponent'; | ||
import ErrorComponent from '../common/error/ErrorComponent'; | ||
import { getUsersResponse } from 'client/client'; | ||
import UsersListTable from './UsersListTable'; | ||
import UserAddButton from './UserAddButton'; | ||
|
||
interface UsersListComponentProps { | ||
paginationProps: PaginationProps; | ||
usersResponse: getUsersResponse; | ||
handleDeleteUserButtonClick: (id: number) => void; | ||
} | ||
|
||
const UsersListComponent = ({ | ||
paginationProps, | ||
usersResponse, | ||
handleDeleteUserButtonClick, | ||
}: UsersListComponentProps) => { | ||
return ( | ||
<Container> | ||
<Stack | ||
bg="var(--mantine-color-body)" | ||
align="center" | ||
justify="center" | ||
maw="100%" | ||
> | ||
<UsersListTitle /> | ||
<ContentsHeader | ||
page={paginationProps.page} | ||
limit={paginationProps.limit} | ||
total={paginationProps.total} | ||
handleLimitChange={paginationProps.handleLimitChange} | ||
/> | ||
{usersResponse.status === 200 ? ( | ||
<UsersListTable | ||
users={usersResponse.data.users} | ||
handleDeleteUserButtonClick={handleDeleteUserButtonClick} | ||
/> | ||
) : ( | ||
<ErrorComponent message={'ユーザー情報を取得できませんでした。'} /> | ||
)} | ||
<UserAddButton /> | ||
<PaginationComponent | ||
total={paginationProps.total} | ||
page={paginationProps.page} | ||
limit={paginationProps.limit} | ||
handlePaginationChange={paginationProps.handlePaginationChange} | ||
/> | ||
</Stack> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default UsersListComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { rem, Table } from '@mantine/core'; | ||
import { GetUsers200UsersItem } from 'client/client.schemas'; | ||
import UserDeleteButton from './UserDeleteButton'; | ||
import NoUserComponent from './NoUserComponent'; | ||
|
||
interface UsersTableProps { | ||
users: GetUsers200UsersItem[]; | ||
handleDeleteUserButtonClick: (id: number) => void; | ||
} | ||
|
||
const UsersListTable = ({ | ||
users, | ||
handleDeleteUserButtonClick, | ||
}: UsersTableProps) => { | ||
if (users.length === 0) return <NoUserComponent />; | ||
return ( | ||
<Table striped maw="50%"> | ||
<Table.Tbody> | ||
{users.map((user) => ( | ||
<Table.Tr key={user.id}> | ||
{user.id && ( | ||
<> | ||
<Table.Td>{user.name}</Table.Td> | ||
<Table.Td maw={rem(5)}> | ||
<UserDeleteButton | ||
id={user.id} | ||
handleDeleteUserButtonClick={handleDeleteUserButtonClick} | ||
/> | ||
</Table.Td> | ||
</> | ||
)} | ||
</Table.Tr> | ||
))} | ||
</Table.Tbody> | ||
</Table> | ||
); | ||
}; | ||
|
||
export default UsersListTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Center, Group, Title } from '@mantine/core'; | ||
import { FaUsers } from 'react-icons/fa'; | ||
|
||
const UsersListTitle = () => { | ||
return ( | ||
<Center> | ||
<Group justify="center" align="center"> | ||
<FaUsers size="3.5ch" /> | ||
<Title order={1}>ユーザー一覧</Title> | ||
</Group> | ||
</Center> | ||
); | ||
}; | ||
|
||
export default UsersListTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.