Skip to content

Commit

Permalink
feat: add loading to index pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Ellison committed Nov 19, 2023
1 parent 0ac9eee commit ee49a47
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
8 changes: 7 additions & 1 deletion pages/customers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import { ListMenu } from '@/components/dashboard/Menus'
import { usePageMenu } from "@/lib/hooks";


export default function Page({ tiles, menuStructure: initialMenuStructure, collection }) {
export default function Page({ tiles, menuStructure: initialMenuStructure, collection, loading }) {


if (loading) {
return (
<IndexView menuStructure={null} title="Customers" tiles={null} menuComponent={ListMenu} loading={true}/>
)
}
const { menuStructure } = usePageMenu(initialMenuStructure, collection);

return (
Expand Down
9 changes: 8 additions & 1 deletion pages/products/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import { HeaderMinimalMenu } from '@/components/dashboard/Menus'
import { usePageMenu } from "@/lib/hooks";


export default function Page({ tiles, menuStructure: initialMenuStructure, collection }) {
export default function Page({ tiles, menuStructure: initialMenuStructure, collection , loading}) {


if (loading) {
return (
<IndexView menuStructure={null} title="Products" tiles={null} menuComponent={HeaderMinimalMenu} loading={true}/>
)
}

const { menuStructure } = usePageMenu(initialMenuStructure, collection);

Expand Down
9 changes: 8 additions & 1 deletion pages/providers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ import { HeaderMinimalMenu } from '@/components/dashboard/Menus'
import { usePageMenu } from "@/lib/hooks";


export default function Page({ tiles, menuStructure: initialMenuStructure, collection }) {
export default function Page({ tiles, menuStructure: initialMenuStructure, collection, loading }) {



if (loading) {
return (
<IndexView menuStructure={null} title="Providers and Services" tiles={null} menuComponent={HeaderMinimalMenu} loading={true}/>
)
}
const { menuStructure } = usePageMenu(initialMenuStructure, collection);

return (
Expand Down
6 changes: 4 additions & 2 deletions pages/services/[...service].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default function Page({
menuStructure: initialMenuStructure,
collection,
controls,
context: initialContext
context: initialContext,
loading
}) {
const {
pageContent,
Expand Down Expand Up @@ -44,12 +45,13 @@ export default function Page({
<ServicesHeader {...props} extraData={controls} />
)}
sideComponent={(props) => <ControlsMenu {...props} controls={controls} />}
loading={loading}
/>
);
}

export async function getServerSideProps(context) {
console.log(context.params.service)
// console.log(context.params.service)

const file = "services/" + context.params.service.join("/");
let pageContent = "";
Expand Down
7 changes: 6 additions & 1 deletion pages/services/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ import { HeaderMinimalMenu } from '@/components/dashboard/Menus'
import { usePageMenu } from "@/lib/hooks";


export default function Page({ tiles, menuStructure: initialMenuStructure, collection }) {
export default function Page({ tiles, menuStructure: initialMenuStructure, collection, loading }) {

if (loading) {
return (
<IndexView menuStructure={null} title="Providers and Services" tiles={null} menuComponent={HeaderMinimalMenu} loading={true}/>
)
}
const { menuStructure } = usePageMenu(initialMenuStructure, collection);

return (
Expand Down
11 changes: 10 additions & 1 deletion pages/solutions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ export default function Page({ tiles, menuStructure: initialMenuStructure, colle
export async function getServerSideProps(context) {

const tiles = await getFrontMatter(siteConfig.content.solutions);


const filteredTiles = tiles.filter(tile => {
const parts = tile.file.split('/'); // Split the file path by '/'
const fileName = parts[parts.length - 1]; // Get the last part (file name)
// Check if the path has exactly 3 parts and the file name is 'index.md' or 'index.mdx'
return parts.length === 3 && (fileName === '_index.md' || fileName === '_index.mdx');
});

const menuPromise = getMenuStructure(
siteConfig,
siteConfig.content.solutions
Expand All @@ -36,7 +45,7 @@ export async function getServerSideProps(context) {
return {
props: {
menuStructure: menuStructure,
tiles: tiles,
tiles: filteredTiles,
collection: siteConfig.content.solutions,
},
};
Expand Down

0 comments on commit ee49a47

Please sign in to comment.