Skip to content

Commit

Permalink
feat: Add unsigned checklist tab to handover sidesheet (#1121)
Browse files Browse the repository at this point in the history
* feat: Add unsigned checklist tab to handover sidesheet

* Update libs/handoversidesheet/src/lib/ui-sidesheet/HandoverSidesheet.tsx

Co-authored-by: Gustav-Eikaas <89254170+Gustav-Eikaas@users.noreply.github.com>

---------

Co-authored-by: Gustav-Eikaas <89254170+Gustav-Eikaas@users.noreply.github.com>
  • Loading branch information
EdwardBrunton and Gustav-Eikaas authored Sep 13, 2024
1 parent 1c8bb70 commit 9b6fd5b
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 2 deletions.
10 changes: 9 additions & 1 deletion libs/handoversidesheet/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ export type HandoverSWCR = {
priority: string;
} & HandoverChild;

export type HandoverUnsignedChecklist = {
type: string;
group: string;
discipline: string;
responsible: string;
tagNo: string;
checklistUrl: string;
} & HandoverChild;

export type HandoverUnsignedAction = {
actionNo: string;
commissioningPackageUrlId: string;
Expand Down Expand Up @@ -106,4 +115,3 @@ export type HandoverWorkOrder = {
commissioningPackageUrlId: string | null;
commpkgNumber: string | null;
} & HandoverChild;

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
SwcrTab,
UnsignedActionTab,
UnsignedTaskTab,
UnsignedChecklistTab,
WorkorderBase,
WorkorderTab,
useContextId,
} from '@cc-components/shared';
Expand Down Expand Up @@ -119,6 +121,12 @@ const HandoverSidesheetComponent = (props: Required<HandoverProps>) => {
error: unsignedActionsError,
} = useHandoverResource(props.id, 'unsigned-actions');

const {
data: unsignedChecklists,
dataIsFetching: isDataFetchingUnsignedChecklists,
error: unsignedChecklistsError,
} = useHandoverResource(props.id, 'unsigned-checklists');

const {
data: punchPackages,
dataIsFetching: isDataFetchingPunch,
Expand Down Expand Up @@ -223,6 +231,14 @@ const HandoverSidesheetComponent = (props: Required<HandoverProps>) => {
isLoading={isDataFetchingUnsignedActions}
/>
</Tabs.Tab>
<Tabs.Tab>
Unsigned Checklists

<TabTitle
data={unsignedChecklists}
isLoading={isDataFetchingUnsignedChecklists}
/>
</Tabs.Tab>
<Tabs.Tab>
Punch <TabTitle data={filteredPunches} isLoading={isDataFetchingPunch} />{' '}
</Tabs.Tab>
Expand All @@ -237,7 +253,6 @@ const HandoverSidesheetComponent = (props: Required<HandoverProps>) => {
<Tabs.Tab>
NCR <TabTitle data={ncrPackages} isLoading={isDataFetchingNcr} />{' '}
</Tabs.Tab>

</StyledTabsList>
</StyledTabListWrapper>

Expand Down Expand Up @@ -269,6 +284,13 @@ const HandoverSidesheetComponent = (props: Required<HandoverProps>) => {
error={unsignedActionsError}
/>
</StyledPanel>
<StyledPanel>
<UnsignedChecklistTab
unsignedChecklists={unsignedChecklists}
isFetching={isDataFetchingUnsignedChecklists}
error={unsignedChecklistsError}
/>
</StyledPanel>
<StyledPanel>
<Switch
onChange={(e: ChangeEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
HandoverQuery,
HandoverSWCR,
HandoverUnsignedAction,
HandoverUnsignedChecklist,
HandoverUnsignedTask,
HandoverWorkOrder,
} from '../types';
Expand All @@ -19,6 +20,7 @@ export type HandoverResourceTypeMap = {
'work-orders': HandoverWorkOrder;
'unsigned-tasks': HandoverUnsignedTask;
'unsigned-actions': HandoverUnsignedAction;
'unsigned-checklists': HandoverUnsignedChecklist;
punch: HandoverPunch;
swcr: HandoverSWCR;
details: HandoverDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './punch';
export * from './query';
export * from './unsignedAction';
export * from './unsignedTask';
export * from './unsignedChecklist';
export * from './details';
export * from './material';
export * from './mccr';
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { TabTable } from '../../../../../../table-helpers/src/lib/table/TabTable/TabTable';
import { StyledContentWrapper } from '@cc-components/sharedcomponents';
import { columns } from './columns';
import { UnsignedChecklistBase } from './types';

type UnsignedChecklistTabProps<T> = {
unsignedChecklists: T[] | undefined;
isFetching: boolean;
error: Error | null;
};
export const UnsignedChecklistTab = <T extends UnsignedChecklistBase>({
unsignedChecklists: unsignedChecklists,
error,
isFetching,
}: UnsignedChecklistTabProps<T>): JSX.Element => {
return (
<StyledContentWrapper>
<TabTable
columns={columns}
error={error}
isFetching={isFetching}
packages={unsignedChecklists}
resourceName="Unsigned Checklists"
/>
</StyledContentWrapper>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { ColDef, ICellRendererProps } from '@equinor/workspace-ag-grid';
import { DescriptionCell } from '../../../../../../table-helpers/src/lib/table/cells/DescriptionCell';
import { LinkCell } from '../../../../../../table-helpers/src/lib/table/cells/LinkCell';
import { UnsignedChecklistBase } from './types';

export const columns: ColDef<UnsignedChecklistBase>[] = [
{
colId: 'type',
headerName: 'Type',
valueGetter: (pkg) => pkg.data?.type,
cellRenderer: (props: ICellRendererProps<UnsignedChecklistBase>) => {
return <LinkCell url={props.data?.checklistUrl} urlText={props.value} />;
},
flex: 1,
},
{
colId: 'group',
headerName: 'Group',
valueGetter: (pkg) => pkg.data?.group,
cellRenderer: (props: ICellRendererProps<UnsignedChecklistBase, string | null>) => {
return <DescriptionCell description={props.value} displayFullText />;
},
flex: 1,
},
{
colId: 'discipline',
headerName: 'Discipline',
valueGetter: (pkg) => pkg.data?.discipline,
cellRenderer: (props: ICellRendererProps<UnsignedChecklistBase, string | null>) => {
return <DescriptionCell description={props.value} displayFullText />;
},
flex: 1,
},
{
colId: 'responsible',
headerName: 'Responsible',
valueGetter: (pkg) => pkg.data?.responsible,
cellRenderer: (props: ICellRendererProps<UnsignedChecklistBase, string | null>) => {
return <DescriptionCell description={props.value} displayFullText />;
},
flex: 1,
},
{
colId: '#',
headerName: 'Tag',
valueGetter: (pkg) => pkg.data?.tagNo,
cellRenderer: (props: ICellRendererProps<UnsignedChecklistBase, string | null>) => {
return <DescriptionCell description={props.value} displayFullText />;
},
flex: 1,
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { UnsignedChecklistTab } from './UnsignedChecklistTab';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type UnsignedChecklistBase = {
type: string;
group: string;
discipline: string;
responsible: string;
tagNo: string;
checklistUrl: string;
};

0 comments on commit 9b6fd5b

Please sign in to comment.