Conversation
…icks map rendering on mobile (#785)
…veryone seems to think.... but secretly I'm-- (#786) ## cmueats ❤️ Hatsune Miku <img width="1280" height="710" alt="image" src="https://github.com/user-attachments/assets/6db3ea46-d5ae-4558-8714-5b5d4538446e" /> https://staging.cmueats.com/?force-miku-day
thank u @pebble-fish for the art ❤️
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Going to add clicking on image to expand |
| ).map(({ default: menuUrl }) => { | ||
| const filename = menuUrl.split('/').pop() || ''; | ||
| return { | ||
| src: menuUrl, | ||
| alt: filename, | ||
| }; | ||
| }); | ||
|
|
||
| const menuUrlMap = Object.fromEntries(menuUrls.map((item) => [item.alt, item.src])); |
There was a problem hiding this comment.
Bug: The image lookup logic relies on matching filenames, which will likely fail in production builds where asset filenames are hashed by Vite, preventing images from being displayed.
Severity: HIGH
Suggested Fix
To ensure a reliable lookup, avoid relying on the final filename. Instead, use the original module path keys provided by import.meta.glob directly. The API should provide a path segment that can be used to uniquely identify the image within the src/assets/images/menu_items directory, which can then be used to find the correct key in the imageModules map without splitting the path.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/components/DrawerTabContent.tsx#L76-L84
Potential issue: The component dynamically loads menu images using `import.meta.glob`.
It then finds the correct image by matching a filename from an API response against the
local file path. This logic, which uses `key.split('/').pop()`, assumes the filename in
the production build will match the filename from the API. However, Vite's default
production build process hashes asset filenames (e.g., `image.png` becomes
`image-a1b2c3d4.png`). This will cause the lookup to fail, as the API will provide the
original, unhashed filename, resulting in no menu images being displayed in the
production environment.
Did we get this right? 👍 / 👎 to inform future reviews.
|
Why do we need the images in the repo? I think we should put them in the database |
|
railway bucket store might be a good choice? and then we can just store the urls in the database |
Added menus. Backend @ ScottyLabs/dining-api#251