saito.k 4b0110856c Merged PR 566: xxxのサンプルページを消し去る
## 概要
[Task3055: xxxのサンプルページを消し去る](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3055)

- 仮で置いてあったサンプルページ削除
  - タブからも削除
  - ルーティングからも削除
- ログイン成功時、階層とロールに応じて遷移する画面を変更する処理を追加

## レビューポイント
- 遷移先を変更する処理は関数に切り出した方が良いか?
  - ほかで使わないからべた書きでも良いかなと思い、こうしました。

## UIの変更
- Before/Afterのスクショなど
- https://ndstokyo.sharepoint.com/:f:/r/sites/Piranha/Shared%20Documents/General/OMDS/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88/Task3055?csf=1&web=1&e=B0E9Ud

## 動作確認状況
- ローカルで確認

## 補足
- 相談、参考資料などがあれば
2023-11-10 02:22:34 +00:00

68 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { isAdminUser, isApproveTier, isStandardUser } from "features/auth";
import { LoginedPaths } from "./types";
import {
ADMIN_ONLY_TABS,
HEADER_MENUS,
TIER1_TO_TIER4_ONLY_TABS,
INVALID_ACCOUNT_TABS,
DELEGATE_TABS,
} from "./constants";
import { TIERS } from "../auth/constants";
// ログイン後のパスかどうか判定
export const isLoginPaths = (d: string): d is LoginedPaths => {
// caseに入力補完で取りうるリテラルしか出なくする
const type = d as LoginedPaths;
switch (type) {
case "/account":
case "/user":
case "/license":
case "/dictations":
case "/workflow":
case "/partners":
return true;
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _: never = type;
return false;
}
}
};
// 権限、階層ごとに表示するヘッダーをわける
export const getFilteredMenus = (isDelegation: boolean) => {
const isAdmin = isAdminUser();
const isStandard = isStandardUser();
const isTier5 = isApproveTier([TIERS.TIER5]);
const tier1ToTier4 = isApproveTier([
TIERS.TIER1,
TIERS.TIER2,
TIERS.TIER3,
TIERS.TIER4,
]);
if (isDelegation) {
return HEADER_MENUS.filter((item) => DELEGATE_TABS.includes(item.key));
}
if (tier1ToTier4) {
if (isAdmin) {
return HEADER_MENUS;
}
if (isStandard) {
return HEADER_MENUS.filter((item) => !ADMIN_ONLY_TABS.includes(item.key));
}
}
if (isTier5) {
if (isAdmin) {
return HEADER_MENUS.filter(
(item) => !TIER1_TO_TIER4_ONLY_TABS.includes(item.key)
);
}
if (isStandard) {
return HEADER_MENUS.filter((item) => !ADMIN_ONLY_TABS.includes(item.key));
}
}
// admin,standardでなく、第15階層でもないアカウントに表示する空のヘッダータブ
return INVALID_ACCOUNT_TABS;
};