Skip to content

Commit

Permalink
🎉 feat: add user column to manage units (closes #666)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Apr 26, 2022
1 parent 90ec53d commit efc8d42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/client/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"success": "Success",
"currency": "$",
"left": "Left",
"right": "Right"
"right": "Right",
"user": "User"
},
"Nav": {
"citizen": "Citizen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Unit } from "src/pages/admin/manage/units";
import Link from "next/link";
import { formatUnitDivisions, makeUnitName, yesOrNoText, formatOfficerDepartment } from "lib/utils";
import { useTranslations } from "use-intl";
import { Button } from "components/Button";
import { Button, buttonVariants } from "components/Button";
import { useGenerateCallsign } from "hooks/useGenerateCallsign";
import useFetch from "lib/useFetch";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -85,6 +85,13 @@ export function AllUnitsTab({ units }: Props) {
),
unit: LABELS[unit.type],
name: makeUnitName(unit),
user: (
<Link href={`/admin/manage/users/${unit.userId}`}>
<a className={`rounded-md transition-all p-1 px-1.5 ${buttonVariants.default}`}>
{unit.user.username}
</a>
</Link>
),
callsign: generateCallsign(unit),
badgeNumber: unit.badgeNumber,
department: formatOfficerDepartment(unit) ?? common("none"),
Expand Down Expand Up @@ -121,6 +128,7 @@ export function AllUnitsTab({ units }: Props) {
: null,
{ Header: `${t("Ems.deputy")}/${t("Leo.officer")}`, accessor: "unit" },
{ Header: common("name"), accessor: "name" },
{ Header: common("user"), accessor: "user" },
{ Header: t("Leo.callsign"), accessor: "callsign" },
BADGE_NUMBERS ? { Header: t("Leo.badgeNumber"), accessor: "badgeNumber" } : null,
{ Header: t("Leo.department"), accessor: "department" },
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ export interface Officer {
activeIncident: LeoIncident | null;
activeIncidentId: string | null;
radioChannelId: string | null;
user: Pick<User, "id" | "username">;
}

/**
Expand Down Expand Up @@ -977,6 +978,7 @@ export interface EmsFdDeputy {
createdAt: Date;
updatedAt: Date;
radioChannelId: string | null;
user: Pick<User, "id" | "username">;
}

/**
Expand Down

0 comments on commit efc8d42

Please sign in to comment.