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/components/Table/styled.ts b/hotel-management/src/components/Table/styled.ts index 4906f3f..739542f 100644 --- a/hotel-management/src/components/Table/styled.ts +++ b/hotel-management/src/components/Table/styled.ts @@ -3,7 +3,7 @@ import styled from 'styled-components'; // Interfaces import { ITable } from '../../globals/interfaces'; -export const StyledTable = styled.div` +const StyledTable = styled.div` border: 1px solid var(--border-color); font-size: 20px; @@ -17,11 +17,11 @@ const CommonRow = styled.div` align-items: center; `; -export const StyledBody = styled.div` +const StyledBody = styled.div` font-size: var(--fs-sm-x); `; -export const StyledRow = styled(CommonRow)` +const StyledRow = styled(CommonRow)` padding: 20px; &:not(:last-child) { @@ -29,7 +29,7 @@ export const StyledRow = styled(CommonRow)` } `; -export const StyledHeader = styled(CommonRow)` +const StyledHeader = styled(CommonRow)` padding: 10px 20px; border-bottom: 1px solid var(--border-color); @@ -41,3 +41,5 @@ export const StyledHeader = styled(CommonRow)` text-transform: capitalize; font-weight: 600; `; + +export { StyledBody, StyledHeader, StyledRow, StyledTable }; 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..279c7f8 --- /dev/null +++ b/hotel-management/src/pages/User/UserTable.tsx @@ -0,0 +1,80 @@ +// 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 Message 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}`); + }; + + const { id, name, identifiedCode, phone, roomId } = user; + + return ( + +
{id}
+
{name}
+
{identifiedCode}
+
{phone}
+
{roomId}
+ + + + + + } + onClick={() => handleOnClick(id)} + > + Edit + + } onClick={() => handleOnClick(id)}> + Delete + + + +
+ ); +}; + +const UserTable = () => { + return sampleData.length ? ( + + +

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..f8323fe --- /dev/null +++ b/hotel-management/src/pages/User/styled.ts @@ -0,0 +1,22 @@ +import styled from 'styled-components'; + +const StyledUser = styled.main` + padding: 20px; + padding-bottom: 100px; + + display: flex; + flex-direction: column; + gap: 30px; +`; + +const Title = styled.h2` + font-size: var(--fs-md); + color: var(--dark-text); + text-transform: capitalize; +`; + +const StyledOperationTable = styled.div` + text-align: right; +`; + +export { StyledUser, Title, StyledOperationTable };