Skip to content

feat(cms): pnk-token-page-types #27

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

Merged
merged 1 commit into from
Dec 20, 2024
Merged

Conversation

tractorss
Copy link
Contributor

@tractorss tractorss commented Dec 20, 2024

Types added

Collection-Types

  1. Exchange
  2. TokenStat

Single-Types

  1. PNK Token Page Hero
  2. PNK Token Page Buy Section
  3. PNK Token Page Need Section
  4. PNK Token Page Tokenomics Section

Components - PNK Token

  1. BuyCard
  2. TokenStatDisplay

Summary by CodeRabbit

  • New Features

    • Introduced new content types: exchange, pnk-token-page-buy-section, pnk-token-page-hero, pnk-token-page-need-section, pnk-token-page-tokenomics-section, and token-stat.
    • Added controllers and routers for each new content type to manage API endpoints.
    • Created services for handling business logic related to each new content type.
    • Implemented new components: buy-card and TokenStatDisplay, with defined attributes and relationships.
  • Bug Fixes

    • None reported.
  • Documentation

    • Added documentation comments to new controllers and services for clarity.

Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Walkthrough

This pull request introduces several new content types, components, and API structures within the Strapi CMS backend for a token page. The changes include creating new schemas for exchanges, token statistics, and various sections of a token page (hero, buy, need, and tokenomics). The implementation follows a consistent pattern of using Strapi's factory methods to generate controllers, routes, and services for each new content type, establishing a standardized approach to API development.

Changes

File Path Change Summary
cms-backend/src/api/exchange/... New API for exchanges with schema, controller, routes, and service
cms-backend/src/api/pnk-token-page-* Multiple new content type APIs for different token page sections (hero, buy, need, tokenomics)
cms-backend/src/api/token-stat/... New API for token statistics with schema, controller, routes, and service
cms-backend/src/components/pnk-token-page/ New components: buy-card.json and token-stat-display.json

Possibly related PRs

Poem

🐰 Hop, hop, through the CMS terrain,
New schemas bloom like a digitalrain!
Routes and services, dancing with glee,
Token pages structured, oh so free!
CodeRabbit's magic makes backends shine bright 🌟

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Dec 20, 2024

Deploy Preview for kleros-website-v2 ready!

Name Link
🔨 Latest commit 32e614e
🔍 Latest deploy log https://app.netlify.com/sites/kleros-website-v2/deploys/6765652ddbf9b800089595a8
😎 Deploy Preview https://deploy-preview-27--kleros-website-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

🧹 Nitpick comments (10)
cms-backend/src/api/pnk-token-page-hero/controllers/pnk-token-page-hero.ts (1)

1-3: Enhance controller documentation

Consider adding more detailed JSDoc comments describing the purpose of this controller and its endpoints.

 /**
  * pnk-token-page-hero controller
+ *
+ * @description Handles CRUD operations for the PNK token page hero section
+ * @endpoints
+ * - GET /api/pnk-token-page-hero
+ * - PUT /api/pnk-token-page-hero
  */
cms-backend/src/api/pnk-token-page-hero/content-types/pnk-token-page-hero/schema.json (1)

31-40: Restrict media types to images only

Since this is a hero section, consider limiting the media types to images only, as files, videos, and audios might not be appropriate for a hero background.

     "background": {
       "allowedTypes": [
-        "images",
-        "files",
-        "videos",
-        "audios"
+        "images"
       ],
       "type": "media",
-      "multiple": false
+      "multiple": false,
+      "required": true
     }
cms-backend/src/api/pnk-token-page-buy-section/services/pnk-token-page-buy-section.ts (1)

1-7: LGTM! Consider adding TypeScript types for better type safety.

The implementation follows Strapi's recommended pattern for service creation.

Consider adding TypeScript types for better type safety:

- import { factories } from '@strapi/strapi';
+ import { factories } from '@strapi/strapi';
+ import { Strapi } from '@strapi/strapi';
+ 
+ export default factories.createCoreService<any>('api::pnk-token-page-buy-section.pnk-token-page-buy-section');
cms-backend/src/components/pnk-token-page/buy-card.json (2)

3-6: Add a meaningful description for the component.

The description field is empty. Adding a clear description helps other developers understand the component's purpose and usage.

 "info": {
   "displayName": "buy-card",
-  "description": ""
+  "description": "Card component for displaying PNK token purchase options with title, icon, and link"
 }

22-26: Consider adding validation for the link relation.

The link relation is correctly defined, but consider making it required and adding validation to ensure the linked content exists.

 "link": {
   "type": "relation",
   "relation": "oneToOne",
-  "target": "api::link.link"
+  "target": "api::link.link",
+  "required": true
 }
cms-backend/src/api/pnk-token-page-buy-section/content-types/pnk-token-page-buy-section/schema.json (2)

14-17: Add field descriptions and validation rules for header

The header field lacks a description and validation rules. Consider adding:

  • Description to improve CMS usability
  • Required field validation
  • Min/max length constraints
 "header": {
   "type": "string"
+  "required": true,
+  "minLength": 1,
+  "maxLength": 100,
+  "description": "The main heading text for the buy section"
 }

23-27: Review exchange relation cardinality

The one-to-many relationship with exchanges implies multiple exchanges can be linked. Consider:

  1. Should there be a limit on the number of exchanges?
  2. Should exchanges be ordered by preference/priority?

Consider adding:

 "exchanges": {
   "type": "relation",
   "relation": "oneToMany",
   "target": "api::exchange.exchange"
+  "max": 10,
+  "ordered": true
 }
cms-backend/src/api/pnk-token-page-need-section/content-types/pnk-token-page-need-section/schema.json (2)

14-19: Add descriptions and validations for text fields

Both header and subtitle fields lack descriptions and validation rules.

 "header": {
   "type": "string"
+  "required": true,
+  "minLength": 1,
+  "maxLength": 100,
+  "description": "The main heading text for the need section"
 },
 "subtitle": {
   "type": "string"
+  "required": true,
+  "minLength": 1,
+  "maxLength": 200,
+  "description": "Supporting text below the header"
 }

20-24: Consider renaming 'card' to 'cards' for consistency

The field name card is singular but it's a repeatable component. For consistency with other schemas (like buyCards in the buy section), consider using the plural form.

-"card": {
+"cards": {
   "type": "component",
   "repeatable": true,
   "component": "content.cta-card"
 }
cms-backend/src/api/pnk-token-page-tokenomics-section/content-types/pnk-token-page-tokenomics-section/schema.json (1)

1-32: Consider adding SEO metadata fields

Since this is a public-facing page section, consider adding SEO-related fields to optimize content for search engines.

 {
   // ... existing configuration ...
   "attributes": {
+    "seo": {
+      "type": "component",
+      "repeatable": false,
+      "component": "shared.seo",
+      "description": "SEO metadata for the tokenomics section"
+    },
     // ... existing attributes ...
   }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9abea45 and 32e614e.

⛔ Files ignored due to path filters (2)
  • cms-backend/types/generated/components.d.ts is excluded by !**/generated/**
  • cms-backend/types/generated/contentTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (26)
  • cms-backend/src/api/exchange/content-types/exchange/schema.json (1 hunks)
  • cms-backend/src/api/exchange/controllers/exchange.ts (1 hunks)
  • cms-backend/src/api/exchange/routes/exchange.ts (1 hunks)
  • cms-backend/src/api/exchange/services/exchange.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-buy-section/content-types/pnk-token-page-buy-section/schema.json (1 hunks)
  • cms-backend/src/api/pnk-token-page-buy-section/controllers/pnk-token-page-buy-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-buy-section/routes/pnk-token-page-buy-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-buy-section/services/pnk-token-page-buy-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-hero/content-types/pnk-token-page-hero/schema.json (1 hunks)
  • cms-backend/src/api/pnk-token-page-hero/controllers/pnk-token-page-hero.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-hero/routes/pnk-token-page-hero.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-hero/services/pnk-token-page-hero.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-need-section/content-types/pnk-token-page-need-section/schema.json (1 hunks)
  • cms-backend/src/api/pnk-token-page-need-section/controllers/pnk-token-page-need-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-need-section/routes/pnk-token-page-need-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-need-section/services/pnk-token-page-need-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-tokenomics-section/content-types/pnk-token-page-tokenomics-section/schema.json (1 hunks)
  • cms-backend/src/api/pnk-token-page-tokenomics-section/controllers/pnk-token-page-tokenomics-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-tokenomics-section/routes/pnk-token-page-tokenomics-section.ts (1 hunks)
  • cms-backend/src/api/pnk-token-page-tokenomics-section/services/pnk-token-page-tokenomics-section.ts (1 hunks)
  • cms-backend/src/api/token-stat/content-types/token-stat/schema.json (1 hunks)
  • cms-backend/src/api/token-stat/controllers/token-stat.ts (1 hunks)
  • cms-backend/src/api/token-stat/routes/token-stat.ts (1 hunks)
  • cms-backend/src/api/token-stat/services/token-stat.ts (1 hunks)
  • cms-backend/src/components/pnk-token-page/buy-card.json (1 hunks)
  • cms-backend/src/components/pnk-token-page/token-stat-display.json (1 hunks)
✅ Files skipped from review due to trivial changes (13)
  • cms-backend/src/api/exchange/routes/exchange.ts
  • cms-backend/src/api/exchange/controllers/exchange.ts
  • cms-backend/src/api/token-stat/controllers/token-stat.ts
  • cms-backend/src/api/pnk-token-page-need-section/routes/pnk-token-page-need-section.ts
  • cms-backend/src/api/pnk-token-page-buy-section/routes/pnk-token-page-buy-section.ts
  • cms-backend/src/api/pnk-token-page-tokenomics-section/controllers/pnk-token-page-tokenomics-section.ts
  • cms-backend/src/api/pnk-token-page-hero/routes/pnk-token-page-hero.ts
  • cms-backend/src/api/pnk-token-page-tokenomics-section/services/pnk-token-page-tokenomics-section.ts
  • cms-backend/src/api/exchange/services/exchange.ts
  • cms-backend/src/api/pnk-token-page-hero/services/pnk-token-page-hero.ts
  • cms-backend/src/api/token-stat/routes/token-stat.ts
  • cms-backend/src/api/token-stat/services/token-stat.ts
  • cms-backend/src/api/pnk-token-page-tokenomics-section/routes/pnk-token-page-tokenomics-section.ts
🔇 Additional comments (7)
cms-backend/src/api/pnk-token-page-hero/controllers/pnk-token-page-hero.ts (1)

5-7: LGTM! Following Strapi's best practices

The controller implementation correctly uses Strapi's factory pattern for creating a core controller. This approach ensures consistent API behavior and maintainability.

cms-backend/src/api/pnk-token-page-hero/content-types/pnk-token-page-hero/schema.json (2)

21-25: Verify button-link component structure

The buyButton component references "content.button-link". Let's verify this component exists and has the necessary fields.

✅ Verification successful

Button-link component structure verified and valid

The component exists at the expected location with proper structure containing:

  • text field of type string
  • link field as a relation to the api::link.link model
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the button-link component configuration

# Check if the component exists and its structure
fd --type f "button-link.json" --exec cat {} \;

Length of output: 350


26-30: Verify social media relation configuration

The oneToMany relation with socials needs verification to ensure it's properly configured in the referenced social model.

✅ Verification successful

Social media relation configuration is correctly set up

The oneToMany relation with socials is properly configured. The social model exists as a collection type with the correct API identifier (api::social.social), and it contains all necessary fields for social media entries (name, icon, url). The relation is being used consistently across multiple components (pnk-token-page-hero and footer-socials-section) in the expected way.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the social model configuration

# Check if the social model exists and has the correct configuration
fd --type f "schema.json" --exec grep -l "api::social.social" {}

Length of output: 246


Script:

#!/bin/bash
# Let's check the content of the social model schema and the related configurations

# First, let's find the social model schema
fd "schema.json" --exec cat {} \; | grep -A 20 -B 20 "api::social.social"

# Also, let's specifically look for the social model schema
fd --type f "schema.json" --exec grep -l "collectionName.*social" {}

Length of output: 1987


Script:

#!/bin/bash
# Let's examine the social model schema specifically
cat ./cms-backend/src/api/social/content-types/social/schema.json

Length of output: 880

cms-backend/src/api/pnk-token-page-need-section/services/pnk-token-page-need-section.ts (1)

1-7: LGTM! Same TypeScript enhancement recommended.

The implementation follows the same correct pattern as the buy-section service.

The same TypeScript enhancement suggestion from the buy-section service applies here.

cms-backend/src/api/pnk-token-page-buy-section/controllers/pnk-token-page-buy-section.ts (1)

1-7: LGTM! Consider TypeScript enhancements and verify relationship handling.

The implementation follows Strapi's recommended pattern for controller creation.

Consider adding TypeScript types for better type safety:

- import { factories } from '@strapi/strapi'
+ import { factories } from '@strapi/strapi';
+ import { Strapi } from '@strapi/strapi';
+ 
+ export default factories.createCoreController<any>('api::pnk-token-page-buy-section.pnk-token-page-buy-section');

Let's verify the controller's relationship handling with the exchange entity:

✅ Verification successful

Let me gather more information about the schema and relationships.


LGTM! The schema correctly defines the relationships, no custom controller needed.

The schema shows proper relationship configuration:

  • One-to-many relationship with exchanges is correctly defined
  • Component relationship for buyCards is properly set up
  • Default Strapi controller is sufficient to handle these relationships

The TypeScript suggestion remains valid for better type safety:

- import { factories } from '@strapi/strapi'
+ import { factories } from '@strapi/strapi';
+ import { Strapi } from '@strapi/strapi';
+ 
+ export default factories.createCoreController<any>('api::pnk-token-page-buy-section.pnk-token-page-buy-section');
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for proper relationship definition in the schema
fd --type f schema.json --exec cat {} \; | jq 'select(.info.singularName == "pnk-token-page-buy-section") | .attributes.exchange'

# Check for any custom controller methods that might handle the relationship
ast-grep --pattern 'createCoreController($_) {
  $$$
}'

Length of output: 197


Script:

#!/bin/bash
# Check the complete schema for pnk-token-page-buy-section
fd --type f schema.json --exec cat {} \; | jq 'select(.info.singularName == "pnk-token-page-buy-section")'

# Search for any exchange-related fields or relationships in the schema
fd --type f schema.json --exec cat {} \; | jq 'select(.info.singularName == "pnk-token-page-buy-section") | .attributes'

# Look for any custom implementations in the controller file
cat cms-backend/src/api/pnk-token-page-buy-section/controllers/pnk-token-page-buy-section.ts

Length of output: 1452

cms-backend/src/api/pnk-token-page-need-section/controllers/pnk-token-page-need-section.ts (1)

1-7: LGTM! Controller implementation follows Strapi best practices.

The controller is correctly implemented using Strapi's factory pattern, which ensures consistent API behavior and proper integration with Strapi's core functionalities.

Let's verify the integration with related files:

✅ Verification successful

Integration verified - all required Strapi components are in place

The verification confirms proper integration with all necessary Strapi components:

  • Found corresponding service file at expected location
  • Found matching routes file at expected location
  • Content type schema is properly defined with correct singular/plural names
  • All files follow consistent naming convention
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of required related files for the controller

# Check for the existence of related route and service files
echo "Checking related files..."
fd -t f "pnk-token-page-need-section\.(ts|json)$" cms-backend/src/api -x echo "Found: {}"

# Verify schema structure
if [ -f "cms-backend/src/api/pnk-token-page-need-section/content-types/pnk-token-page-need-section/schema.json" ]; then
    echo "\nSchema structure:"
    cat cms-backend/src/api/pnk-token-page-need-section/content-types/pnk-token-page-need-section/schema.json | jq '.info'
fi

Length of output: 865

cms-backend/src/api/pnk-token-page-buy-section/content-types/pnk-token-page-buy-section/schema.json (1)

18-22: Verify the buy-card component structure

The buyCards field references the pnk-token-page.buy-card component. Let's verify its structure and implementation.

✅ Verification successful

Component structure verified and valid

The pnk-token-page.buy-card component exists and has a valid structure with:

  • title field (string)
  • icon field (media, multiple)
  • link field (relation to api::link.link)

All fields appear properly defined and aligned with typical card component requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the referenced component exists and examine its structure
fd --type f "buy-card.json" --exec cat {}

Length of output: 539

Comment on lines +15 to +20
"header": {
"type": "string"
},
"subtitle": {
"type": "string"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add field validations for text content

The header and subtitle fields should have proper validations to ensure content quality.

     "header": {
-      "type": "string"
+      "type": "string",
+      "required": true,
+      "maxLength": 100,
+      "minLength": 3
     },
     "subtitle": {
-      "type": "string"
+      "type": "string",
+      "required": true,
+      "maxLength": 200,
+      "minLength": 10
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"header": {
"type": "string"
},
"subtitle": {
"type": "string"
},
"header": {
"type": "string",
"required": true,
"maxLength": 100,
"minLength": 3
},
"subtitle": {
"type": "string",
"required": true,
"maxLength": 200,
"minLength": 10
},

Comment on lines +17 to +26
"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Restrict media types to images only.

Since this is for exchange icons, we should restrict the allowed types to images only. Additionally, consider adding size and dimension constraints.

 "icon": {
   "allowedTypes": [
-    "images",
-    "files",
-    "videos",
-    "audios"
+    "images"
   ],
   "type": "media",
-  "multiple": false
+  "multiple": false,
+  "required": true
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
}
"icon": {
"allowedTypes": [
"images"
],
"type": "media",
"multiple": false,
"required": true
}

Comment on lines +14 to +16
"url": {
"type": "string"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add URL validation and required constraint.

The URL field should include validation to ensure proper URL format and should be marked as required since it's essential for an exchange entry.

 "url": {
   "type": "string"
+  "required": true,
+  "regex": "^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"url": {
"type": "string"
},
"url": {
"type": "string",
"required": true,
"regex": "^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$"
},

Comment on lines +9 to +11
"title": {
"type": "string"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add required constraint to title field.

The title field should be marked as required since it's essential for the buy card display.

 "title": {
-  "type": "string"
+  "type": "string",
+  "required": true
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"title": {
"type": "string"
},
"title": {
"type": "string",
"required": true
},

Comment on lines +12 to +21
"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": true
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Revise icon field configuration.

The current configuration allows multiple icons and various media types, which seems unnecessary for a card icon.

 "icon": {
   "allowedTypes": [
-    "images",
-    "files",
-    "videos",
-    "audios"
+    "images"
   ],
   "type": "media",
-  "multiple": true
+  "multiple": false,
+  "required": true
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": true
},
"icon": {
"allowedTypes": [
"images"
],
"type": "media",
"multiple": false,
"required": true
},

Comment on lines +25 to +29
"arrowLink": {
"type": "component",
"repeatable": true,
"component": "content.button-link"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

The arrowLink field should not be repeatable

Based on the codebase analysis, the button-link component is consistently used as a non-repeatable field in other sections, particularly in the CTA card component where arrowLink is explicitly marked as "repeatable": false. This pattern suggests that the repeatable setting in the pnk-token-page-need-section is inconsistent with the established usage across the codebase.

  • cms-backend/src/api/pnk-token-page-need-section/content-types/pnk-token-page-need-section/schema.json: Change "repeatable": true to "repeatable": false for the arrowLink field
🔗 Analysis chain

Verify the button-link component implementation

The arrowLink field is marked as repeatable, which might not be necessary for a typical CTA section. Let's verify the component structure and its usage pattern.


Let me check how the button-link component is used in other sections to make a more informed decision.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the referenced component exists and examine its structure
fd --type f "button-link.json" --exec cat {}

# Look for other usages of this component to verify if it's typically repeatable
rg -l "content.button-link"

Length of output: 1625


Script:

#!/bin/bash
# Check the usage pattern of button-link in other schemas
fd --type f schema.json --exec rg -A 3 "content.button-link" {}

# Also check component usage in CTA sections specifically
fd --type f "cta" --exec cat {}

Length of output: 2116

Comment on lines +13 to +23
"attributes": {
"key": {
"type": "string"
},
"primaryValue": {
"type": "string"
},
"secondaryValue": {
"type": "string"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add field validations and descriptions for better data integrity

The schema fields lack important constraints and documentation. Consider adding:

  1. Required field validations
  2. Field descriptions
  3. Minimum/maximum length constraints where appropriate
 "attributes": {
   "key": {
-    "type": "string"
+    "type": "string",
+    "required": true,
+    "description": "Identifier/label for the token statistic (e.g., 'Market Cap', 'Total Supply')",
+    "minLength": 1,
+    "maxLength": 50
   },
   "primaryValue": {
-    "type": "string"
+    "type": "string",
+    "required": true,
+    "description": "Main value to display (e.g., '$1.2M', '1,000,000 PNK')",
+    "minLength": 1
   },
   "secondaryValue": {
-    "type": "string"
+    "type": "string",
+    "description": "Optional secondary/supplementary value"
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"attributes": {
"key": {
"type": "string"
},
"primaryValue": {
"type": "string"
},
"secondaryValue": {
"type": "string"
}
}
"attributes": {
"key": {
"type": "string",
"required": true,
"description": "Identifier/label for the token statistic (e.g., 'Market Cap', 'Total Supply')",
"minLength": 1,
"maxLength": 50
},
"primaryValue": {
"type": "string",
"required": true,
"description": "Main value to display (e.g., '$1.2M', '1,000,000 PNK')",
"minLength": 1
},
"secondaryValue": {
"type": "string",
"description": "Optional secondary/supplementary value"
}
}

Comment on lines +18 to +22
"stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::token-stat.token-stat"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation for stats relationship

The stats relationship should be required and documented.

 "stats": {
   "type": "relation",
   "relation": "oneToMany",
-  "target": "api::token-stat.token-stat"
+  "target": "api::token-stat.token-stat",
+  "required": true,
+  "description": "Token statistics to display in this section"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::token-stat.token-stat"
}
"stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::token-stat.token-stat",
"required": true,
"description": "Token statistics to display in this section"
}

Comment on lines +8 to +17
"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Restrict icon media types to images only

The icon field currently allows unnecessary media types (files, videos, audios) which could lead to incorrect usage. Since this is for displaying statistics, only images should be allowed.

 "icon": {
   "allowedTypes": [
-    "images",
-    "files",
-    "videos",
-    "audios"
+    "images"
   ],
   "type": "media",
-  "multiple": false
+  "multiple": false,
+  "required": true,
+  "description": "Visual icon representing the statistic (use SVG or PNG)"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
},
"icon": {
"allowedTypes": [
"images"
],
"type": "media",
"multiple": false,
"required": true,
"description": "Visual icon representing the statistic (use SVG or PNG)"
},

Comment on lines +14 to +31
"attributes": {
"header": {
"type": "string"
},
"subtitle": {
"type": "string"
},
"arrowLink": {
"type": "component",
"repeatable": false,
"component": "content.button-link"
},
"tokenStatDisplay": {
"type": "component",
"repeatable": false,
"component": "pnk-token-page.token-stat-display"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance schema with validations and descriptions

The schema needs better field constraints and documentation for content editors.

 "attributes": {
   "header": {
-    "type": "string"
+    "type": "string",
+    "required": true,
+    "description": "Main heading for the tokenomics section",
+    "minLength": 1,
+    "maxLength": 100
   },
   "subtitle": {
-    "type": "string"
+    "type": "string",
+    "required": true,
+    "description": "Explanatory text below the header",
+    "minLength": 1,
+    "maxLength": 200
   },
   "arrowLink": {
     "type": "component",
     "repeatable": false,
-    "component": "content.button-link"
+    "component": "content.button-link",
+    "required": true,
+    "description": "Call-to-action button/link for the tokenomics section"
   },
   "tokenStatDisplay": {
     "type": "component",
     "repeatable": false,
-    "component": "pnk-token-page.token-stat-display"
+    "component": "pnk-token-page.token-stat-display",
+    "required": true,
+    "description": "Token statistics display component for this section"
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"attributes": {
"header": {
"type": "string"
},
"subtitle": {
"type": "string"
},
"arrowLink": {
"type": "component",
"repeatable": false,
"component": "content.button-link"
},
"tokenStatDisplay": {
"type": "component",
"repeatable": false,
"component": "pnk-token-page.token-stat-display"
}
}
"attributes": {
"header": {
"type": "string",
"required": true,
"description": "Main heading for the tokenomics section",
"minLength": 1,
"maxLength": 100
},
"subtitle": {
"type": "string",
"required": true,
"description": "Explanatory text below the header",
"minLength": 1,
"maxLength": 200
},
"arrowLink": {
"type": "component",
"repeatable": false,
"component": "content.button-link",
"required": true,
"description": "Call-to-action button/link for the tokenomics section"
},
"tokenStatDisplay": {
"type": "component",
"repeatable": false,
"component": "pnk-token-page.token-stat-display",
"required": true,
"description": "Token statistics display component for this section"
}
}

Copy link
Collaborator

@alcercu alcercu left a comment

Choose a reason for hiding this comment

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

lgtm

@alcercu alcercu merged commit b6b40b4 into master Dec 20, 2024
5 checks passed
@alcercu alcercu deleted the feat/pnk-token-page-types branch December 20, 2024 13:27
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.

2 participants