Skip to content

Commit

Permalink
Add Loading component
Browse files Browse the repository at this point in the history
  • Loading branch information
thanwin84 authored and kmtusher97 committed Feb 15, 2025
1 parent 4fa27e8 commit f98b0c7
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/components/thanwin/ecommerce/Ecommerce.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import ProductList from './ProductList';
import FilterContainer from './FilterContainer';

import CartIcon from './CartIcon';

import { EcommerceProvider } from './ecommerContext';
import Spinner from './Spinner';
import { EcommerceProvider, useEcommerceContext } from './ecommerContext';
import Cart from './Cart';

const Ecommerce = () => {
return (
<EcommerceProvider>
<section className="w-full px-6 py-4 bg-gray-100 relative">
<div className="flex justify-between items-center">
<h1 className="flex-1 text-xl tracking-widest font-bold text-slate-900 text-center my-6">
Win Store
</h1>
<CartIcon />
</div>
<div>
<FilterContainer />
<ProductList />
</div>
<Cart />
</section>
<Content />
</EcommerceProvider>
);
};

const Content = () => {
const { isLoading } = useEcommerceContext();
if (isLoading) {
return (
<div className="bg-gray-100 py-6 h-screen">
<Spinner />
</div>
);
}
return (
<section className="w-full px-6 py-4 bg-gray-100 relative">
<div className="flex justify-between items-center">
<h1 className="flex-1 text-xl tracking-widest font-bold text-slate-900 text-center my-6">
Win Store
</h1>
<CartIcon />
</div>
<div>
<FilterContainer />
<ProductList />
</div>
<Cart />
</section>
);
};

export default Ecommerce;

0 comments on commit f98b0c7

Please sign in to comment.