Skip to content

Commit

Permalink
fix: Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nesadrian committed Jan 15, 2024
1 parent e1c3ca6 commit a05b9f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 54 deletions.
13 changes: 4 additions & 9 deletions components/AppHeader/UserMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";
import styles from "./UserMenu.module.scss";
import { Button, Menu } from "@equinor/eds-core-react";
import { useAccount, useMsal } from "@azure/msal-react";
Expand All @@ -14,13 +14,8 @@ const UserMenu: React.FC = () => {
const { publicRuntimeConfig } = getConfig();
const commitHash = publicRuntimeConfig.RADIX_GIT_COMMIT_HASH;

const [state, setState] = React.useState<{
buttonEl: HTMLButtonElement;
}>({
buttonEl: null,
});
const [buttonEl, setButtonEl] = useState<HTMLButtonElement | null>(null);

const { buttonEl } = state;
const isOpen = Boolean(buttonEl);

const openMenu = (
Expand All @@ -29,10 +24,10 @@ const UserMenu: React.FC = () => {
| React.KeyboardEvent<HTMLButtonElement>
) => {
const target = e.target as HTMLButtonElement;
setState({ ...state, buttonEl: target });
setButtonEl(target);
};

const closeMenu = () => setState({ ...state, buttonEl: null });
const closeMenu = () => setButtonEl(null);

const onKeyPress = (e: React.KeyboardEvent<HTMLButtonElement>) => {
const { key } = e;
Expand Down
33 changes: 0 additions & 33 deletions components/SelectTaskType.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions interfaces/VsmObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface vsmObject {
parent?: number;
name?: string;
fkObjectType?: vsmObjectTypes;
time?: number;
timeDefinition?: string;
time?: number | null;
timeDefinition?: string | null;
role?: string;
childObjects?: Array<vsmObject>;
vsmObjectType?: {
Expand Down
15 changes: 5 additions & 10 deletions types/timeDefinitions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ export const timeDefinitions = [
export const getTimeDefinitionValues = (): Array<string> =>
timeDefinitions.map((item) => item.displayName);

export const getTimeDefinitionValue = (displayName: string): string | null => {
const timeDefinitionValue = timeDefinitions.find(
(item) => item?.displayName === displayName
)?.value;
return timeDefinitionValue || null;
};
export const getTimeDefinitionValue = (displayName: string) =>
timeDefinitions.find((item) => item?.displayName === displayName)?.value ||
null;

export const getTimeDefinitionDisplayName = (value: string): string => {
if (!value) return "";
return timeDefinitions.find((item) => item.value === value).displayName;
};
export const getTimeDefinitionDisplayName = (value: string) =>
timeDefinitions.find((item) => item.value === value)?.displayName || "";

/**
* Capitalize the first letter and lowercase the rest.
Expand Down

0 comments on commit a05b9f8

Please sign in to comment.