Skip to content

Commit

Permalink
Merge pull request #282 from jadmsaadaot/SUBMIT-task#353
Browse files Browse the repository at this point in the history
Allow everybody to see entity notes all the time
  • Loading branch information
jadmsaadaot authored Feb 6, 2025
2 parents 67f6d64 + 866d287 commit 2eb5bec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
13 changes: 0 additions & 13 deletions submit-web/src/components/Shared/PermissionGate/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { EPIC_SUBMIT_ROLE } from "@/models/Role";

export const checkIfEAO = (roles: string[]) => {
if (!roles) {
return false;
}
return roles.length > 0;
};
export const checkIfManager = (roles?: string[]) => {
if (!roles) {
return false;
Expand All @@ -29,13 +23,6 @@ export const checkIfStaff = (roles?: string[]) => {
);
};

export const checkIfProponent = (roles?: string[]) => {
if (!roles || roles.length === 0) {
return true;
}
return false;
};

export const hasPermission = ({
permissions,
scopes,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LoadingButton } from "@/components/Shared/LoadingButton";
import { checkIfProponent } from "@/components/Shared/PermissionGate/utils";
import { useCreatePackageUpdateRequesNote } from "@/hooks/api/usePackages";
import { UpdateRequest } from "@/models/UpdateRequest";
import { USER_TYPE } from "@/models/User";
import { useAccount } from "@/store/accountStore";
import {
Box,
Expand Down Expand Up @@ -33,8 +33,8 @@ export const AddRequestNoteSection = ({
packageId: updateRequest.submission_package_id,
});

const { roles } = useAccount();
const isProponent = checkIfProponent(roles);
const { userType } = useAccount();
const isProponent = userType === USER_TYPE.PROPONENT;

return (
<Box mt="1em">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Box, Typography } from "@mui/material";
import { BCDesignTokens } from "epic.theme";
import dateUtils from "@/utils/dateUtils";
import { UPDATE_REQUEST_TYPE, UpdateRequest } from "@/models/UpdateRequest";
import { Case, Switch, Unless, When } from "react-if";
import { Case, Switch, When } from "react-if";
import { AddRequestNoteSection } from "./AddRequestNoteSection";
import { PACKAGE_STATUS, SubmissionPackage } from "@/models/Package";
import { checkIfEAO } from "@/components/Shared/PermissionGate/utils";
import { SubmissionPackage } from "@/models/Package";
import { useAccount } from "@/store/accountStore";
import { USER_TYPE } from "@/models/User";

type UpdateRequestProps = Readonly<{
updateRequest: UpdateRequest;
Expand All @@ -21,18 +21,11 @@ export default function RequestSection({
updateRequest;
const createdDate = dateUtils.formatDate(created_date);

const { roles } = useAccount();
const isEAO = checkIfEAO(roles || []);
const { userType } = useAccount();

const submissionItems = submissionPackage.items.filter((item) =>
submission_item_ids.includes(item.id),
);

const showNoteSection =
(isEAO &&
submissionPackage.status.includes(PACKAGE_STATUS.SUBMITTED.value)) ||
(!isEAO && Boolean(note));

return (
<Box sx={{ my: BCDesignTokens.layoutMarginLarge }}>
<Box
Expand Down Expand Up @@ -69,7 +62,7 @@ export default function RequestSection({
{reason}
</Typography>

<When condition={showNoteSection}>
<When condition={Boolean(note)}>
<Typography
variant="body1"
sx={{ mb: 1, fontWeight: BCDesignTokens.typographyFontWeightsBold }}
Expand All @@ -80,9 +73,9 @@ export default function RequestSection({
{note}
</Typography>
</When>
<Unless condition={isEAO}>
<When condition={userType === USER_TYPE.PROPONENT}>
<AddRequestNoteSection updateRequest={updateRequest} />
</Unless>
</When>
</Box>
);
}

0 comments on commit 2eb5bec

Please sign in to comment.