generated from muratkeremozcan/react-cypress-ts-vite-template
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #87 from cesarhenrq/qa
Qa
- Loading branch information
Showing
36 changed files
with
456 additions
and
251 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
47 changes: 47 additions & 0 deletions
47
src/components/CityTechTrendsChart/CityTechTrendsChart.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,47 @@ | ||
import { useContext } from 'react'; | ||
|
||
import Chart from '@components/Chart'; | ||
|
||
import useResource from '@hooks/useResource'; | ||
import useFetchResource from '@hooks/useFetchResource'; | ||
|
||
import { filtersContext } from '@contexts/filters'; | ||
|
||
const CityTechTrendsChart = () => { | ||
const { filters } = useContext(filtersContext); | ||
|
||
const url = filters.technologies[0] | ||
? `vacancies?technologies=${filters.technologies[0]}` | ||
: 'vacancies?technologies=React'; | ||
|
||
const label = ( | ||
<span> | ||
Cidades quem mais procuram por{' '} | ||
<span>{filters.technologies[0] ? filters.technologies[0] : 'React'}</span> | ||
</span> | ||
); | ||
|
||
const [vacancies, vacanciesService] = useResource<Vacancy>(url); | ||
|
||
useFetchResource(vacanciesService, [url]); | ||
|
||
const cityCounts = vacancies.reduce<{ [key: string]: number }>( | ||
(acc, vacancy) => { | ||
const city = vacancy.location; | ||
acc[city] = (acc[city] || 0) + 1; | ||
return acc; | ||
}, | ||
{}, | ||
); | ||
|
||
const cityData = Object.entries(cityCounts).map(([city, count]) => ({ | ||
name: city, | ||
qty: count, | ||
})); | ||
|
||
cityData.sort((a, b) => b.qty - a.qty); | ||
|
||
return <Chart label={label} data={cityData} />; | ||
}; | ||
|
||
export default CityTechTrendsChart; |
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 @@ | ||
export { default } from './CityTechTrendsChart'; |
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,44 @@ | ||
import Chart from '@components/Chart'; | ||
|
||
import useResource from '@hooks/useResource'; | ||
import useFetchResource from '@hooks/useFetchResource'; | ||
|
||
const CountryTechTrends = () => { | ||
const [vacancies, vacanciesService] = useResource<Vacancy>('vacancies'); | ||
|
||
useFetchResource(vacanciesService); | ||
|
||
const label = ( | ||
<span> | ||
Tecnologias mais procuradas em <span>Brasil</span> | ||
</span> | ||
); | ||
|
||
const allTechnologies = vacancies.reduce<string[]>((acc, vacancy) => { | ||
vacancy.technologies.forEach(tech => { | ||
acc.push(tech.tecName); | ||
}); | ||
return acc; | ||
}, []); | ||
|
||
const technologyCount = allTechnologies.reduce<{ [key: string]: number }>( | ||
(acc, techName) => { | ||
acc[techName] = (acc[techName] || 0) + 1; | ||
return acc; | ||
}, | ||
{}, | ||
); | ||
|
||
const mostUsedTechnologies = Object.keys(technologyCount).map(techName => ({ | ||
name: techName, | ||
qty: technologyCount[techName], | ||
})); | ||
|
||
mostUsedTechnologies.sort((a, b) => b.qty - a.qty); | ||
|
||
const top5Technologies = mostUsedTechnologies.slice(0, 5); | ||
|
||
return <Chart label={label} data={top5Technologies} />; | ||
}; | ||
|
||
export default CountryTechTrends; |
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 @@ | ||
export { default } from './CountryTechTrends'; |
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.