Skip to content
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

Website: Display contributions dynamically on selections page (instead of hardcoding in shared/locales) #1001

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

DarkMenacer
Copy link
Contributor

@DarkMenacer DarkMenacer commented Jan 4, 2025

Summary by CodeRabbit

  • Localization

    • Removed financial amount references in website selection localization files for multiple languages (German, English, French, Italian)
  • Code Structure

    • Simplified import paths across multiple components
    • Updated path resolution for draws directory
  • New Features

    • Added currency redirection functionality
    • Introduced dynamic currency handling in Resources component
  • Page Updates

    • Refactored recipient selection page to support currency-specific routing

Copy link

vercel bot commented Jan 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
public ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 8, 2025 3:09pm

Copy link

coderabbitai bot commented Jan 4, 2025

📝 Walkthrough

Walkthrough

This pull request introduces changes across multiple localization files and website components, focusing on removing a specific financial figure ("USD 300,000+") from website selection JSON files and refactoring import paths. The modifications also include a new currency-based redirection mechanism and updates to the recipient selection page's structure, enhancing the website's localization and navigation capabilities.

Changes

File Change Summary
shared/locales/*/website-selection.json Removed "amount": "USD 300,000+" key from section-2 in German, English, French, and Italian localization files
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(components)/draw-card.tsx Simplified import path for CompletedDraw type
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/hero-section.tsx Updated ScrollToChevron import path
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/resources.tsx Added ResourcePageProps, updated function to handle currency and contributions
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/currency-redirect.tsx New file for handling currency-based redirects
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/page.tsx New page component with comprehensive recipient selection layout
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/page.tsx Replaced static page with currency redirection logic

Sequence Diagram

sequenceDiagram
    participant User
    participant CurrencyRedirect
    participant Page
    
    User->>CurrencyRedirect: Access page
    CurrencyRedirect->>Page: Check current currency
    alt Currency mismatch
        CurrencyRedirect->>User: Redirect to correct currency page
    else Currency matches
        Page->>User: Render recipient selection content
    end
Loading

Possibly Related PRs

Suggested Labels

surveys, website

Suggested Reviewers

  • andrashee
  • socialincome-dev
  • mkue

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

@DarkMenacer DarkMenacer linked an issue Jan 4, 2025 that may be closed by this pull request
1 task
Copy link

github-actions bot commented Jan 4, 2025

Visit the preview URL for this PR (updated for commit d91390d):

https://si-admin-staging--pr1001-pranav-number-from-t-4mdo90t9.web.app

(expires Wed, 15 Jan 2025 15:08:43 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b7b0969384059dce6ea8fad1ee1d1737e54e6676

@DarkMenacer
Copy link
Contributor Author

@CodeRabbit review

Copy link

coderabbitai bot commented Jan 8, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@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: 3

🧹 Nitpick comments (3)
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/resources.tsx (1)

57-60: Use Link component for internal navigation

For internal links, it's recommended to use the Link component from next/link instead of an a tag. This improves performance and enables client-side transitions.

Apply this diff to update the code:

+import Link from 'next/link';

 <Button variant="link">
-    <a href="../finances" target="_blank" rel="noopener noreferrer">
+    <Link href="../finances">
         <Typography as="span" className="text-xl sm:text-2xl">
             {currency.toUpperCase()} {roundAmount(totalContributionsAmount)}{' '}
             {translator.t('section-2.amount-context')}
         </Typography>
+    </Link>
-    </a>
 </Button>
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/page.tsx (1)

18-18: Consider using design tokens for margin values

The arbitrary negative margins (-mt-24, -mt-36) could cause layout inconsistencies. Consider using design system tokens or CSS variables.

website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/state.ts (1)

Line range hint 28-40: Enhance error handling specificity

The catch block currently logs all errors generically. Consider handling specific error types (e.g., file not found, parse errors) differently.

 } catch (e) {
-    console.error(e);
+    if (e instanceof SyntaxError) {
+        console.error('Failed to parse draw file:', e);
+    } else if ((e as NodeJS.ErrnoException).code === 'ENOENT') {
+        console.error('Draw file not found:', e);
+    } else {
+        console.error('Unexpected error loading draws:', e);
+    }
     return [];
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 55b7607 and d91390d.

⛔ Files ignored due to path filters (2)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(assets)/globe.svg is excluded by !**/*.svg
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(assets)/transparency.svg is excluded by !**/*.svg
📒 Files selected for processing (12)
  • shared/locales/de/website-selection.json (0 hunks)
  • shared/locales/en/website-selection.json (0 hunks)
  • shared/locales/fr/website-selection.json (0 hunks)
  • shared/locales/it/website-selection.json (0 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(components)/draw-card.tsx (1 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/hero-section.tsx (1 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/past-rounds.tsx (1 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/resources.tsx (2 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/state.ts (1 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/currency-redirect.tsx (1 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/page.tsx (1 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/page.tsx (1 hunks)
💤 Files with no reviewable changes (4)
  • shared/locales/de/website-selection.json
  • shared/locales/fr/website-selection.json
  • shared/locales/it/website-selection.json
  • shared/locales/en/website-selection.json
✅ Files skipped from review due to trivial changes (1)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/past-rounds.tsx
🔇 Additional comments (3)
website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/page.tsx (1)

19-24: LGTM! Props handling looks good

Props are correctly typed and passed down to child components. The currency transformation to uppercase is handled appropriately.

website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/hero-section.tsx (1)

7-7: LGTM! Import path simplification looks good

The relative import path is correctly simplified and maintains code clarity.

website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(components)/draw-card.tsx (1)

7-7: LGTM! Import path and security best practices look good

The relative import path is correctly simplified, and external links properly implement security best practices with appropriate attributes.

@@ -1,7 +1,7 @@
import { readFileSync } from 'fs';
import * as fs from 'fs/promises';

const DRAWS_PATH = '../recipients_selection/draws';
const DRAWS_PATH = process.cwd() + '/../recipients_selection/draws';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid using process.cwd() for file paths

Using process.cwd() can be unreliable in production as the working directory might change. Consider using path.resolve(__dirname, ...) instead.

-const DRAWS_PATH = process.cwd() + '/../recipients_selection/draws';
+import path from 'path';
+const DRAWS_PATH = path.resolve(__dirname, '../../../recipients_selection/draws');

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Member

@ssandino ssandino left a comment

Choose a reason for hiding this comment

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

Nice! @mkue

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.

[Web]: Fetch number from transparency page
2 participants