diff --git a/src/components/PlanInfo.tsx b/src/components/PlanInfo.tsx index 0f29571..c33d0ca 100644 --- a/src/components/PlanInfo.tsx +++ b/src/components/PlanInfo.tsx @@ -5,7 +5,12 @@ export default function PlanInfo({ parsedData }: { parsedData: PublicNoteData }) return null } - const extraList = parsedData.planDataMod.extra.split(",").length > 1 ? parsedData.planDataMod.extra.split(",") : parsedData.planDataMod.extra.split(",")[0] === "" ? [] : [parsedData.planDataMod.extra] + const extraList = + parsedData.planDataMod.extra.split(",").length > 1 + ? parsedData.planDataMod.extra.split(",") + : parsedData.planDataMod.extra.split(",")[0] === "" + ? [] + : [parsedData.planDataMod.extra] return (
@@ -51,26 +56,26 @@ export default function PlanInfo({ parsedData }: { parsedData: PublicNoteData }) "text-[9px] bg-blue-600 text-blue-200 dark:bg-blue-800 dark:text-blue-300 w-fit rounded-[5px] px-[3px] py-[1.5px]", )} > - {parsedData.planDataMod.networkRoute.split(",").map((route,index) => { - return route + (index === parsedData.planDataMod!.networkRoute.split(",").length - 1 ? "" : "|") + {parsedData.planDataMod.networkRoute.split(",").map((route, index) => { + return ( + route + + (index === parsedData.planDataMod!.networkRoute.split(",").length - 1 ? "" : "|") + ) })}

)} - { - extraList.map((extra, index) => { - return ( -

- {extra} -

- ) - }) - } - + {extraList.map((extra, index) => { + return ( +

+ {extra} +

+ ) + })}
) } diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 3777f5b..81743ce 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -109,21 +109,24 @@ export function getDaysBetweenDatesWithAutoRenewal({ } } + if (nowTime < endTime) { + return { + days: getDaysBetweenDates(endDate, new Date(nowTime).toISOString()), + cycleLabel: cycleLabel, + remainingPercentage: + getDaysBetweenDates(endDate, new Date(nowTime).toISOString()) / + (30 * months) > + 1 + ? 1 + : getDaysBetweenDates(endDate, new Date(nowTime).toISOString()) / + (30 * months), + } + } + const nextTime = getNextCycleTime(endTime, months, nowTime) const diff = dayjs(nextTime).diff(dayjs(), "day") + 1 const remainingPercentage = diff / (30 * months) > 1 ? 1 : diff / (30 * months) - console.log( - "nextTime", - nextTime, - "diff", - diff, - "month", - months, - "remainingPercentage", - remainingPercentage, - ) - return { days: diff, cycleLabel: cycleLabel,