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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cms-backend/src/api/exchange/content-types/exchange/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"kind": "collectionType",
"collectionName": "exchanges",
"info": {
"singularName": "exchange",
"pluralName": "exchanges",
"displayName": "Exchange"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"url": {
"type": "string"
},
Comment on lines +14 to +16
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()@:%_\\+.~#?&\\/=]*)$"
},

"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
}
Comment on lines +17 to +26
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
}

}
}
7 changes: 7 additions & 0 deletions cms-backend/src/api/exchange/controllers/exchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* exchange controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::exchange.exchange');
7 changes: 7 additions & 0 deletions cms-backend/src/api/exchange/routes/exchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* exchange router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::exchange.exchange');
7 changes: 7 additions & 0 deletions cms-backend/src/api/exchange/services/exchange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* exchange service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::exchange.exchange');
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"kind": "singleType",
"collectionName": "pnk_token_page_buy_sections",
"info": {
"singularName": "pnk-token-page-buy-section",
"pluralName": "pnk-token-page-buy-sections",
"displayName": "PNKTokenPageBuySection",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"header": {
"type": "string"
},
"buyCards": {
"type": "component",
"repeatable": true,
"component": "pnk-token-page.buy-card"
},
"exchanges": {
"type": "relation",
"relation": "oneToMany",
"target": "api::exchange.exchange"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-buy-section controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::pnk-token-page-buy-section.pnk-token-page-buy-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-buy-section router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::pnk-token-page-buy-section.pnk-token-page-buy-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-buy-section service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::pnk-token-page-buy-section.pnk-token-page-buy-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"kind": "singleType",
"collectionName": "pnk_token_page_heroes",
"info": {
"singularName": "pnk-token-page-hero",
"pluralName": "pnk-token-page-heroes",
"displayName": "PNKTokenPageHero",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"header": {
"type": "string"
},
"subtitle": {
"type": "string"
},
Comment on lines +15 to +20
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
},

"buyButton": {
"type": "component",
"repeatable": false,
"component": "content.button-link"
},
"socials": {
"type": "relation",
"relation": "oneToMany",
"target": "api::social.social"
},
"background": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-hero controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::pnk-token-page-hero.pnk-token-page-hero');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-hero router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::pnk-token-page-hero.pnk-token-page-hero');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-hero service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::pnk-token-page-hero.pnk-token-page-hero');
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"kind": "singleType",
"collectionName": "pnk_token_page_need_sections",
"info": {
"singularName": "pnk-token-page-need-section",
"pluralName": "pnk-token-page-need-sections",
"displayName": "PNKTokenPageNeedSection"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"header": {
"type": "string"
},
"subtitle": {
"type": "string"
},
"card": {
"type": "component",
"repeatable": true,
"component": "content.cta-card"
},
"arrowLink": {
"type": "component",
"repeatable": true,
"component": "content.button-link"
}
Comment on lines +25 to +29
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

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-need-section controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::pnk-token-page-need-section.pnk-token-page-need-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-need-section router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::pnk-token-page-need-section.pnk-token-page-need-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-need-section service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::pnk-token-page-need-section.pnk-token-page-need-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"kind": "singleType",
"collectionName": "pnk_token_page_tokenomics_sections",
"info": {
"singularName": "pnk-token-page-tokenomics-section",
"pluralName": "pnk-token-page-tokenomics-sections",
"displayName": "PNKTokenPageTokenomicsSection",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"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"
}
}
Comment on lines +14 to +31
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"
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-tokenomics-section controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::pnk-token-page-tokenomics-section.pnk-token-page-tokenomics-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-tokenomics-section router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::pnk-token-page-tokenomics-section.pnk-token-page-tokenomics-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* pnk-token-page-tokenomics-section service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::pnk-token-page-tokenomics-section.pnk-token-page-tokenomics-section');
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"kind": "collectionType",
"collectionName": "token_stats",
"info": {
"singularName": "token-stat",
"pluralName": "token-stats",
"displayName": "TokenStat"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"key": {
"type": "string"
},
"primaryValue": {
"type": "string"
},
"secondaryValue": {
"type": "string"
}
}
Comment on lines +13 to +23
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"
}
}

}
7 changes: 7 additions & 0 deletions cms-backend/src/api/token-stat/controllers/token-stat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* token-stat controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::token-stat.token-stat');
7 changes: 7 additions & 0 deletions cms-backend/src/api/token-stat/routes/token-stat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* token-stat router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::token-stat.token-stat');
7 changes: 7 additions & 0 deletions cms-backend/src/api/token-stat/services/token-stat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* token-stat service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::token-stat.token-stat');
28 changes: 28 additions & 0 deletions cms-backend/src/components/pnk-token-page/buy-card.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"collectionName": "components_pnk_token_page_buy_cards",
"info": {
"displayName": "buy-card",
"description": ""
},
"options": {},
"attributes": {
"title": {
"type": "string"
},
Comment on lines +9 to +11
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
},

"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": true
},
Comment on lines +12 to +21
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
},

"link": {
"type": "relation",
"relation": "oneToOne",
"target": "api::link.link"
}
}
}
24 changes: 24 additions & 0 deletions cms-backend/src/components/pnk-token-page/token-stat-display.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"collectionName": "components_pnk_token_page_token_stat_displays",
"info": {
"displayName": "TokenStatDisplay"
},
"options": {},
"attributes": {
"icon": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
},
Comment on lines +8 to +17
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)"
},

"stats": {
"type": "relation",
"relation": "oneToMany",
"target": "api::token-stat.token-stat"
}
Comment on lines +18 to +22
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"
}

}
}
Loading