From d4d3d8d944cb19f046a418fd5cdb164ca55f9829 Mon Sep 17 00:00:00 2001 From: Loi Phan Date: Tue, 24 Oct 2023 15:38:47 +0700 Subject: [PATCH] Add content for user page --- hotel-management/src/commons/styles/Button.ts | 15 ++++ .../src/commons/styles/Direction.ts | 29 +++++++ hotel-management/src/constants/sampleData.ts | 68 ++++++++++++++++ hotel-management/src/pages/User.tsx | 15 ---- hotel-management/src/pages/User/UserTable.tsx | 81 +++++++++++++++++++ hotel-management/src/pages/User/index.tsx | 22 +++++ hotel-management/src/pages/User/styled.ts | 20 +++++ 7 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 hotel-management/src/commons/styles/Button.ts create mode 100644 hotel-management/src/commons/styles/Direction.ts create mode 100644 hotel-management/src/constants/sampleData.ts delete mode 100644 hotel-management/src/pages/User.tsx create mode 100644 hotel-management/src/pages/User/UserTable.tsx create mode 100644 hotel-management/src/pages/User/index.tsx create mode 100644 hotel-management/src/pages/User/styled.ts diff --git a/hotel-management/src/commons/styles/Button.ts b/hotel-management/src/commons/styles/Button.ts new file mode 100644 index 0000000..40ca5b3 --- /dev/null +++ b/hotel-management/src/commons/styles/Button.ts @@ -0,0 +1,15 @@ +import styled from 'styled-components'; + +const Button = styled.button` + padding: 10px 20px; + + background-color: var(--primary-color); + color: var(--light-text); + text-transform: uppercase; + font-weight: 500; + cursor: pointer; + + border-radius: var(--radius-md); +`; + +export default Button; diff --git a/hotel-management/src/commons/styles/Direction.ts b/hotel-management/src/commons/styles/Direction.ts new file mode 100644 index 0000000..787a6e5 --- /dev/null +++ b/hotel-management/src/commons/styles/Direction.ts @@ -0,0 +1,29 @@ +import styled, { css } from 'styled-components'; + +interface IDirection { + type?: 'vertical' | 'horizontal'; +} + +const Direction = styled.div` + display: flex; + + ${(props) => + props.type === 'horizontal' && + css` + justify-content: space-between; + align-items: center; + `} + + ${(props) => + props.type === 'vertical' && + css` + flex-direction: column; + gap: 20px; + `} +`; + +Direction.defaultProps = { + type: 'vertical', +}; + +export default Direction; diff --git a/hotel-management/src/constants/sampleData.ts b/hotel-management/src/constants/sampleData.ts new file mode 100644 index 0000000..c851dec --- /dev/null +++ b/hotel-management/src/constants/sampleData.ts @@ -0,0 +1,68 @@ +import { TUser } from '../globals/types'; + +export const sampleData: TUser[] = [ + { + id: '123', + name: 'Nezumi', + identifiedCode: '123', + phone: '0937425123', + roomId: '246', + address: 'Da Nang', + }, + { + id: '456', + name: 'Nezumi', + identifiedCode: '123', + phone: '123', + roomId: '246', + address: 'Da Nang', + }, + { + id: '231', + name: 'Nezumi', + identifiedCode: '123', + phone: '123', + roomId: '246', + address: 'Da Nang', + }, + { + id: '241', + name: 'Nezumi', + identifiedCode: '123', + phone: '123', + roomId: '246', + address: 'Da Nang', + }, + { + id: '512', + name: 'Nezumi', + identifiedCode: '123', + phone: '123', + roomId: '246', + address: 'Da Nang', + }, + { + id: '524', + name: 'Nezumi', + identifiedCode: '123', + phone: '123', + roomId: '246', + address: 'Da Nang', + }, + { + id: '125', + name: 'Nezumi', + identifiedCode: '123', + phone: '123', + roomId: '246', + address: 'Da Nang', + }, + { + id: '111', + name: 'Nezumi', + identifiedCode: '123', + phone: '123', + roomId: '246', + address: 'Da Nang', + }, +]; diff --git a/hotel-management/src/pages/User.tsx b/hotel-management/src/pages/User.tsx deleted file mode 100644 index 6d85050..0000000 --- a/hotel-management/src/pages/User.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import styled from 'styled-components'; - -const StyledUser = styled.main` - padding: 20px; -`; - -const User = () => { - return ( - -

User page

-
- ); -}; - -export default User; diff --git a/hotel-management/src/pages/User/UserTable.tsx b/hotel-management/src/pages/User/UserTable.tsx new file mode 100644 index 0000000..c5a6780 --- /dev/null +++ b/hotel-management/src/pages/User/UserTable.tsx @@ -0,0 +1,81 @@ +// Components +import { HiSquare2Stack } from 'react-icons/hi2'; +import { HiTrash } from 'react-icons/hi'; +import { StyledOperationTable } from './styled'; +import Menus from '../../components/Menus/Menus'; +import Table from '../../components/Table'; +import Direction from '../../commons/styles/Direction'; +import Empty from '../../components/Message'; + +// Types +import { TUser } from '../../globals/types'; + +// Constants +import { sampleData } from '../../constants/sampleData'; + +type TUserModal = { user: TUser }; + +const UserRow = ({ user }: TUserModal) => { + const handleOnClick = (id: string) => { + alert(`Id: ${id}`); + }; + + return ( + +
{user.id}
+
{user.name}
+
{user.identifiedCode}
+
{user.phone}
+
{user.roomId}
+ + + + + + } + onClick={() => handleOnClick(user.id)} + > + Edit + + } + onClick={() => handleOnClick(user.id)} + > + Delete + + + +
+ ); +}; + +const UserTable = () => { + return sampleData.length > 0 ? ( + + +

Sort / Filter / Search table

+
+ + + + +
Id
+
Name
+
Identified Code
+
Phone
+
Room
+
+ + data={sampleData} + render={(user: TUser) => } + /> +
+
+
+ ) : ( + No data to show here! + ); +}; + +export default UserTable; diff --git a/hotel-management/src/pages/User/index.tsx b/hotel-management/src/pages/User/index.tsx new file mode 100644 index 0000000..d6cda30 --- /dev/null +++ b/hotel-management/src/pages/User/index.tsx @@ -0,0 +1,22 @@ +// Components +import Direction from '../../commons/styles/Direction'; +import Button from '../../commons/styles/Button'; +import UserTable from './UserTable'; + +// Styled +import { StyledUser, Title } from './styled'; + +const User = () => { + return ( + + + List User + + + + + + ); +}; + +export default User; diff --git a/hotel-management/src/pages/User/styled.ts b/hotel-management/src/pages/User/styled.ts new file mode 100644 index 0000000..1c1a707 --- /dev/null +++ b/hotel-management/src/pages/User/styled.ts @@ -0,0 +1,20 @@ +import styled from 'styled-components'; + +export const StyledUser = styled.main` + padding: 20px; + padding-bottom: 100px; + + display: flex; + flex-direction: column; + gap: 30px; +`; + +export const Title = styled.h2` + font-size: var(--fs-md); + color: var(--dark-text); + text-transform: capitalize; +`; + +export const StyledOperationTable = styled.div` + text-align: right; +`;