Skip to content

Commit

Permalink
Remove intermediate date conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Feb 5, 2025
1 parent 51a2c26 commit 9c53176
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function parseInventoryGroup(group: IGroup) {
if (!dateString) return;
const sampleDate = new Date(dateString);
if (isNaN(sampleDate.getTime())) return;
return sampleDate.toLocaleDateString();
return sampleDate;
};

// invariant one member representing the product
Expand Down Expand Up @@ -171,14 +171,11 @@ function matchesSearch(obj: TableData, search: string) {
* @param obj - obj to filter
*/
function activeInventoryByAccEndDate(obj: TableData) {
if (obj.accountabilityEndDate === undefined) {
const endDate = obj.accountabilityEndDate;
if (endDate === undefined) {
return true;
}
const currentAccEndDate = Date.parse(obj.accountabilityEndDate);
if (!isNaN(currentAccEndDate)) {
return currentAccEndDate >= Date.now();
}
return false;
return endDate.getTime() >= Date.now();
}

export const InventoryView = ({ fhirBaseUrl, locationId }: InventoryViewProps) => {
Expand Down Expand Up @@ -253,11 +250,17 @@ export const InventoryView = ({ fhirBaseUrl, locationId }: InventoryViewProps) =
title: t('Delivery dt.'),
dataIndex: 'deliveryDate' as const,
key: 'deliveryDate' as const,
render: (val?: Date) => {
return val?.toLocaleDateString();
},
},
{
title: t('Acct. end dt.'),
dataIndex: 'accountabilityEndDate' as const,
key: 'accountabilityEndDate' as const,
render: (val?: Date) => {
return val?.toLocaleDateString();
},
},
{
title: t('Unicef section'),
Expand Down

0 comments on commit 9c53176

Please sign in to comment.