Skip to content

Commit

Permalink
fix(COS-6908): Update SLIs filtering to include ended line items not …
Browse files Browse the repository at this point in the history
…closed by the user (#17)
  • Loading branch information
Kasia9090 authored Feb 19, 2025
1 parent 1737787 commit b0d91b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export const ProductCard = observer(
? store.skus.getById(liveServices[0].tempValue.skuId)
: null;

const isClosed = liveServices?.every(
(service) => service?.tempValue?.closed,
);
const isClosed =
!!liveServices?.length &&
liveServices.every((service) => service?.tempValue?.closed);

const handleCloseChange = (closed: boolean) => {
liveServices?.forEach((service) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ContractLineItemStore } from '@store/ContractLineItems/ContractLineItem
import { useStore } from '@shared/hooks/useStore';
import { BilledType, ContractStatus, ServiceLineItem } from '@graphql/types';

import { ProductCard } from './ProductCard.tsx';
import { ProductCard } from './ProductCard';

interface ProductListProps {
id: string;
Expand All @@ -24,11 +24,13 @@ export const ProductsList = observer(

const serviceLineItems =
ids
?.filter(
(id) =>
(store.contractLineItems?.value.get(id) as ContractLineItemStore)
?.value.closed === false,
)
?.filter((id) => {
const sli = store.contractLineItems?.value.get(
id,
) as ContractLineItemStore;

return sli?.value.closed === false;
})
?.map(
(id) =>
(store.contractLineItems?.value.get(id) as ContractLineItemStore)
Expand Down Expand Up @@ -71,21 +73,17 @@ export const ProductsList = observer(
}
});

const sortedGroups = Object.values(grouped).map((group) =>
return Object.values(grouped).map((group) =>
group.sort(
(a, b) =>
new Date(a?.serviceStarted).getTime() -
new Date(b?.serviceStarted).getTime(),
),
);

return sortedGroups;
};

return {
subscription: getGroupedServices(subscription).filter((group) =>
group.some((service) => service?.serviceEnded === null),
),
subscription: getGroupedServices(subscription),
once: getGroupedServices(once),
};
};
Expand Down

0 comments on commit b0d91b9

Please sign in to comment.