Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vue-demo): add dynamic breadcrumbs #1369

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

feat(vue-demo): add dynamic breadcrumbs #1369

wants to merge 17 commits into from

Conversation

mdanilowicz
Copy link
Collaborator

Description

closes #139

Type of change

ToDo's

Screenshots (if applicable)

Additional context

Copy link

vercel bot commented Oct 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
frontends-demo 🔄 Building (Inspect) Visit Preview Nov 14, 2024 9:40am
shopware-frontends-docs ✅ Ready (Inspect) Visit Preview Nov 14, 2024 9:40am

Copy link

pkg-pr-new bot commented Oct 17, 2024

Open in Stackblitz

@shopware/api-client

pnpm add https://pkg.pr.new/shopware/frontends/@shopware/api-client@1369

@shopware/api-gen

pnpm add https://pkg.pr.new/shopware/frontends/@shopware/api-gen@1369

@shopware-pwa/composables-next

pnpm add https://pkg.pr.new/shopware/frontends/@shopware-pwa/composables-next@1369

@shopware-pwa/cms-base

pnpm add https://pkg.pr.new/shopware/frontends/@shopware-pwa/cms-base@1369

@shopware-pwa/helpers-next

pnpm add https://pkg.pr.new/shopware/frontends/@shopware-pwa/helpers-next@1369

@shopware-pwa/nuxt3-module

pnpm add https://pkg.pr.new/shopware/frontends/@shopware-pwa/nuxt3-module@1369

commit: 108c83d

@BrocksiNet
Copy link
Collaborator

@kstala could you test this please 🙌

Copy link
Collaborator

@patzick patzick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good feature incoming! We need to clarify a few things here first :)


useBreadcrumbs(breadcrumbs);
const { buildDynamicBreadcrumbs } = useBreadcrumbs();
buildDynamicBreadcrumbs(props.navigationId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's happening asynchronously, so I have two questions:

  1. how are you assuring it's loaded on Server Side Render?
  2. isn't there a blink on client side? What about showing previous breadcrumbs and replace them when new ones are loaded? Does it make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, changed

@@ -48,8 +66,38 @@ export function useBreadcrumbs(
_breadcrumbs.value = [];
};

const getCategoryBreadcrumbs = async (categoryId: string) => {
const response = await apiClient.invoke(
"readBreadcrumb get /breadcrumb/{id}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this endpoint is not only to load category breadcrumbs, I'm not sure about exposing it here, what is the designed flow here looks like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint is only for the category breadcrumbs. For the product entity we will also receive, category breadcrumbs

return response.data;
};

const buildDynamicBreadcrumbs = async (categoryId: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about product breadcrumbs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is the same method, for product we are also getting category breadcrumbs

Comment on lines 92 to 94
} catch (error) {
console.error("Error while fetching breadcrumbs", error);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not handle errors in composable, it should be thrown to invoking component to handle in the project - analytics/notifications etc. however they need to handle it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"@shopware-pwa/composables-next": minor
---

Added `getCategoryBreadcrumbs` method for fetching backend breadcrumbs in `useBreadcrumbs` composable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the buildDynamicBreadcrumbs is more important functionality, should be mentioned and explained here more

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @param page
* @returns
*/
export function getCmsBreadcrumbs<
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this helper - it's not creating breadcrumbs, just displaying entity translated property, when would that be useful for the users?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using it to build CMS page breadcrumbs, where we always have 1 level of breadcrumbs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Category breadcrumbs path is missing
3 participants