From 1d2b58b281fa20e2855e40e0123a43a52e4f3ca4 Mon Sep 17 00:00:00 2001 From: Gen Tamura Date: Tue, 17 Dec 2024 16:08:56 +0900 Subject: [PATCH] Fix build error --- app/(main)/settings/team/actions.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/(main)/settings/team/actions.ts b/app/(main)/settings/team/actions.ts index b23724d8..d3f34452 100644 --- a/app/(main)/settings/team/actions.ts +++ b/app/(main)/settings/team/actions.ts @@ -450,11 +450,19 @@ export async function getAgentActivities({ .orderBy(desc(agentActivities.startedAt)) .limit(limit); - const formattedActivities = activities.map((activity) => ({ - ...activity, - // Convert milliseconds to seconds and round to 2 decimal places - usedCharge: Math.ceil((activity.usedCharge / 1000) * 100) / 100, - })); + const formattedActivities = activities.map((activity) => { + const durationInSeconds = Number(activity.usedCharge) / 1000; + + const validDuration = Number.isNaN(durationInSeconds) + ? 0 + : durationInSeconds; + + return { + ...activity, + // Convert milliseconds to seconds and round to 2 decimal places + usedCharge: Math.ceil(validDuration * 100) / 100, + }; + }); return { success: true,