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

refactor(types): update type definitions #118

Merged
merged 4 commits into from
Feb 3, 2025

Conversation

suhas-sensei
Copy link
Collaborator

@suhas-sensei suhas-sensei commented Feb 2, 2025

enhances #14

introduces sharable types

Summary by CodeRabbit

  • New Features

    • The home page now showcases a curated list of project initiatives, presenting detailed information such as funding progress, descriptions, and other key details.
    • Updated structures now support clearer statistical displays of important metrics for a more informative user experience.
    • New navigation items and sections have been introduced for improved user navigation.
  • Documentation

    • Enhanced type clarity and documentation for various interfaces and types, improving overall readability and maintainability.

Copy link

vercel bot commented Feb 2, 2025

@suhas-sensei is attempting to deploy a commit to the kindfi Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Walkthrough

This update introduces new type-safe data structures and additional type annotations across various components and type definition files. The home page now defines a projects constant with an array of Project objects that use the Money and Percentage types. The navigation component also benefits from explicit type annotations for its navigation arrays. Several type definitions have been enhanced in the types files, including updates to the Category interface and the addition of new interfaces and export statements. A placeholder comment has been added in the escrow contract module without altering its logic.

Changes

File(s) Change Summary
apps/web/components/pages/home.tsx
apps/web/components/shared/layout/header/navigation.tsx
Added a new projects constant with typed Project objects in the home page and added explicit type annotations for the projects and resources arrays in the navigation component.
apps/web/lib/types/home.types.ts
apps/web/lib/types/pages.ts
apps/web/lib/types/index.ts
apps/web/lib/types/stats.ts
Updated type definitions: replaced React.ReactNode with ReactNode in the Category interface; added new interfaces NavigationItem, NavigationSection, and StatItem; and introduced new export statements for project and stats modules.
apps/web/lib/stellar/escrow.ts Inserted a placeholder comment line in the escrow contract initialization function without modifying its existing logic.
apps/web/lib/types/project.ts Introduced new types, helper functions, and interfaces including Percentage, Money, and StatItem, along with their respective creation functions and validations.

Possibly related PRs

  • feat: implement user dashboard and fixes linting errors #110: The changes in the main PR are related to the modifications in the retrieved PR as both involve the Project type, with the main PR introducing new types and functions for handling project data, while the retrieved PR updates the type from Project to ProjectDetails in the context of project mappings.
  • Feat: Create project details components for project page #97: The changes in the main PR, which involve the addition of types and functions related to Money, Percentage, and Project, are directly related to the new ProjectOverview component in the retrieved PR, as both involve the handling and representation of project-related data structures.
  • Add proper keys to lists #68: The changes in the main PR, which involve adding structured project data with specific types and properties, are related to the modifications in the retrieved PR that also enhance the structure of data by introducing unique identifiers for rendering lists, particularly in the projects array. Both PRs focus on improving data representation and ensuring unique keys for React components.

Suggested reviewers

  • Bran18
  • AndlerRL

Poem

I'm a rabbit with a coder's delight,
Hopping through files from morning to night.
New types and projects make my heart sing,
Each line of code a joyful spring.
With a bounce and a hop, our code's truly bright! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

@suhas-sensei suhas-sensei mentioned this pull request Feb 2, 2025
@coderabbitai coderabbitai bot added documentation Improvements or additions to documentation enhancement New feature improvement or request labels Feb 2, 2025
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: 4

🔭 Outside diff range comments (1)
apps/web/lib/stellar/escrow.ts (1)

26-96: Consider enhancing type safety for Stellar SDK usage.

The function could benefit from stronger type safety around Stellar SDK operations.

  1. Create a type-safe wrapper for Server:
// apps/web/lib/stellar/types.ts
export type StellarNetwork = 'TESTNET' | 'MAINNET';
export interface StellarConfig {
  networkUrl: string;
  network: StellarNetwork;
}

// apps/web/lib/stellar/config.ts
export function getStellarConfig(): StellarConfig {
  const networkUrl = process.env.STELLAR_NETWORK_URL;
  if (!networkUrl) {
    throw new Error('STELLAR_NETWORK_URL is not configured');
  }
  return {
    networkUrl,
    network: process.env.NODE_ENV === 'production' ? 'MAINNET' : 'TESTNET'
  };
}
  1. Use these types in the escrow contract:
-const server = new Server(process.env.STELLAR_NETWORK_URL!)
+const config = getStellarConfig();
+const server = new Server(config.networkUrl)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b606803 and 9640109.

📒 Files selected for processing (7)
  • apps/web/components/pages/home.tsx (2 hunks)
  • apps/web/components/shared/layout/header/navigation.tsx (3 hunks)
  • apps/web/lib/stellar/escrow.ts (1 hunks)
  • apps/web/lib/types/home.types.ts (1 hunks)
  • apps/web/lib/types/index.ts (1 hunks)
  • apps/web/lib/types/pages.ts (1 hunks)
  • apps/web/lib/types/stats.ts (1 hunks)
🔇 Additional comments (5)
apps/web/lib/types/pages.ts (2)

9-13: LGTM! Type-safe URL validation using template literals.

The NavigationItem interface effectively uses template literal types to ensure type-safe URLs, allowing only valid URL patterns.


15-23: LGTM! Well-documented interface with clear purpose.

The NavigationSection interface is well-documented with comprehensive JSDoc comments explaining its purpose and properties.

apps/web/components/shared/layout/header/navigation.tsx (1)

18-34: LGTM! Enhanced type safety with explicit array types.

The explicit NavigationItem[] type annotations for projects and resources arrays improve type safety and make the code more maintainable.

Also applies to: 36-53

apps/web/lib/types/index.ts (1)

8-9: LGTM!

The new exports follow the barrel pattern, which is a good practice for organizing and exposing types.

apps/web/lib/stellar/escrow.ts (1)

42-42: Empty line added for readability.

apps/web/lib/types/stats.ts Show resolved Hide resolved
apps/web/lib/types/home.types.ts Show resolved Hide resolved
apps/web/components/pages/home.tsx Show resolved Hide resolved
apps/web/components/pages/home.tsx Outdated Show resolved Hide resolved
Copy link

vercel bot commented Feb 2, 2025

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

Name Status Preview Comments Updated (UTC)
kindfi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 3, 2025 0:20am

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 2, 2025
Copy link
Contributor

@Bran18 Bran18 left a comment

Choose a reason for hiding this comment

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

Hey @suhas-sensei, could you please address the issue that has appeared after rebasing your branch? Here’s what you need to do:

  1. Open the terminal and navigate to the web folder.
  2. Run the following command: bun run build
  3. Review the error message that appears and resolve the issue.
  4. Commit your changes and push them again.

Thank you!

Screenshot 2025-02-02 at 5 47 14 PM

@suhas-sensei
Copy link
Collaborator Author

image
is this solved, the rest files dont seem to be my edits @Bran18

@suhas-sensei
Copy link
Collaborator Author

sending then

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: 6

♻️ Duplicate comments (2)
apps/web/components/pages/home.tsx (2)

91-98: 🛠️ Refactor suggestion

Use helper functions consistently for type assertions.

Replace type assertions with the provided helper functions for consistency.

Apply this diff:

-currentAmount: { __brand: 'money', value: 22800 } as unknown as Money,
-targetAmount: { __brand: 'money', value: 25000 } as unknown as Money,
-investors: 18,
-minInvestment: { __brand: 'money', value: 5 } as unknown as Money,
-percentageComplete: {
-  __brand: 'percentage',
-  value: 90,
-} as unknown as Percentage,
+currentAmount: createMoney(22800),
+targetAmount: createMoney(25000),
+investors: 18,
+minInvestment: createMoney(5),
+percentageComplete: createPercentage(90),

83-231: 🛠️ Refactor suggestion

Extract projects data to a separate file.

The large projects array should be moved to a dedicated data file.

Create a new file apps/web/data/projects.ts:

import { Money, Percentage, Project } from '~/lib/types'
import { createMoney, createPercentage } from '~/lib/types'

export const projects: Project[] = [
  {
    id: 'healthy-kids-id',
    // ... rest of the project data
  },
  // ... other projects
]
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9640109 and b181b71.

📒 Files selected for processing (3)
  • apps/web/app/auth/callback/route.ts (1 hunks)
  • apps/web/components/pages/home.tsx (2 hunks)
  • apps/web/lib/types/project.ts (1 hunks)

apps/web/lib/types/project.ts Show resolved Hide resolved
apps/web/lib/types/project.ts Show resolved Hide resolved
apps/web/lib/types/project.ts Show resolved Hide resolved
apps/web/lib/types/project.ts Show resolved Hide resolved
apps/web/app/auth/callback/route.ts Show resolved Hide resolved
apps/web/app/auth/callback/route.ts Show resolved Hide resolved
Copy link
Contributor

@Bran18 Bran18 left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the build issues and contributing to our project! Great job!

@Bran18 Bran18 merged commit a4a1342 into kindfi-org:develop Feb 3, 2025
3 of 4 checks passed
@suhas-sensei
Copy link
Collaborator Author

Pleasure working with you folks, learnt a great lot stuff!

JoE11-y pushed a commit to JoE11-y/kindfi that referenced this pull request Feb 5, 2025
* refactor(types): update type definitions

* refactor(types): update type definitions build fix

* refactor(types): update type definitions build fix

---------

Co-authored-by: Brandon Fernández <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Feb 5, 2025
@coderabbitai coderabbitai bot mentioned this pull request Feb 13, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature improvement or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants