Skip to content

Commit

Permalink
Feature/104582 handle scope handed over status (#768)
Browse files Browse the repository at this point in the history
* Added ScopeHandedOver enumm and added to filter

* Unable to edit when scope handed over

* Removed step created when handed over

* Cannot edit when scope handed over

* Renamed files

* Improve readability for ScopeHandedOver status in search IPO

* Rename

* Allow admin to delete IPOs with status ScopeHandedOver

---------

Co-authored-by: VRiveland <[email protected]>
  • Loading branch information
2 people authored and chormaz committed Sep 13, 2023
1 parent cfc0458 commit bfc263b
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/app/ProcosysRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const UserGreeting = React.lazy(() => import('./../modules/UserGreeting'));
const Preservation = React.lazy(() => import('./../modules/Preservation'));
const PlantConfig = React.lazy(() => import('./../modules/PlantConfig'));
const InvitationForPunchOut = React.lazy(
() => import('./../modules/InvitationForPunchOut')
() => import('../modules/InvitationForPunchOut/InvitationForPunchOut')
);

const Page404 = (): JSX.Element => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CreateIPO from './views/CreateAndEditIPO/CreateIPO';
import EditIPO from './views/CreateAndEditIPO/EditIPO';
import { Helmet } from 'react-helmet';
import { InvitationForPunchOutContextProvider } from './context/InvitationForPunchOutContext';
import SearchIPO from './views/SearchIPO';
import SearchIPO from './views/SearchIPO/SearchIpo';
import ViewIPO from './views/ViewIPO/ViewIPO';
import withAccessControl from '@procosys/core/security/withAccessControl';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ProCoSysApiError } from '../../../core/ProCoSysApiError';
import ProCoSysSettings from '../../../core/ProCoSysSettings';
import Qs from 'qs';
import { RequestCanceler } from '../../../http/HttpClient';
import { IpoStatusEnum } from '../views/enums';

export class IpoApiError extends ProCoSysApiError {
constructor(error: AxiosError) {
Expand Down Expand Up @@ -183,7 +184,7 @@ interface FunctionalRoleResponse {
interface IPO {
id: number;
title: string;
status: string;
status: IpoStatusEnum;
type: string;
createdAtUtc: Date;
startTimeUtc: Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
CheckboxFilterValue,
dateFilterParamType,
filterParamType,
} from '../index';
} from '../InvitationsFilter';
import { CheckboxSection, DateField, DatesContainer } from './index.style';
import { Collapse, CollapseInfo } from '../index.style';
import React, { ChangeEvent, useState } from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fireEvent, render } from '@testing-library/react';

import CheckboxFilterWithDates from '../index';
import CheckboxFilterWithDates from '../CheckboxFilterWithDates';
import React from 'react';

const checkboxItems = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
import { IPOFilter, ProjectDetails, SavedIPOFilter } from '../types';
import React, { useEffect, useRef, useState } from 'react';

import CheckboxFilterWithDates from './CheckboxFilterWithDates';
import CheckboxFilterWithDates from './CheckboxFilterWithDates/CheckboxFilterWithDates';
import EdsIcon from '@procosys/components/EdsIcon';
import { IpoStatusEnum } from '../../enums';
import SavedFilters from './SavedFilters';
import SelectFilter from './SelectFilter';
import SelectFilter from './SelectFilter/SelectFilter';
import { SelectItem } from '@procosys/components/Select';
import { isValidDate } from '@procosys/core/services/DateService';
import {
Expand Down Expand Up @@ -93,6 +93,10 @@ const ipoStatuses: FilterInput[] = [
id: IpoStatusEnum.ACCEPTED,
title: 'Accepted',
},
{
id: IpoStatusEnum.SCOPEHANDEDOVER,
title: 'Scope Handed Over',
},
];

const punchOutDateFields: FilterInput[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Dropdown from '@procosys/components/Dropdown';
import EdsIcon from '@procosys/components/EdsIcon';
import { SelectItem } from '@procosys/components/Select';
import Spinner from '@procosys/components/Spinner';
import { rolePersonParamType } from '..';
import { rolePersonParamType } from '../InvitationsFilter';
import { showSnackbarNotification } from '@procosys/core/services/NotificationService';
import { useInvitationForPunchOutContext } from '@procosys/modules/InvitationForPunchOut/context/InvitationForPunchOutContext';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PersonSelector from '../index';
import PersonSelector from '../PersonSelector';
import React from 'react';
import { render } from '@testing-library/react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Container, DropdownItem } from './index.style';
import { Container, DropdownItem } from './RoleSelector.style';
import React, { useEffect, useState } from 'react';

import Dropdown from '@procosys/components/Dropdown';
import EdsIcon from '@procosys/components/EdsIcon';
import { SelectItem } from '@procosys/components/Select';
import Spinner from '@procosys/components/Spinner';
import { rolePersonParamType } from '..';
import { rolePersonParamType } from '../InvitationsFilter';

interface RoleSelectorProps {
functionalRoleCode: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import RoleSelector from '../index';
import RoleSelector from '../RoleSelector';
import { render } from '@testing-library/react';

const roles = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Collapse, CollapseInfo } from '../index.style';
import React, { useState } from 'react';
import { FilterContainer } from './index.style';
import PersonSelector from '../PersonSelector';
import RoleSelector from '../RoleSelector';
import { FilterContainer } from './SelectFilter.style';
import PersonSelector from '../PersonSelector/PersonSelector';
import RoleSelector from '../RoleSelector/RoleSelector';
import { SelectItem } from '@procosys/components/Select';
import { rolePersonParamType } from '..';
import { rolePersonParamType } from '../InvitationsFilter';
import { KeyboardArrowUp, KeyboardArrowDown } from '@mui/icons-material';

type SelectProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fireEvent, render } from '@testing-library/react';

import EdsIcon from '@procosys/components/EdsIcon';
import React from 'react';
import SelectFilter from '../index';
import SelectFilter from '../SelectFilter';

const roles = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fireEvent, render } from '@testing-library/react';

import InvitationsFilter from '../index';
import InvitationsFilter from '../InvitationsFilter';
import React from 'react';

const emptyFilter = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
LeftPartOfHeader,
StyledButton,
TooltipText,
} from './index.style';
} from './SearchIpo.style';
import { IPOFilter, IPOs, SavedIPOFilter } from './types';
import React, { useEffect, useReducer, useRef, useState } from 'react';

import { Canceler } from 'axios';
import Dropdown from '@procosys/components/Dropdown';
import EdsIcon from '@procosys/components/EdsIcon';
import InvitationsFilter from './Filter';
import InvitationsTable from './Table';
import InvitationsFilter from './Filter/InvitationsFilter';
import InvitationsTable from './Table/InvitationsTable';
import { Link } from 'react-router-dom';
import { ProjectDetails } from '@procosys/modules/InvitationForPunchOut/types';
import { SelectItem } from '@procosys/components/Select';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Container, CustomLink } from './index.style';
import { Container, CustomLink } from './InvitationsTable.style';
import React, { useEffect, useState } from 'react';
import { IPO } from '../types';
import { Typography } from '@equinor/eds-core-react';
import { getFormattedDate } from '@procosys/core/services/DateService';
import { Query, TableOptions, UseTableRowProps } from 'react-table';
import ProcosysTable, { TableSorting } from '@procosys/components/Table';
import { Tooltip } from '@mui/material';
import { IpoStatusEnum } from '../../enums';

interface InvitationsTableProps {
getIPOs: (
Expand Down Expand Up @@ -336,7 +337,9 @@ const InvitationsTable = ({
Header: 'Status',
id: 'status',
accessor: (d: IPO): string | undefined => {
return d.status;
if (d.status == IpoStatusEnum.SCOPEHANDEDOVER)
return 'Scope handed over';
else return d.status;
},
Cell: (rowData: TableOptions<IPO>): JSX.Element => {
return <Typography>{rowData.row.values.status}</Typography>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import InvitationsTable from '../index';
import InvitationsTable from '../InvitationsTable';
import React from 'react';
import { render, waitFor } from '@testing-library/react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, waitFor } from '@testing-library/react';

import React from 'react';
import SearchIPO from '../../SearchIPO';
import SearchIPO from '../SearchIpo';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router';

Expand Down
4 changes: 3 additions & 1 deletion src/modules/InvitationForPunchOut/views/SearchIPO/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { IpoStatusEnum } from '../enums';

export interface IPO {
id: number;
title: string;
status: string;
status: IpoStatusEnum;
type: string;
createdAtUtc: Date;
startTimeUtc: Date;
Expand Down
14 changes: 14 additions & 0 deletions src/modules/InvitationForPunchOut/views/ViewIPO/ViewIPO.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ const stepsWhenCanceled: Step[] = [
{ title: 'Punch-out is canceled', isCompleted: true },
];

const stepsWhenHandedOver: Step[] = [
{ title: 'Invitation for punch-out sent', isCompleted: true },
{ title: 'Punch-out scope handed over', isCompleted: true },
];

enum StepsEnum {
Planned = 1,
Completed = 2,
Accepted = 3,
Canceled = 4,
ScopeHandedOver = 5,
}

const ipoHeaderSize = 136;
Expand Down Expand Up @@ -143,6 +149,10 @@ const ViewIPO = (): JSX.Element => {
setSteps(stepsWhenCanceled);
setCurrentStep(StepsEnum.Canceled + 1);
break;
case StepsEnum[5]:
setSteps(stepsWhenHandedOver);
setCurrentStep(StepsEnum.ScopeHandedOver + 1);
break;
default:
setCurrentStep(StepsEnum.Planned + 1);
}
Expand Down Expand Up @@ -525,6 +535,10 @@ const ViewIPO = (): JSX.Element => {
canDelete={
invitation.canDelete ||
(invitation.status === IpoStatusEnum.CANCELED &&
isAdmin &&
isUsingAdminRights) ||
(invitation.status ===
IpoStatusEnum.SCOPEHANDEDOVER &&
isAdmin &&
isUsingAdminRights)
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/InvitationForPunchOut/views/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum IpoStatusEnum {
PLANNED = 'Planned',
COMPLETED = 'Completed',
ACCEPTED = 'Accepted',
SCOPEHANDEDOVER = 'ScopeHandedOver',
CANCELED = 'Canceled',
}

Expand Down

0 comments on commit bfc263b

Please sign in to comment.