-
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.
Merge pull request #33 from danial117/client_dev_24
ss
- Loading branch information
Showing
17 changed files
with
260 additions
and
165 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
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,37 @@ | ||
// CMSContext.js | ||
import React, { createContext, useContext, useState, useEffect } from 'react'; | ||
|
||
// Create a context | ||
const CMSContext = createContext(); | ||
|
||
// Create a provider component | ||
export const CMSProvider = ({ children }) => { | ||
const [cmsData, setCmsData] = useState({}); | ||
|
||
|
||
|
||
|
||
|
||
useEffect(() => { | ||
const fetchCmsData = async () => { | ||
try { | ||
const response = await fetch(`${process.env.REACT_APP_API_URL}/CMS/show`); // Replace with your CMS data API endpoint | ||
const data = await response.json(); | ||
setCmsData(data[0]); | ||
} catch (error) { | ||
console.error('Failed to fetch CMS data', error); | ||
} | ||
}; | ||
|
||
fetchCmsData(); | ||
}, []); | ||
|
||
return ( | ||
<CMSContext.Provider value={cmsData}> | ||
{children} | ||
</CMSContext.Provider> | ||
); | ||
}; | ||
|
||
// Custom hook to use CMS context | ||
export const useCMS = () => useContext(CMSContext); |
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
Binary file not shown.
Oops, something went wrong.