Skip to content

Commit

Permalink
fix: Label ui
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 29, 2024
1 parent 17a1e3b commit 170e8f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import { Role, UserRole } from "@opensystemslab/planx-core/types";
import { AddButton } from "pages/Team";
import React, { useState } from "react";
import Permission from "ui/editor/Permission";
Expand Down Expand Up @@ -50,10 +51,12 @@ export const MembersTable = ({
const [actionType, setActionType] = useState<ActionType>("add");
const [initialValues, setInitialValues] = useState<TeamMember | undefined>();

const roleLabels: Record<string, string> = {
const roleLabels: Record<Role, string> = {
platformAdmin: "Admin",
teamEditor: "Editor",
teamViewer: "Viewer",
demoUser: "Demo User",
public: "Public",
};

const editUser = (member: TeamMember) => {
Expand All @@ -72,7 +75,7 @@ export const MembersTable = ({
setInitialValues(undefined);
};

const getRoleLabel = (role: string) => {
const getRoleLabel = (role: Role) => {
return roleLabels[role] || role;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ describe("adding a new user to the Demo team", () => {
expect(newUser.role).toBe("demoUser");

// Use role tag displayed in table
expect(within(membersTable).getByText("demoUser")).toBeVisible();
expect(within(membersTable).getByText("Demo User")).toBeVisible();
});
});

0 comments on commit 170e8f1

Please sign in to comment.