-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Hugo Marques <[email protected]>
- Loading branch information
1 parent
b5f254b
commit 04465fe
Showing
29 changed files
with
1,388 additions
and
47 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
54 changes: 54 additions & 0 deletions
54
src/components/MicrocreditDashboardProvider/MicrocreditDashboardProvider.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { createContext } from 'react'; | ||
|
||
const initialData: { | ||
data?: { | ||
[key: string]: number; | ||
}; | ||
} = { | ||
data: { | ||
activeBorrowers: 0, | ||
apr: 0, | ||
avgBorrowedAmount: 0, | ||
currentDebt: 0, | ||
earnedInterest: 0, | ||
estimatedMaturity: 0, | ||
inReview: 0, | ||
liquidityAvailable: 0, | ||
paidBack: 0, | ||
totalApplicants: 0, | ||
totalBorrowed: 0, | ||
totalDebitsRepaid: 0 | ||
} | ||
}; | ||
|
||
export const MicrocreditDashboardContext = createContext(initialData); | ||
|
||
type ProviderProps = { | ||
children?: any; | ||
data: { | ||
activeBorrowers: number; | ||
apr: number; | ||
avgBorrowedAmount: number; | ||
currentDebt: number; | ||
earnedInterest: number; | ||
estimatedMaturity: number; | ||
inReview: number; | ||
liquidityAvailable: number; | ||
paidBack: number; | ||
totalApplicants: number; | ||
totalBorrowed: number; | ||
totalDebtisRepaid: number; | ||
}; | ||
}; | ||
|
||
export const MicrocreditDashboardProvider = ({ children, data }: ProviderProps) => { | ||
return <MicrocreditDashboardContext.Provider value={{ data }}>{children}</MicrocreditDashboardContext.Provider>; | ||
}; | ||
|
||
export const useData = () => { | ||
const { data } = React.useContext(MicrocreditDashboardContext); | ||
|
||
return data; | ||
}; | ||
|
||
export const MicrocreditDashboardConsumer = MicrocreditDashboardContext.Consumer; |
This file was deleted.
Oops, something went wrong.
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,65 @@ | ||
import { Div, Row, Text } from '../../theme/components'; | ||
import { MicrocreditDashboardProvider } from '../../components/MicrocreditDashboardProvider/MicrocreditDashboardProvider'; | ||
import { colors } from '../../theme'; | ||
import { usePrismicData } from '../../lib/Prismic/components/PrismicDataProvider'; | ||
import Api from '../../apis/api'; | ||
import React, { useEffect, useState } from 'react'; | ||
import Slices from '../../lib/Prismic/components/Slices'; | ||
import styled from 'styled-components'; | ||
|
||
const HeadingRow = styled(Row)` | ||
align-items: center; | ||
flex-direction: column; | ||
max-width: 800px; | ||
text-align: center; | ||
margin: 2rem auto 0 auto; | ||
`; | ||
|
||
export const MicrocreditDashboard = () => { | ||
const { page } = usePrismicData(); | ||
const slices = page?.data?.body; | ||
const { heading, smallHeading } = page?.data; | ||
const [microcreditData, setMicrocreditData] = useState() as any; | ||
|
||
useEffect(() => { | ||
const getMicrocredit = async () => { | ||
const microcreditData = await Api.getMicrocreditData(); | ||
|
||
setMicrocreditData(microcreditData); | ||
}; | ||
|
||
getMicrocredit(); | ||
}, []); | ||
|
||
return ( | ||
<MicrocreditDashboardProvider data={microcreditData?.data}> | ||
<Div sFlexDirection="column" style={{ backgroundColor: colors.p25 }}> | ||
<HeadingRow> | ||
{smallHeading && ( | ||
<Text sColor={colors.p700} sFontWeight={600}> | ||
{smallHeading} | ||
</Text> | ||
)} | ||
{heading && ( | ||
<Text | ||
mt={0.75} | ||
sColor={colors.g900} | ||
sFontSize={{ | ||
md: 3, | ||
xs: 2 | ||
}} | ||
sFontWeight={600} | ||
sLineHeight={{ | ||
md: 2.75, | ||
xs: 2.5 | ||
}} | ||
> | ||
{heading} | ||
</Text> | ||
)} | ||
</HeadingRow> | ||
<Slices slices={slices} /> | ||
</Div> | ||
</MicrocreditDashboardProvider> | ||
); | ||
}; |
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,10 @@ | ||
import { usePrismicData } from '../../lib/Prismic/components/PrismicDataProvider'; | ||
import React from 'react'; | ||
import Slices from '../../lib/Prismic/components/Slices'; | ||
|
||
export const Microcredit = () => { | ||
const { page } = usePrismicData(); | ||
const slices = page?.data?.body; | ||
|
||
return <Slices slices={slices} />; | ||
}; |
31 changes: 31 additions & 0 deletions
31
src/page-components/Ubi/Dashboard/ChartGroups/ChartGroups.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { GlobalDashboardChartGroup } from './GlobalDashboardChartGroup'; | ||
import { IGlobalDashboard } from '../../../../apis/types'; | ||
import React from 'react'; | ||
|
||
type ChartGroupsProps = { | ||
data?: IGlobalDashboard; | ||
items?: { | ||
[key: string]: { | ||
charts: any[]; | ||
}; | ||
}; | ||
}; | ||
|
||
export const ChartGroups = (props: ChartGroupsProps) => { | ||
const { data, items } = props; | ||
const chartGroups = ['distribution', 'fundraising', 'economic']; | ||
|
||
return ( | ||
<> | ||
{chartGroups.map((name, index) => ( | ||
<GlobalDashboardChartGroup | ||
data={data} | ||
key={index} | ||
name={name} | ||
pb={index + 1 === chartGroups.length ? { sm: 4, xs: 2 } : 0} | ||
{...items[name]} | ||
/> | ||
))} | ||
</> | ||
); | ||
}; |
42 changes: 42 additions & 0 deletions
42
src/page-components/Ubi/Dashboard/ChartGroups/GlobalDashboardChartGroup.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { DashboardChartGroup } from '../../../../components'; | ||
import { IGlobalDashboard } from '../../../../apis/types'; | ||
import { distribution } from '../../../../apis/distribution'; | ||
import { economic } from '../../../../apis/economic'; | ||
import { fundraising } from '../../../../apis/fundraising'; | ||
import { useTranslation } from '../../../../components/TranslationProvider/TranslationProvider'; | ||
import React from 'react'; | ||
|
||
const api: { [key: string]: any } = { | ||
distribution, | ||
economic, | ||
fundraising | ||
}; | ||
|
||
type GlobalDashboardChartGroupProps = { | ||
data?: IGlobalDashboard; | ||
charts: any[]; | ||
name: string; | ||
pb: object | number; | ||
}; | ||
|
||
export const GlobalDashboardChartGroup = (props: GlobalDashboardChartGroupProps) => { | ||
const { data, charts, name, ...forwardProps } = props; | ||
const { t } = useTranslation(); | ||
|
||
const chartsConfig = charts.map(({ labelKey, name: helper }) => { | ||
const helperData = api[name][helper] ? api[name][helper](data, t) : {}; | ||
|
||
return { | ||
...helperData, | ||
heading: t(labelKey || helper) | ||
}; | ||
}); | ||
|
||
const composedProps = { | ||
...forwardProps, | ||
heading: t(`page.globalDashboard.${name}.heading`), | ||
text: t(`page.globalDashboard.${name}.text`) | ||
}; | ||
|
||
return <DashboardChartGroup charts={chartsConfig} {...composedProps} />; | ||
}; |
Oops, something went wrong.
04465fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web – ./
www.impactmarket.com
web-git-production-ipct.vercel.app
impactmarket.com
web-ipct.vercel.app