-
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 branch 'main' of github.com:librarian-org/librarian
- Loading branch information
Showing
31 changed files
with
550 additions
and
15 deletions.
There are no files selected for viewing
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
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,64 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { FaHandshake } from 'react-icons/fa'; | ||
import { FiAlertTriangle, FiBook, FiUsers } from 'react-icons/fi'; | ||
import i18n from '../../i18n'; | ||
import Panel from '../Panel'; | ||
import PanelBody from '../Panel/PanelBody'; | ||
import PanelFooter from '../Panel/PanelFooter'; | ||
import { Container, Row, Wrapper } from './styles'; | ||
|
||
const Dashboard: React.FC = () => { | ||
const [registeredSamples, setRegisteredSamples] = useState(0); | ||
const [registeredPeople, setRegisteredPeople] = useState(0); | ||
const [activeBorrows, setActiveBorrows] = useState(0); | ||
const [overdueBorrows, setOverdueBorrows] = useState(0); | ||
|
||
useEffect(() => { | ||
const samples = window.api.sendSync('regiteredSamples') as number; | ||
setRegisteredSamples(samples); | ||
|
||
const people = window.api.sendSync('regiteredPeople') as number; | ||
setRegisteredPeople(people); | ||
|
||
const actives = window.api.sendSync('activeBorrows') as number; | ||
setActiveBorrows(actives); | ||
|
||
const overdues = window.api.sendSync('overdueBorrows') as number; | ||
setOverdueBorrows(overdues); | ||
}, []); | ||
|
||
return ( | ||
<Container> | ||
<Wrapper> | ||
<Row> | ||
<Panel color={'#fe5d70'}> | ||
<PanelBody icon={FiAlertTriangle}>{overdueBorrows}</PanelBody> | ||
<PanelFooter color={'#fe5d70'}> | ||
{i18n.t('dashboard.overdueBorrows')} | ||
</PanelFooter> | ||
</Panel> | ||
<Panel color={'#fe9365'}> | ||
<PanelBody icon={FaHandshake}>{activeBorrows}</PanelBody> | ||
<PanelFooter color={'#fe9365'}> | ||
{i18n.t('dashboard.activeBorrows')} | ||
</PanelFooter> | ||
</Panel> | ||
<Panel color={'#01a9ac'}> | ||
<PanelBody icon={FiBook}>{registeredSamples}</PanelBody> | ||
<PanelFooter color={'#01a9ac'}> | ||
{i18n.t('dashboard.registeredSamples')} | ||
</PanelFooter> | ||
</Panel> | ||
<Panel color={'#0ac282'}> | ||
<PanelBody icon={FiUsers}>{registeredPeople}</PanelBody> | ||
<PanelFooter color={'#0ac282'}> | ||
{i18n.t('dashboard.registeredPeople')} | ||
</PanelFooter> | ||
</Panel> | ||
</Row> | ||
</Wrapper> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Dashboard; |
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 styled from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100vw; | ||
padding: 24px; | ||
`; | ||
|
||
export const Wrapper = styled.div` | ||
padding: 24px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
`; | ||
|
||
export const Row = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
& > div { | ||
margin: 16px; | ||
} | ||
`; |
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,22 @@ | ||
import React from 'react'; | ||
import { IconBaseProps } from 'react-icons'; | ||
|
||
import { Container } from './styles'; | ||
|
||
interface PanelBodyProps { | ||
icon?: React.ComponentType<IconBaseProps>; | ||
} | ||
|
||
const PanelBody: React.FC<PanelBodyProps> = ({ | ||
children, | ||
icon: Icon, | ||
}) => { | ||
return ( | ||
<Container> | ||
{children} | ||
{Icon && <Icon size={30} />} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default PanelBody; |
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,9 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Container = styled.h1` | ||
display: flex; | ||
justify-content: space-between; | ||
flex-direction: row; | ||
padding: 16px; | ||
color: #D1D1D1; | ||
`; |
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,13 @@ | ||
import React from 'react'; | ||
|
||
import { Container } from './styles'; | ||
|
||
interface PanelFooterProps { | ||
color: string; | ||
} | ||
|
||
const PanelFooter: React.FC<PanelFooterProps> = ({ color, children }) => { | ||
return <Container backgroundColor={color}>{children}</Container>; | ||
}; | ||
|
||
export default PanelFooter; |
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 styled from 'styled-components'; | ||
import {shade} from 'polished'; | ||
|
||
interface ContainerProps { | ||
backgroundColor: string; | ||
} | ||
|
||
export const Container = styled.div<ContainerProps>` | ||
display: flex; | ||
flex-direction: row; | ||
width: 100%; | ||
color: #D1D1D1; | ||
background: ${props => shade(0.1, props.backgroundColor)}; | ||
border-bottom-left-radius: 10px; | ||
border-bottom-right-radius: 10px; | ||
padding: 16px; | ||
padding-top: 8px; | ||
padding-bottom: 8px; | ||
`; |
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,17 @@ | ||
import React from 'react'; | ||
|
||
import { Container } from './styles'; | ||
|
||
interface PanelProps { | ||
color: string; | ||
} | ||
|
||
const Panel: React.FC<PanelProps> = ({ color, children }) => { | ||
return ( | ||
<Container backgroundColor={color}> | ||
{children} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Panel; |
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 styled from 'styled-components'; | ||
|
||
interface ContainerProps { | ||
backgroundColor: string; | ||
} | ||
|
||
export const Container = styled.div<ContainerProps>` | ||
border-radius: 10px; | ||
display: flex; | ||
flex-direction: column; | ||
width: 90%; | ||
background-color: ${props => props.backgroundColor}; | ||
color: #D1D1D1; | ||
`; | ||
|
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
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
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.