fix(useBillingAndUsageData): fix invalid date
This commit is contained in:
@@ -7,7 +7,8 @@ import { GET_BILLING_AND_USAGE } from 'graphql/queries/get-billing-and-usage.ee'
|
||||
function transform(billingAndUsageData: NonNullable<UseBillingAndUsageDataReturn>) {
|
||||
const nextBillDate = billingAndUsageData.subscription.nextBillDate;
|
||||
const nextBillDateTitle = nextBillDate.title;
|
||||
const relativeNextBillDateTitle = nextBillDateTitle ? DateTime.fromMillis(Number(nextBillDateTitle)).toFormat('LLL dd, yyyy') as string : '';
|
||||
const nextBillDateTitleDateObject = DateTime.fromMillis(Number(nextBillDateTitle));
|
||||
const formattedNextBillDateTitle = nextBillDateTitleDateObject.isValid ? nextBillDateTitleDateObject.toFormat('LLL dd, yyyy') : nextBillDateTitle;
|
||||
|
||||
return {
|
||||
...billingAndUsageData,
|
||||
@@ -15,7 +16,7 @@ function transform(billingAndUsageData: NonNullable<UseBillingAndUsageDataReturn
|
||||
...billingAndUsageData.subscription,
|
||||
nextBillDate: {
|
||||
...billingAndUsageData.subscription.nextBillDate,
|
||||
title: relativeNextBillDateTitle,
|
||||
title: formattedNextBillDateTitle,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user