-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conversão de requisição ao back utilizando Api.tsx
- Loading branch information
1 parent
a07bb0e
commit bd4906c
Showing
2 changed files
with
39 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { createContext, SetStateAction, useState, Dispatch, ReactNode, useEffect } from 'react'; | ||
import { collaboratorType, indicatorType, managerType, metasMesIndicadorType } from '../types'; | ||
import axios from 'axios'; | ||
import Api from '../Api'; | ||
|
||
interface VfoodsContextType { | ||
allCollaborators: collaboratorType[]; | ||
|
@@ -33,16 +34,21 @@ export function VfoodsProvider({ children }: VfoodsProviderProps) { | |
// TODO: get manager id from backend | ||
const tempId = '[email protected]' | ||
try { | ||
const url = 'http://localhost:3000/gestor/' + tempId | ||
|
||
const response = axios.get(url) | ||
|
||
const man = (await response).data | ||
|
||
setManager(man) | ||
getCollaborators(man) | ||
getIndicators(man) | ||
|
||
const url = 'gestor/' + tempId | ||
|
||
// const response = axios.get(url) | ||
|
||
Api.get(url).then(response => { | ||
const man = response.data | ||
setManager(man) | ||
getCollaborators(man) | ||
getIndicators(man) | ||
}) | ||
/* | ||
console.log(manager); | ||
console.log(allCollaborators); | ||
console.log(allIndicators); | ||
*/ | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
|
@@ -51,12 +57,13 @@ export function VfoodsProvider({ children }: VfoodsProviderProps) { | |
const getCollaborators = async (manager: managerType) => { | ||
const urlEmail = manager.email | ||
try { | ||
const url = 'http://localhost:3000/gestor/colaboradores/' + urlEmail | ||
const response = axios.get(url) | ||
|
||
const collab = (await response).data | ||
setAllCollab(collab) | ||
console.log(allCollaborators) | ||
const url = 'gestor/colaboradores/' + urlEmail | ||
//const response = axios.get(url) | ||
Api.get(url).then(response => { | ||
const collab = response.data | ||
setAllCollab(collab) | ||
console.log(allCollaborators); | ||
}) | ||
|
||
} catch (error) { | ||
console.log(error) | ||
|
@@ -66,12 +73,15 @@ export function VfoodsProvider({ children }: VfoodsProviderProps) { | |
const getIndicators = async (manager: managerType) => { | ||
const urlID = manager.id | ||
try { | ||
const url = 'http://localhost:3000/indicador/' + urlID | ||
const response = axios.get(url) | ||
|
||
const ind = (await response).data | ||
setAllIndicators(ind) | ||
console.log(allIndicators) | ||
const url = 'indicador/' + urlID | ||
|
||
Api.get(url).then(response => { | ||
// console.log(response) | ||
const ind = response.data | ||
setAllIndicators(ind) | ||
// console.log(allIndicators); | ||
|
||
}) | ||
|
||
} catch (error) { | ||
console.log(error) | ||
|