Skip to content

Refactor code structure for improved readability and maintainability - #219

Merged
nonsobethel0-dev merged 2 commits into
Parashield-Protocol:mainfrom
Nursca:fix/status-lookup
Jul 25, 2026
Merged

nonsobethel0-dev merged 2 commits into
Parashield-Protocol:mainfrom
Nursca:fix/status-lookup

Conversation

@Nursca

@Nursca Nursca commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Here's a summary of what changed:

Closes #202
src/lib/constants.ts — Imported Category, PolicyStatus, ClaimStatus from @/types and typed the lookup tables:

  • CATEGORY_LABELS: Record<string, string> → Record<Category, string>
  • CATEGORY_ICONS: Record<string, string> → Record<Category, string>
  • STATUS_COLOURS: Record<string, string> → Record<PolicyStatus | ClaimStatus, string>

src/components/Badge.tsx — Tightened types to satisfy the stricter lookup tables:

  • Added ColourName type for badge colour values
  • variant prop typed as ColourName instead of string
  • Added isStatusKey type guard for safe indexing into STATUS_COLOURS

Closes #203
Added security headers to netlify.toml:

  • X-Frame-Options: DENY + frame-ancestors 'none' — prevents iframing/clickjacking
  • X-Content-Type-Options: nosniff — prevents MIME sniffing
  • Referrer-Policy: strict-origin-when-cross-origin — limits referrer leakage
  • Permissions-Policy — disables camera, microphone, geolocation
  • Content-Security-Policy — restricts origins to self, Stellar Horizon/Soroban RPCs, PostHog, and Google Fonts; blocks all other external connections

Closes #204
The fix adds safeBigInt to src/lib/format.ts:3 which validates via the same /^-?\d+$/ regex as stroopsToDisplay before converting, returning 0n for any malformed input. The dashboard reduce calls at src/app/dashboard/page.tsx:27-28 now use it instead of raw BigInt().

Closes #205
The "Active Policies" section now branches on error before checking active.length === 0 (src/app/dashboard/page.tsx:76). When a fetch error occurs, it shows an inline notice instead of the misleading empty state.

@netlify

netlify Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for boisterous-sunshine-dd4c4c failed.

Name Link
🔨 Latest commit 70e15cf
🔍 Latest deploy log https://app.netlify.com/projects/boisterous-sunshine-dd4c4c/deploys/6a649dbfa799d900088ad448

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Nursca Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nonsobethel0-dev
nonsobethel0-dev merged commit 1a5877e into Parashield-Protocol:main Jul 25, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants