-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10dd397
commit b7e824a
Showing
8 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
libs/shared/src/packages/sidesheet/src/lib/sidesheet/tabs/cutoff/CutoffTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { TabTable } from '../../../../../../table-helpers/src/lib/table/TabTable'; | ||
import { StyledContentWrapper } from '../tabs.styles'; | ||
import { columns } from './columns'; | ||
import { CutoffBase } from './types'; | ||
|
||
type CutoffTabProps<T> = { | ||
cutoff: T[] | undefined; | ||
isFetching: boolean; | ||
error: Error | null; | ||
}; | ||
export const CutoffTab = <T extends CutoffBase>({ | ||
error, | ||
isFetching, | ||
cutoff: Cutoff, | ||
}: CutoffTabProps<T>): JSX.Element => { | ||
return ( | ||
<StyledContentWrapper> | ||
<TabTable | ||
columns={columns} | ||
error={error} | ||
isFetching={isFetching} | ||
packages={Cutoff} | ||
resourceName="Cutoff" | ||
/> | ||
</StyledContentWrapper> | ||
); | ||
}; |
66 changes: 66 additions & 0 deletions
66
libs/shared/src/packages/sidesheet/src/lib/sidesheet/tabs/cutoff/columns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { ColDef, ICellRendererProps } from '@equinor/workspace-ag-grid'; | ||
import { CutoffBase } from './types'; | ||
import { DateCell, DescriptionCell } from '../../../../../../table-helpers'; | ||
|
||
export const columns: ColDef<CutoffBase>[] = [ | ||
{ | ||
field: 'Cutoff', | ||
headerName: 'Cutoff', | ||
valueGetter: (pkg) => pkg.data?.cutoffWeek, | ||
valueFormatter: (pkg) => | ||
pkg.data?.cutoffWeek | ||
? `${pkg.data.cutoffWeek.slice(0, 4)}w${pkg.data.cutoffWeek.slice(4)}` | ||
: '', | ||
minWidth: 150, | ||
}, | ||
{ | ||
field: 'Title', | ||
valueGetter: (pkg) => pkg.data?.title, | ||
cellRenderer: (props: ICellRendererProps<CutoffBase, string | null>) => { | ||
return <DescriptionCell description={props.value} />; | ||
}, | ||
}, | ||
{ | ||
field: 'Project', | ||
valueGetter: (pkg) => pkg.data?.project, | ||
}, | ||
{ | ||
field: 'Milestone', | ||
valueGetter: (pkg) => pkg.data?.milestone, | ||
}, | ||
{ | ||
field: 'SubMilestone', | ||
valueGetter: (pkg) => pkg.data?.subMilestone, | ||
}, | ||
{ | ||
field: 'Comm.Pkg', | ||
valueGetter: (pkg) => pkg.data?.commissioningPackageNo, | ||
}, | ||
{ | ||
field: 'Area', | ||
valueGetter: (pkg) => pkg.data?.location, | ||
}, | ||
{ | ||
field: 'HoldBy', | ||
valueGetter: (pkg) => pkg.data?.holdBy, | ||
}, | ||
{ | ||
field: 'StartupDate', | ||
valueGetter: (pkg) => pkg.data?.plannedStartupDate, | ||
cellRenderer: (props: ICellRendererProps<CutoffBase, string | null>) => ( | ||
<DateCell dateString={props.data?.plannedStartupDate} /> | ||
), | ||
}, | ||
{ | ||
field: 'FinishDate', | ||
valueGetter: (pkg) => pkg.data?.plannedCompletionDate, | ||
cellRenderer: (props: ICellRendererProps<CutoffBase, string | null>) => ( | ||
<DateCell dateString={props.data?.plannedCompletionDate} /> | ||
), | ||
}, | ||
|
||
{ | ||
field: 'Responsible', | ||
valueGetter: (pkg) => pkg.data?.responsible, | ||
}, | ||
]; |
1 change: 1 addition & 0 deletions
1
libs/shared/src/packages/sidesheet/src/lib/sidesheet/tabs/cutoff/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { CutoffTab } from './CutoffTab'; |
13 changes: 13 additions & 0 deletions
13
libs/shared/src/packages/sidesheet/src/lib/sidesheet/tabs/cutoff/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export type CutoffBase = { | ||
cutoffWeek: string; | ||
title: string | null; | ||
project: string | null; | ||
commissioningPackageNo: string | null; | ||
location: string | null; | ||
holdBy: string | null; | ||
plannedStartupDate: string | null; | ||
plannedCompletionDate: string | null; | ||
milestone: string; | ||
subMilestone: string | null; | ||
responsible: string | null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export type WorkOrderCutoff = { | ||
sourceName: string | null; | ||
sourceIdentity: string; | ||
facility: string; | ||
project: string; | ||
cutoffWeek: string; | ||
cutoffDate: string; | ||
expendedManHoursLastWeek: number; | ||
earnedManHoursLastWeek: number; | ||
workOrderNo: string; | ||
title: string | null; | ||
description: string | null; | ||
plannedStartupDate: string; | ||
actualStartupDate: string | null; | ||
plannedCompletionDate: string; | ||
actualCompletionDate: string | null; | ||
commissioningPackageNo: string | null; | ||
milestone: string; | ||
category: string | null; | ||
holdBy: string | null; | ||
typeOfWork: string | null; | ||
onshoreOffshore: string | null; | ||
projectProgress: number; | ||
workOrderType: string | null; | ||
jobStatus: string; | ||
materialStatus: string; | ||
estimatedManHours: number; | ||
expendedManHours: number; | ||
remainingManHours: string | null; | ||
earnedManHours: number; | ||
subMilestone: string | null; | ||
responsible: string; | ||
discipline: string; | ||
location: string | null; | ||
updatedDate: string; | ||
workOrderId: string; | ||
constructionComments: string | null; | ||
materialComments: string | null; | ||
commissioningPackageId: string | null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
libs/workordersidesheet/src/lib/utils-sidesheet/useCutoff.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useContextId, useHttpClient } from '@cc-components/shared'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { WorkOrderCutoff } from '../types/workOrderCutoff'; | ||
|
||
const fetchCutoff = async ( | ||
ccClient: ReturnType<typeof useHttpClient>, | ||
contextId: string | undefined, | ||
packageId: string | null, | ||
signal?: AbortSignal | ||
) => { | ||
const res = await ccClient.fetch( | ||
`/api/contexts/${contextId}/work-orders/${packageId}/cutoff`, | ||
{ | ||
signal, | ||
} | ||
); | ||
|
||
if (!res.ok) { | ||
throw new Error('failed to fetch cutoff'); | ||
} | ||
|
||
return (await res.json()) as WorkOrderCutoff[]; | ||
}; | ||
export const useCutoff = (packageId: string | null) => { | ||
const ccApp = useHttpClient(); | ||
const contextId = useContextId(); | ||
|
||
const { data, isLoading, error } = useQuery({ | ||
queryFn: (a) => fetchCutoff(ccApp, contextId, packageId, a.signal), | ||
queryKey: ['cutoff', packageId], | ||
useErrorBoundary: false, | ||
}); | ||
return { | ||
//Rip performance | ||
data, | ||
isLoading, | ||
error, | ||
}; | ||
}; |