Skip to content

Conversation

@patinen
Copy link
Contributor

@patinen patinen commented Oct 13, 2025

📄 Pull Request Overview

Closes #548

🔧 Changes Made

  1. Directus backed heroApi
  • implemented src/entities/Hero/model/heroApi.ts with normalized local filtering
  • unified mapper for RTH Query (useGetHeroBySlugQuery) and SSR (fetchHeroBySlug)
  • Translation selection via translations.languages_code
  • images returned as StaticImageData-like objects ( { src, width, height } )
  1. Stats loading
  • loads hero stats from stats O2M relation, sorted by order
  • safe defaults + resilient mapping if fields are missing
  1. Fallback readiness
  • API layer supports fallback to local hardcoded data if CMS missing

Checklist Before Submission

  • Functionality: I have tested my code, and it works as expected.
  • JSDoc: I have added or updated JSDoc comments for all relevant code.
  • Debugging: No console.log() or other debugging statements are left.
  • Clean Code: Removed commented-out or unnecessary code.
  • Tests: Added new tests or updated existing ones for the changes made.
  • Documentation: Inline comments and PR notes.

📝 Additional Information

How to verify

  • directus raw check:

    • https://strapi.altzone.fi/items/heroes?filter[slug][_eq]=researcher&limit=1&fields=slug,id,stats.*
  • Screenshots: [Include any screenshots or videos if the changes affect the UI]

  • Dependencies: [Mention any new dependencies or breaking changes]

  • Known Issues: [List any known issues or limitations]

Dependencies

  • No new runtime deps. Uses existing Directus REST + RTK Query.

Known Issues / Notes

  • GIF upload size on server side (nginx) still limits large files; current integration assumes assets already in Directus.
  • If languages_code in CMS deviates from fi|en|ru, localization selection will fall back to the first translation.
  • Image dimensions default to width/height = 1 if Directus lacks metadata (UI can still render; consider enriching later).

Copy link
Member

@Skoivumaki Skoivumaki left a comment

Choose a reason for hiding this comment

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

If I understood this correctly, you created 2 heroes Overeater and Researcher in CMS to test with? Researcher works and it seems like its correctly fetching from Directus. However overeater isn't working at all:
image

Also see comments.

@patinen patinen requested a review from Skoivumaki October 15, 2025 14:54
@patinen patinen changed the base branch from main to dev October 23, 2025 09:35
@patinen patinen marked this pull request as draft October 23, 2025 09:57
@patinen patinen force-pushed the juho/enhancement/548-move-hardcoded-heroes-to-directus-CMS-and-implement-endpoints branch from a7e8761 to b7a59a9 Compare October 29, 2025 14:17
@patinen patinen marked this pull request as ready for review October 29, 2025 15:51
@patinen
Copy link
Contributor Author

patinen commented Oct 30, 2025

Setting this back to draft. The /defense-gallery page and the hero category pages are still fetching their data directly from code instead of the CMS.

I originally thought of it as a separate task, but since the API is already working and I'm familiar with the configuration and endpoints, it makes more sense to handle it within this same PR rather than opening a new issue just to patch it afterwards.

@patinen patinen marked this pull request as draft October 30, 2025 19:01
translate stray finnish note

# Conflicts:
#	frontend-next-migration/src/entities/Hero/model/initializeHeroGroups.ts
… API

- Initialize hero data from Directus before attempting to fetch from static data.
- Implement fallback mechanism for hero retrieval, ensuring a seamless experience.
- Enhance navigation logic for previous and next heroes using Directus data.
- Update SingleHeroPage component to handle new hero data structure and fetching logic.
…ation

- Moved the groupHeroesByGroup function from heroApi.ts to a separate module for better modularity.
- This change enhances readability and maintainability of the heroApi.ts file.
@patinen patinen force-pushed the juho/enhancement/548-move-hardcoded-heroes-to-directus-CMS-and-implement-endpoints branch from b7a59a9 to 5143494 Compare December 16, 2025 21:29
@patinen
Copy link
Contributor Author

patinen commented Dec 16, 2025

Status update:

Hero data fetching has been migrated to a CMS-first model using Directus, with fallbacks to existing static data. This update also adds fetching to DefenseGalleryPage and SingleDefensePage with error handling to keep the UI stable if CMS data is missing or unavailable.

Directus is not yet populated with hero data, so this PR is not ready to be merged. Next step is to populate hero content in Directus before merge.

@Rutjake
Copy link
Contributor

Rutjake commented Dec 19, 2025

I tried loading a character image into Directus, it shows up correctly on the defense gallery page, but not on the individual character page. Was the fallback to hardcoded implemented here? Or did I misunderstand something?
image
image
image

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.

Move Hardcoded Heroes to Directus CMS & Implement endpoints

4 participants