-
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 #10 from abdulsamad/develop
Completed more features and Updated README
- Loading branch information
Showing
18 changed files
with
3,140 additions
and
2,986 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 |
---|---|---|
@@ -1,19 +1,44 @@ | ||
import React from 'react'; | ||
import type { NextPage } from 'next'; | ||
import type { NextPage, GetServerSideProps } from 'next'; | ||
import { dehydrate, QueryClient, useQuery } from '@tanstack/react-query'; | ||
|
||
import { getProducts } from '@api/admin'; | ||
import AdminLayout from '@components/admin/layout'; | ||
import Product from '@components/admin/product'; | ||
|
||
const Index: NextPage = () => { | ||
const { data, isLoading } = useQuery({ queryKey: ['orders'], queryFn: getProducts }); | ||
|
||
return ( | ||
<AdminLayout | ||
isLoading={isLoading} | ||
title={ | ||
<> | ||
Manage <span className="text-primary">Products</span> | ||
</> | ||
}> | ||
<h1 className="text-center">Coming soon...</h1> | ||
<section className="space-y-5 py-4 text-center"> | ||
{data?.products.map((product) => ( | ||
<Product key={product._id} {...product} /> | ||
))} | ||
</section> | ||
</AdminLayout> | ||
); | ||
}; | ||
|
||
export const getServerSideProps: GetServerSideProps = async () => { | ||
const queryClient = new QueryClient(); | ||
|
||
await queryClient.prefetchQuery({ | ||
queryKey: ['products'], | ||
queryFn: getProducts, | ||
}); | ||
|
||
return { | ||
props: { | ||
dehydratedState: dehydrate(queryClient), | ||
}, | ||
}; | ||
}; | ||
|
||
export default Index; |
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
Oops, something went wrong.