-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/tqlg 307 seo img alt title #111
base: main
Are you sure you want to change the base?
Conversation
m-borgmann
commented
Jan 31, 2025
•
edited
Loading
edited
- add seo relevant alt tags and titles to all img tags in the project with sensible fallbacks where possible
- unify order lineItem styling for order finish, edit and account
- only show customerComment if it was used
- load seo urls in cartItemStore
- use new useLineItemRoute composable to get seoUrls for lineItems
- no longer link promotion product name
- fix error when trying to remove a promotion from cart
…ith sensible fallbacks where possible
components/Order/OrderLineItem.vue
Outdated
:alt="lineItemCover.alt ?? lineItem?.translated?.name" | ||
:title="lineItemCover.title ?? lineItem?.translated?.name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't you use getTranslatedProperty
? same question for the following files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use it initially, because getTranslatedProperty
returns an empty string if it can't find a matching value. This breaks the nullish coalescent operator ??
because an empty string is falsy, but not nullish. I fixed it by using the logical or operator ||
instead whenever there is another fallback after one that is called with getTranslatedProperty
, which works as intended here.
… show customerComment if it was used
…longer link promotion product name, fix error when trying to remove a promotion from cart
getTranslatedProperty(option.media, 'title') ?? | ||
option.media.fileName | ||
" | ||
:alt="getTranslatedProperty(option.media, 'alt') || option.media.fileName" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we not extract this in a method? we used it in a few places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean here 🤔 do you want a function which takes a preferred and a fallback value as parameters and returns the matching one? if so, i am not sure what the advantage would be over using the operators here 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i thought it would be beneficial to not copy paste the operator over again and use a function. also to guarantee that its always the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to disagree here. Imo wrapping this and similar calls in a function would look quite bloated. The issue also is, that we would need another parameter for the operator, making the function call even longer, since some calls work with ??
while others need ||
because getTranslatedProperty
returns an empty string which wont work with ??
if it is the first argument. Because of these differences in the calls I don't see a benefit by using a function
@@ -0,0 +1,38 @@ | |||
import type { Schemas } from '@shopware/api-client/api-types'; | |||
|
|||
export function useLineItemRoute() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also have a useProductRoute. could we not merge them to one composable? and also use the same structure as we did for example in useMedia?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially actually added the function to that composable but then split them up :D if you prefer it we can group them together though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up to you :D i prefer less composables with more logic in it but i dont think we have a guideline for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually ended up keeping the lineItem but removing the useProductRoute composable. The useProductRoute is already provided by shopware. We had just modified it before to sort of work with lineItems but this implementation is better. Thus I changed the few places where it was used to either use this new one or the default provided by shopware
|
||
const { apiClient } = useShopwareContext(); | ||
|
||
const { data: seoUrls } = await apiClient.invoke('readSeoUrl post /seo-url', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does an include make sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The response of that endpoint is actually pretty small since it only returns the seoUrl entity, see: https://shopware.stoplight.io/docs/store-api/a5120c0fde5df-fetch-seo-routes - I dont think we would benefit much from an include here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its better to really just load the things we need (even if its in this case not that much we load without an include)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you are right 👍 I added an includes here