usdigitalresponse / cpf-reporter

CPF Reporter application maintained by the USDR Grants program.
Apache License 2.0
0 stars 3 forks source link

Organization Setup #56

Open snyde664 opened 6 months ago

snyde664 commented 6 months ago

Why is this issue important?

We need rto be able to create organizations to onboard our partners.

Current State

none

Expected State

The flow should be similar to the "Add Organization" flow in the existing Finder tool as seen here: https://staging.grants.usdr.dev/organizations

The flow should accept the same fields:

image

Need:

Implementation Plan

Follow this createTenant function in the usdr-gost repository: https://github.com/usdigitalresponse/usdr-gost/blob/main/packages/server/src/routes/tenants.js#L24

Relevant Code Snippets

No response

Vikariusu commented 5 months ago

PR info

PR link: https://github.com/usdigitalresponse/cpf-reporter/pull/64 The PR for this ticket has been merged and is currently in staging.

Functionality Overview

Organizations tab

  1. Organizations tab renders only for users with USDR_ADMIN role.
  2. For users without USDR_ADMIN role, navigating to /organizations will show a newly added Forbidden page. Forbidden page renders when the current user doesn't have permissions to view that page but is logged in.

New Organization form

  1. Creates a new organization, a new agency under that organization, and a new user with ORGANIZATION_ADMIN role assigned to that organization and agency.
  2. All fields are required. Trying to submit a form with empty fields will render "This field is required" under the missing fields.
  3. Replaced instances of the term 'Team' with 'Organization' in labels for consistency.

Dev Changes

Changing Role model to an enum

Made a few changes after talking to Aditya

  1. Removed the Role model and replaced it with an enum. Enums are commonly written in uppercase letters (e.g. USDR_ADMIN), which is the convention I've followed.
  2. Kept the hardcoded roles array in getCurrentUser() but changed the string that we're passing to match the enum formatting.
  3. Updated the user adding/editing forms to use a select input (dropdown) for the Role field, replacing the previous text field for Role ID.
  4. Used an existing formatEnum() function to change how we display user.role on the frontend (eg. ORGANIZATION_ADMIN to Organization admin )

New Organization form as a separate component

New Organization form has its own component, separate from Edit Organization form. By default, Redwood uses the same form for adding and editing but since those 2 forms are quite different, separating the two makes the code more clear.