-
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.
Co-authored-by: javikalsan <jcalzadosanchez@gmail.com>
- Loading branch information
Showing
3 changed files
with
72 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react' | ||
import { useAuth } from './AuthProvider' | ||
import ovapi from '../services/ovapi' | ||
|
||
const InstallationContext = React.createContext() | ||
|
||
export default function InstallationProvider({ children }) { | ||
// const [installations, setInstallations] = React.useState([]) | ||
const { currentUser } = useAuth() | ||
|
||
//const closeDialog = () => { | ||
// setDialogs((dialogs) => { | ||
// const latestDialog = dialogs.pop() | ||
// if (!latestDialog) return dialogs | ||
// if (latestDialog.onClose) latestDialog.onClose() | ||
// return [...dialogs].concat({ ...latestDialog, open: false }) | ||
// }) | ||
//} | ||
|
||
|
||
// const reloadUser = () => { | ||
// ov.currentUser().then((user) => setCurrentUser(user)) | ||
// } | ||
|
||
const getInstallations = () => { | ||
return ovapi.installations(currentUser) | ||
.then((data) => { | ||
// setInstallations(data); | ||
// setLoading(false); | ||
console.log(data); | ||
return data; | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
// setLoading(false); | ||
// throw error; | ||
}); | ||
}; | ||
|
||
|
||
// const getInstallations = () => { | ||
// return [1,2,3]// Use the data here or perform additional actions | ||
// }; | ||
|
||
|
||
|
||
const contextValue = getInstallations() | ||
|
||
return ( | ||
<InstallationContext.Provider value={contextValue}> | ||
{children} | ||
</InstallationContext.Provider> | ||
) | ||
} | ||
|
||
export const useInstallationContext = () => React.useContext(InstallationContext) |
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