Skip to content

Commit

Permalink
Merge branch 'master' into feat/Scenarios-Old-Fetch-Scenarios-By-Quer…
Browse files Browse the repository at this point in the history
…y-With-Filter
  • Loading branch information
JacobJsuh committed Jun 12, 2024
2 parents 74f05b6 + 37aa1c2 commit d77eebb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const ScenarioListOLD = (props: ScenarioListOLDProps) => {
nameField,
timeZone,
statusOverrideFunction,
groupByItemFunction,
} = props;
const [groupedScenarios, setGroupedScenarios] = useState<Dictionary<ScenarioOLD[]>>();
const [selectedId, setSelectedId] = useState(selectedScenarioId);
Expand All @@ -42,9 +43,11 @@ const ScenarioListOLD = (props: ScenarioListOLDProps) => {
setGroupedScenarios(
showHour || showDate
? groupBy(scenarios, (scenario) => {
return scenario.dateTime && timeZone
? format(utcToTz(scenario.dateTime, timeZone), 'yyyy-MM-dd')
: format(parseISO(scenario.dateTime), 'yyyy-MM-dd') || '';
return groupByItemFunction ?
groupByItemFunction(scenario, timeZone) :
scenario.dateTime && timeZone
? format(utcToTz(scenario.dateTime, timeZone), 'yyyy-MM-dd')
: format(parseISO(scenario.dateTime), 'yyyy-MM-dd') || '';
})
: groupBy(scenarios, (scenario) => scenario.dateTime),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ interface ScenarioListOLDProps {
* The function that returns the new status to override
*/
statusOverrideFunction?: (scenario: Scenario) => StatusOverride;
/**
* The function that returns the item to be used for grouping by:
*/
groupByItemFunction?: (scenario: Scenario, timeZone?: string) => string;
}

export default ScenarioListOLDProps;
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const ScenariosOLD = (props: ScenariosOLDProps) => {
translations,
timeZone,
statusOverrideFunction,
groupByItemFunction,
} = props;

const [dialog, setDialog] = useState<GeneralDialogProps>();
Expand Down Expand Up @@ -461,6 +462,7 @@ const ScenariosOLD = (props: ScenariosOLDProps) => {
status={status}
timeZone={timeZone}
statusOverrideFunction={statusOverrideFunction}
groupByItemFunction={groupByItemFunction}
/>
);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/react-components/src/Scenarios/ScenariosOLD/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ interface ScenariosOLDProps {
* The function that returns the new status to override
*/
statusOverrideFunction?: (scenario: Scenario) => StatusOverride | {};

/**
* The function that returns the item to be used for grouping by:
*/
groupByItemFunction?: (scenario: Scenario, timeZone?: string) => string;
}

interface dataFilterbyPropertyObj {
Expand Down

0 comments on commit d77eebb

Please sign in to comment.