Closed DevonGifford closed 1 year ago
shop-data
json file products.context
(Temporarily breaks the shop page but after pushing the data up we will access the data via FireSotre)FireBase.utils
;Bringing in two new methods
addCollectionandDocuments
function
key
- this wll be the name of the collectionobject
- this will be the data batch
and collection
methodsProducts.Context
;Imported the new SHOP_DATA
Imported teh new addCollectionandDocuments
Imported teh useEffect
Hook
Using the useEffect as I only want this to run literally once, thus commenting out after it's single use
Saving - confirming the useEffect and function worked - it Did!
Commenting out the useEffect
FireBase.utils
;Bringing in the querey method
Created a getCategoriesAndDocuments
function
collectionRef
we want access tooquerey
on our collectionRef
Products.Context
;Imported the new getCategoriesAndDocuments
function
Created a useEffect Hook to fetch the data
CategoryMap
dataIn the ProductsContext
ProductsContext
to CategoriesContext
main.jsx
to reflect changeshop.component
to reflect change (more required)
ProductsContext
to CategoriesContext
ProducstProvider
to CategoriesProvider
categoriesMap
as an objectsetCategoriesMap
function using (CategoryMap
)shop.component
return structureProductsContext
Fragment
to wrap the entire returnObject.keys
to turn keys into an array fragment
categoriesMap