Skip to content

Commit

Permalink
feature/CPF-56 change roleId textfield to a select dropdown for Role,…
Browse files Browse the repository at this point in the history
… use formatEnum func to display user.role
  • Loading branch information
Vikariusu committed Jan 4, 2024
1 parent 4e0cc22 commit e3455b0
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion api/src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getCurrentUser = async (
return {
id: 1,
email: '[email protected]',
roles: ['admin', 'usdr-admin', 'USDR_ADMIN'],
roles: ['USDR_ADMIN'],
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Routes = () => {
{/* Reporting Periods */}
<Route path="/reporting-periods" page={ReportingPeriodsPage} name="reportingPeriods" />
{/* Organizations */}
<PrivateSet unauthenticated="forbidden" roles="usdr-admin">
<PrivateSet unauthenticated="forbidden" roles="USDR_ADMIN">
<Route path="/organizations/new" page={OrganizationNewOrganizationPage} name="newOrganization" />
<Route path="/organizations/{id:Int}/edit" page={OrganizationEditOrganizationPage} name="editOrganization" />
<Route path="/organizations/{id:Int}" page={OrganizationOrganizationPage} name="organization" />
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Navigation = () => {
Reporting Periods
</NavLink>
</Nav.Item>
{currentUser?.roles?.includes('usdr-admin') && (
{currentUser?.roles?.includes('USDR_ADMIN') && (
<Nav.Item>
<NavLink
to={routes.organizations()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const NewOrganizationForm = (props: NewOrganizationFormProps) => {

<div className="row mb-3">
<Label name="agencyName" className="form-label col-sm-3 col-form-label">
Team Name
Agency Name
</Label>
<div className="col-sm-6">
<TextField
Expand All @@ -108,7 +108,7 @@ const NewOrganizationForm = (props: NewOrganizationFormProps) => {
name="agencyAbbreviation"
className="form-label col-sm-3 col-form-label"
>
Team Abbreviation
Agency Abbreviation
</Label>
<div className="col-sm-6">
<TextField
Expand Down
9 changes: 5 additions & 4 deletions web/src/components/User/User/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link, routes, navigate } from '@redwoodjs/router'
import { useMutation } from '@redwoodjs/web'
import { toast } from '@redwoodjs/web/toast'

import { formatEnum } from 'src/lib/formatters'
import { timeTag } from 'src/lib/formatters'

const DELETE_USER_MUTATION = gql`
Expand Down Expand Up @@ -65,10 +66,10 @@ const User = ({ user }: Props) => {
<th>Organization id</th>
<td>{user.organizationId}</td>
</tr>
{/* <tr>
<th>Role id</th>
<td>{user.roleId}</td>
</tr> */}
<tr>
<th>Role</th>
<td>{formatEnum(user.role)}</td>
</tr>
<tr>
<th>Created at</th>
<td>{timeTag(user.createdAt)}</td>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/User/UserCell/UserCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const QUERY = gql`
name
agencyId
organizationId
# role
role
createdAt
updatedAt
}
Expand Down
13 changes: 6 additions & 7 deletions web/src/components/User/UserForm/UserForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Button } from 'react-bootstrap'
import { Select } from 'react-bootstrap/Form'
import { useForm, UseFormReturn } from 'react-hook-form'
import type { EditUserById, UpdateUserInput } from 'types/graphql'

Expand Down Expand Up @@ -129,24 +128,24 @@ const UserForm = (props: UserFormProps) => {
/>
</div>

{/* <div className="row mb-3">
<div className="row mb-3">
<Label name="role" className="form-label col-sm-2 col-form-label">
Role
</Label>

<div className="col-sm-6">
<SelectField name="role">
<option>USDR_ADMIN</option>
<option>ORGANIZATION_ADMIN</option>
<option> ORGANIZATION_STAFF</option>
<SelectField name="role" className="form-select">
<option value="USDR_ADMIN">USDR admin</option>
<option value="ORGANIZATION_ADMIN">Organization admin</option>
<option value="ORGANIZATION_STAFF">Organization staff</option>
</SelectField>
</div>

<FieldError
name="role"
className="error-message offset-2 invalid-feedback"
/>
</div> */}
</div>

<div className="row mb-3">
<Label name="agencyId" className="form-label col-sm-2 col-form-label">
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/User/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { FindUsersByOrganizationId } from 'types/graphql'

import { Link, routes } from '@redwoodjs/router'

import { timeTag, truncate } from 'src/lib/formatters'
import { timeTag, truncate, formatEnum } from 'src/lib/formatters'

const UsersList = ({ usersByOrganization }: FindUsersByOrganizationId) => {
return (
Expand All @@ -27,7 +27,7 @@ const UsersList = ({ usersByOrganization }: FindUsersByOrganizationId) => {
<td className="border border-slate-700">
{truncate(user.agencyId)}
</td>
{/* <td className="border border-slate-700">{truncate(user.roleId)}</td> */}
<td className="border border-slate-700">{formatEnum(user.role)}</td>
<td className="border border-slate-700">
{timeTag(user.createdAt)}
</td>
Expand Down
2 changes: 1 addition & 1 deletion web/types/graphql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ export type FindUserByIdVariables = Exact<{
}>;


export type FindUserById = { __typename?: 'Query', user?: { __typename?: 'User', id: number, email: string, name?: string | null, agencyId?: number | null, organizationId: number, createdAt: string, updatedAt: string } | null };
export type FindUserById = { __typename?: 'Query', user?: { __typename?: 'User', id: number, email: string, name?: string | null, agencyId?: number | null, organizationId: number, role?: RoleEnum | null, createdAt: string, updatedAt: string } | null };

export type FindUsersByOrganizationIdVariables = Exact<{
organizationId: Scalars['Int'];
Expand Down

0 comments on commit e3455b0

Please sign in to comment.