diff --git a/.changeset/tricky-deers-argue.md b/.changeset/tricky-deers-argue.md new file mode 100644 index 000000000..993bbc864 --- /dev/null +++ b/.changeset/tricky-deers-argue.md @@ -0,0 +1,7 @@ +--- +"@equinor/mad-dfw": minor +--- + +WorkOrderCell adjusted. Renamed prop `workOrder` to `workOrderId`. Added new prop, `workOrderType`, +this relates to the workOrderId. Removed the `symbolDirection` and `overwriteLabel` props. The +symbol direction is now column by default. diff --git a/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx b/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx index de19443ba..dcd082a69 100644 --- a/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx +++ b/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx @@ -24,7 +24,8 @@ export const WorkOrderCellScreen = () => { { isProductionCritical startJobButton={{ visible: true, + loading: true, onPress: () => console.log("Start"), }} readyForOperationButton={{ @@ -60,7 +62,8 @@ export const WorkOrderCellScreen = () => { { onPress: () => console.log("Complete"), }} showSymbols - symbolDirection="row" /> @@ -94,7 +96,8 @@ export const WorkOrderCellScreen = () => { { ); diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx b/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx index f8c6fb36e..b6a0456fc 100644 --- a/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx +++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx @@ -1,12 +1,11 @@ +import { Color } from "@equinor/mad-components"; import React from "react"; import { PropertyRow } from "../PropertyRow"; import { WorkOrder } from "./types"; -import moment from "moment"; -import { Color, useToken } from "@equinor/mad-components"; +import { formatDate } from "./utils"; -const defaultWorkOrderLabelMap: Record = { +const workOrderLabelMap: Record = { title: "Title", - workOrder: "Work order", maintenanceType: "Maintenance type", functionalLocation: "Functional Location", equipment: "Equipment", @@ -18,34 +17,24 @@ const defaultWorkOrderLabelMap: Record = { } as const; type PropertyListProps = { - workOrder: Partial; + data: Partial; valueColor: Color; - currentDate: Date; - overwriteLabel?: Partial>; }; -export const PropertyList = ({ - workOrder, - valueColor, - currentDate, - overwriteLabel = {}, -}: PropertyListProps) => { - const token = useToken(); - - const formatDate = (dateString: string) => moment(dateString).format("DD.MM.YYYY"); - - const requiredEnd = workOrder.requiredEnd ? new Date(workOrder.requiredEnd) : null; +export const PropertyList = ({ data, valueColor }: PropertyListProps) => { + const currentDate = new Date(); + const requiredEnd = data.requiredEnd ? new Date(data.requiredEnd) : null; const combinedDates = - workOrder.basicStartDate && workOrder.basicFinishDate - ? `${formatDate(workOrder.basicStartDate)} - ${formatDate(workOrder.basicFinishDate)}` + data.basicStartDate && data.basicFinishDate + ? `${formatDate(data.basicStartDate)} - ${formatDate(data.basicFinishDate)}` : null; - const getLabel = (key: keyof WorkOrder) => { + const getLabel = (key: string) => { if (key === "basicStartDate" && combinedDates) { return "Basic start / finish"; } - return overwriteLabel?.[key] ?? defaultWorkOrderLabelMap[key]; + return workOrderLabelMap[key]; }; const getDisplayValue = (key: keyof WorkOrder, value: string | undefined) => { @@ -60,11 +49,10 @@ export const PropertyList = ({ return ( <> - {Object.entries(workOrder).map(([key, value], index) => { + {Object.entries(data).map(([key, value], index) => { const typedKey = key as keyof WorkOrder; if (combinedDates && typedKey === "basicFinishDate") return null; - if (value || (typedKey === "basicStartDate" && combinedDates)) { const label = getLabel(typedKey); const displayValue = getDisplayValue(typedKey, value); @@ -75,13 +63,14 @@ export const PropertyList = ({ : valueColor; return ( - + label && ( + + ) ); } return null; diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx index 6007fa406..ab868010c 100644 --- a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx +++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx @@ -2,14 +2,14 @@ import { Button, Cell, EDSStyleSheet, - Label, Typography, useBreakpoint, useStyles, + useToken, } from "@equinor/mad-components"; -import moment from "moment"; import React, { useMemo } from "react"; import { View } from "react-native"; +import { PropertyRow } from "../PropertyRow"; import { PropertyList } from "./PropertyList"; import { StatusIcon } from "./StatusIcon"; import { WorkOrderCellProps } from "./types"; @@ -17,13 +17,13 @@ import { getStatusIconsAndLabels } from "./utils"; export const WorkOrderCell = ({ title, + workOrderId, + workOrderType, maintenanceType, - showSymbols, - symbolDirection = "column", + showSymbols = true, valueColor = "textTertiary", isHseCritical, isProductionCritical, - overwriteLabel, style, startJobButton, readyForOperationButton, @@ -31,11 +31,14 @@ export const WorkOrderCell = ({ ...rest }: WorkOrderCellProps) => { const breakpoint = useBreakpoint(); - const styles = useStyles(themeStyles, { symbolDirection }); + const token = useToken(); + const styles = useStyles(themeStyles); const anyButtonVisible = startJobButton?.visible ?? readyForOperationButton?.visible ?? tecoButton?.visible; - const currentDate = moment(); + + const currentDate = useMemo(() => new Date(), []); + const iconsAndLabels = useMemo( () => getStatusIconsAndLabels( @@ -50,23 +53,28 @@ export const WorkOrderCell = ({ return ( - + {title} - {showSymbols && ( - + {showSymbols && iconsAndLabels.length > 0 && ( + {iconsAndLabels.map((item, index) => ( ))} )} - {maintenanceType &&