Coder Social home page Coder Social logo

potlock-nextjs-app's Introduction

PotLock - NextJS App

PotLock application.

You can access BOS PotLock version using one of the environments below:

Development

Getting Started

# using the right node version
nvm use;
# enable Yarn support
corepack enable;
# create config for environment variables
cp .env.example .env.local;
# if required, edit .env.local
# then run the development server ( dependencies will be installed automatically )
yarn dev

Open http://localhost:3000 in your browser.

DJango Indexer API

This project is using an indexer service. You can access its docs here: https://github.com/PotLock/django-indexer?tab=readme-ov-file#api-endpoints

URI: http://ec2-100-27-57-47.compute-1.amazonaws.com/api/v1

Swagger UI: https://dev.potlock.io/api/schema/swagger-ui/#/

Project Structure

Provides explicit separation between abstract and business-logic-heavy parts of the codebase, for which it offers a highly modular approach, defining clear boundaries for different aspects of the application within each module:

[ src/ ]
│
├── [ app ] <--- # Entry point of the application.
│   │            # Follows Nextjs App routing specification ( see link 1. )
│   │
│  ...
│   │
│   └── [ _store ] <--- # Application state root.# Uses Rematch state management library, based on Redux.
│
│
│
│
├── [ common ] <--- # Low-level foundation of the app, containing endpoint bindings,
│   │               # utility libraries, reusable primitives, and assets, used in layouts and
│   │               # business logic across the codebase. MUST NOT contain business logic by itself.
│   │               # AKA "shared" ( see link 2. )
│   │
│   ├── constants.ts <--- # Static reusable values, e.g.
│   │                      export const DEFAULT_NETWORK = "testnet"
│   │                      export const MAX_GAS = 100
│   │
│   ├── [ api ] <--- # Facilitates network interaction with backend(s)
│   │
│   ├── [ assets ] <--- # Globally used assets, e.g. images or icons
│   │
│   ├── [ contracts ] <--- # Smart contract services and interfaces
│   │
│   ├── [ hooks ] <--- # Shared React hooks for low-level functionalities
│   │
│   ├── [ lib ] <--- # Universal utilities, e.g. string manipulations,
│   │                # mathematic calculations, browser API bindings, etc.
│   │
│   └── [ ui ] <--- # Project UI kit
│       │
│       ├── [ components ] <--- # React components implementing UI design primitives
│       │
│       └── [ utils ] <--- # UI-specific utilities, like DOM manipulations# or TailwindCSS class transformers
│
│
│
│
└── [ modules ] <--- # Business logic units broken down into categories. Simply put, this is# a collection of directories that contain code implementing specific# groups of app use cases and are named after functionalities they provide.
    │
   ...
    │
    │
    ├── [ core ] <--- # Follows the same structure as any other module, but contains business logic,# that is shared between all or some of the other modules
    │
    ├── [ profile ] <--- # A feature-specific module
    │   │
    │   ├── constants.ts <--- # Module-specific static reusable values, e.g.
    │   │                       export const POTLOCK_REGISTRY_LIST_ID = 1
    │   │
    │   ├── models.ts <--- # Feature state definitions ( See link 3. )
    │   │                  # If this file grows over 300 LoC, consider turning it into a directory
    │   │                  # with the same name by applying code-splitting techniques.
    │   │
    │   ├── types.d.ts <--- # Module-specific shared types and interfaces
    │   │
    │   ├── [ components ] <--- # Feature-specific React components
    │   │
    │   ├── [ hooks ] <--- # Feature-specific React hooks
    │   │
    │   └── [ utils ] <--- # Feature-specific utilities, like value converters or validators
    │
    │
    ├── ...
    │
   ...

Links

  1. Nextjs Routing
  2. Shared layer from Feature-Sliced Design methodology
  3. Rematch models

Testing

We use Vitest testing framework coupled with React Testing Library to specifically target UI.

For details, please refer to the corresponding documentation resources:

Commands

Execute all unit tests:

yarn test:unit

Run dev server for unit tests:

yarn dev:test

File colocation

The project convention implies keeping the test scenarios alongside the code they're meant for ( See examples below ).

Pages

Tests for each page must be placed in tests.tsx within the same directory where page.tsx is located:

─── [ app ]
    │
    ├── page.tsx <--- # Homepage ( URL "/" )
    │
    ├── tests.tsx <--- # Tests for Homepage
    │
    ├── [ pots ]
    │   │
    │   ├── page.tsx <--- # Pots page ( URL "/pots" )
    │   │
    │   └── tests.tsx <--- # Tests for Pots page
    │
    └── [ users ]
        │
        └── [ [userId] ]
            │
            ├── page.tsx <--- # User page ( e.g. "/users/builder.near" )
            │
            └── tests.tsx <--- # Tests for User page
Modules

For modules, we target specific implementation details:

─── [ modules ]
    │
    └── [ profile ] <--- # Profile module
        │
        ├── [ components ]
        │   │
        │   ├── ProfileCard.tsx <--- # Profile card component
        │   │
        │   └── ProfileCard.test.tsx <--- # Tests for profile card component
        │
        └── [ utils ]
            │
            ├── validation.ts <--- # Profile validation functions
            │
            └── validation.test.ts <--- # Profile validation tests

potlock-nextjs-app's People

Contributors

wpdas avatar m-rb3 avatar carina-akaia avatar codingshot avatar heroes-bounty[bot] avatar

Stargazers

 avatar

potlock-nextjs-app's Issues

API update requests

If you have any requests, e.g.

  • Additional API endpoints
  • Updates to existing endpoints (e.g. adjusted data formatting, additional data, etc)

Please put them below and ping me (lachlan) to let me know!


API UPDATE REQUESTS:

Profile Page

Most of the components here are present on the Project Page, replicate them. Implement the Social Feed and Donations tab pages. When the Followers and Following buttons are clicked, the user should see the followers/following information.

The Followers / Following View is in another ticket. #20

Donate Modal

Implement Donate Modal, its sub-pages, and functionality. After implementation, add the ability to open the modal in the Hero and Card components. This modal uses the function to add items to the cart, the cart state should be updated to support it.

Home Page: Featured Projects & Card Component

Create the Featured Projects section, including the Card component that will be used later in other parts of the application. Different items are displayed on the Card depending on whether the user is authenticated or not. If the user is authenticated, the Donate button should be displayed.

Image

Home Page: All Projects

Implement the All Projects section. At this point, the Card component should be available. The Search, Filter, and Sort component must also be implemented.

Authentication

Create the module and its items to control user authentication. A state must be created to be used in the application. Thus informing whether the user is logged in or not. The most basic features must be implemented, such as signin and signout.

Navbar

Develop the interface and operation of Navbar. Your layout has been changed in Figma and such changes must be taken into account. Use authentication data to know button states e.g. Sign In / Sign Out.

This should also include the Cart button with its notification signal. This button should take the user to the /cart page (to be done). Also, prepare the initial cart state. This will be required by Donate Modal (to be done).

Cart Page

Reference: https://app.potlock.org/?tab=cart
Implement components and logic/business rules for this page. Items present here will be added by the Donate Modal. The components used here are simple to implement, however, the logic may be a little complex.

[FEATURE] "Act as DAO"

Problem

As a user, I may want to take actions on behalf of a DAO (creating FunctionCall proposals for a DAO that I have appropriate permissions for).

As a developer, I want to be able to easily handle DAO actions via a middleware and not create conditional UI at every step based on whether the user is acting as a DAO for that step.

Right now, this involves cumbersome UX and cumbersome code to provide the option to act as a DAO on each independent step.

Would be much better if I can "Act as DAO" at a top level, e.g. enter a DAO address which then verifies that I have FunctionCall proposal permissions for that DAO and fetches other DAO config like proposal deposit requirement, and then any action I take is in the form of a FunctionCall proposal to that DAO.

User Story(s):

As a _______, I want to ____, so that I can

Description

Description of solution

Acceptance Criteria

Outline what needs to be done

Limitations

Outline any potential limitations

Resources

  • outline links and relevant resources, references implementations

Project Page (user/{userId})

Two new requirements:

  1. a URL for an account detail page (aka “profile”) should be the same pattern regardless of the perceived “type” of account. E.g. not /project/{projectId} and /profile/{accountId} but rather /user/{userId} (this is account ID)

  2. we will continue to display “project” or “profile” views, but this will not be based on the URL pattern but rather on checking whether the account (user ID) is registered on the Potlock PG registry (list with list_id 1). If it is, “project” view will be displayed. If not, “profile” view will be displayed.

Donation: Direct NEAR donation

Implement Donate Modal, its sub-pages, and functionality. After implementation, add the ability to open the modal in the Hero and Card components. This modal is using the function to add items to the cart, the cart state should be updated to support it.

PotLock with NextJS

  • Project bootstrap: nextjs, rematch (state manager), shadcn, tailwind, unocss, typescript, naxios, wallet-selector, react-query, initial contracts, initial api services, eslint, prettier, initial hooks, initial store, initial pages.
  • Project structure: ✅
  • Projects Page:
  • Donate Randomly Modal:
  • Profile Page
  • Feed Page:
  • Pots Home Page:
  • Pot Single Page:
  • Donors Page:
  • Cart Page:
  • Homepage filter:
  • Donor Leaderboard:
  • Create Project Page:
  • Edit Project Page:
  • Deploy Pot:

Notes:

Ref links:

Figma
Repository

Map:
✅ = Done
🕵️ = Tested

Initial Components

  • Inputs
  • InfoSegment
  • Active Round Banner (to be shown at the bottom with the "Donate now" information)
  • Pagination
  • ToastNotification

Project Page: Pots Tab Page & Pot Card Component

The Pots page is going to have different states. If the project is not present in any pot, users should see this state (This Project has not participated in any pots yet.).
Reference https://app.potlock.org/?tab=project&projectId=potlock.near&nav=pots

If the project is participating in any pot, the user should be able to see a list of pots.
Reference: https://app.potlock.org/?tab=project&projectId=near-social-bridge.near&nav=pots

The Pot Card component should also be implemented. Check out the previous project code to create its states. You can see the pot cards here: https://app.potlock.org/?tab=pots. Each Pot Card should take the user to its pot details page.

Pot Details Page: Pot Details Components

implement the Pot details section. The buttons have different states like "Donate”, "Fund matching pool”, and “Challenge payouts”… it depends on the pot status.

Image

Home Page: Hero

Implement the Hero component. The "Donate Randomly", "View Your Project" and "Register Your Project” buttons do not need to have any action at this time because the Donate Randomly Modal and Project Page will be implemented later.

Image

project page: Pots Tab Page & Pot Card Component

Home Tab Page implementation. Reference: https://app.potlock.org/?tab=project&projectId=potlock.near&nav=home

If the project is participating in any pot, the user should be able to see a list of pots: https://app.potlock.org/?tab=project&projectId=near-social-bridge.near&nav=pots
The Pot Card component should also be implemented. Check out the previous project code to create its states. You can see the pot cards here: https://app.potlock.org/?tab=pots. Each Pot Card should take the user to its pot details page.

Donors Page: Leaderboard List

Implement components for Leaderboard List section as well as all the needed functionalities like filters and pagination

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.