Skip to content

Commit

Permalink
fix(ui): refresh freight after manual approval
Browse files Browse the repository at this point in the history
Signed-off-by: Remington Breeze <remington@breeze.software>
  • Loading branch information
rbreeze committed May 22, 2024
1 parent da05fa7 commit 3198378
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ui/src/features/project/pipelines/pipelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ export const Pipelines = () => {
hideSubscriptions
);

const [fullFreightById, setFullFreightById] = React.useState<{ [key: string]: Freight }>({});

const { mutate: manualApproveAction } = useMutation(approveFreight, {
onError,
onSuccess: () => {
message.success(`Freight ${state.freight} has been manually approved.`);
refetchFreightData();
state.clear();
}
});
Expand All @@ -158,12 +157,12 @@ export const Pipelines = () => {
return [stagesPerFreight, subscribersByStage];
}, [data, freightData]);

React.useEffect(() => {
const fullFreightById: { [key: string]: Freight } = {};
const fullFreightById: { [key: string]: Freight } = useMemo(() => {
const freightMap: { [key: string]: Freight } = {};
(freightData?.groups['']?.freight || []).forEach((freight) => {
fullFreightById[freight?.metadata?.name || ''] = freight;
freightMap[freight?.metadata?.name || ''] = freight;
});
setFullFreightById(fullFreightById);
return freightMap;
}, [freightData]);

if (isLoading || isLoadingFreight) return <LoadingState />;
Expand Down

0 comments on commit 3198378

Please sign in to comment.