forked from ThiagoAugustoSM/visual-curriculum
-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature] Habilitar para a criação de novos currículos e Universidades #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ItaloSa
wants to merge
6
commits into
main
Choose a base branch
from
ItaloSa/main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
92bcad8
chore: update dependencies
ItaloSa 5424d35
refactor: Move logic into hook
ItaloSa fda474e
feat: Add routering and service
ItaloSa 255e86e
feat: Add data loader
ItaloSa ad9e475
fix: remove package.json
ItaloSa 64bec87
fix: compilation errors
SteffanoP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -22,4 +22,6 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.eslintcache | ||
.eslintcache | ||
|
||
package-lock.json |
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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,14 @@ | ||
[ | ||
{ | ||
"key": "UFPE", | ||
"name": "Universidade Federal de Pernambuco", | ||
"website": "", | ||
"logo": "", | ||
"courses": [ | ||
{ | ||
"key": "engenharia-da-computacao", | ||
"name": "Engenharia da Computação" | ||
} | ||
] | ||
} | ||
Comment on lines
+2
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. É necessário refatorar e adicionar o currículo de Ciência da Computação da UFRPE, que está em |
||
] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,59 @@ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
import { useCallback, useMemo, useState, useEffect } from 'react'; | ||
import { useRouteMatch } from 'react-router-dom'; | ||
|
||
import { CurriculumType } from '../models/Curriculum'; | ||
import Service from './service'; | ||
|
||
export default function useCurriculum() { | ||
const { params } = useRouteMatch<{ university: string; course: string }>(); | ||
|
||
const [curriculum, setCurriculum] = useState< | ||
CurriculumType | Record<string, never> | ||
>({}); | ||
const [academicTotal, setAcademicTotal] = useState(0); | ||
const [academicObligatory, setAcademicObligatory] = useState(0); | ||
const [academicElective, setAcademicElective] = useState(0); | ||
const service = useMemo(() => new Service(), []); | ||
|
||
useEffect(() => { | ||
service.setCurrent(params.university, params.course); | ||
}, [params, service]); | ||
|
||
const updateState = ({ isActive, isObligatory, hours }): void => { | ||
if (isActive) { | ||
if (isObligatory) { | ||
setAcademicObligatory(academicObligatory + hours); | ||
} else { | ||
setAcademicElective(academicElective + hours); | ||
} | ||
setAcademicTotal(academicTotal + hours); | ||
} else { | ||
if (isObligatory) { | ||
setAcademicObligatory(academicObligatory - hours); | ||
} else { | ||
setAcademicElective(academicElective - hours); | ||
} | ||
setAcademicTotal(academicTotal - hours); | ||
} | ||
}; | ||
|
||
const loadCurriculum = useCallback( | ||
async (university: string, course: string) => { | ||
const data = await service.loadCurriculum(university, course); | ||
setCurriculum(data); | ||
}, | ||
[service] | ||
); | ||
|
||
return { | ||
curriculum, | ||
updateState, | ||
loadCurriculum, | ||
completed: { | ||
academicTotal, | ||
academicElective, | ||
academicObligatory, | ||
}, | ||
}; | ||
} |
This file contains hidden or 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,28 @@ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable class-methods-use-this */ | ||
|
||
import { CurriculumType } from '../models/Curriculum'; | ||
|
||
export default class Service { | ||
currentUniversity = ''; | ||
|
||
currentCourse = ''; | ||
|
||
setCurrent(university: string, course: string): void { | ||
this.currentUniversity = university; | ||
this.currentCourse = course; | ||
} | ||
|
||
async loadCurriculum( | ||
university: string, | ||
course: string | ||
): Promise<CurriculumType | Record<string, never>> { | ||
try { | ||
const response = await fetch(`/university/${university}/${course}.json`); | ||
return await (response.json() as Promise<CurriculumType>); | ||
} catch (err) { | ||
console.error(err); | ||
return {}; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Por algum motivo o
yarn
tá me mostrando um aviso de dependência (abaixo), pode ser um falso negativo, mas dá uma olhada se tá tudo certinho.