feat: finalize TrialOverAlert on billing page

This commit is contained in:
Ali BARIN
2023-04-09 12:07:31 +00:00
parent dc734b04d8
commit 2739d2297f
5 changed files with 50 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ import useFormatMessage from './useFormatMessage';
type UseTrialStatusReturn = {
expireAt: DateTime;
message: string;
over: boolean;
status: 'error' | 'warning';
} | null;
@@ -25,11 +26,13 @@ function getFeedbackPayload(date: DateTime) {
return {
translationEntryId: 'trialBadge.over',
status: 'error' as const,
over: true,
};
} else if (diffInDays <= 0) {
return {
translationEntryId: 'trialBadge.endsToday',
status: 'warning' as const,
over: false,
}
} else {
return {
@@ -38,6 +41,7 @@ function getFeedbackPayload(date: DateTime) {
remainingDays: diffInDays
},
status: 'warning' as const,
over: false,
}
}
}
@@ -54,11 +58,13 @@ export default function useTrialStatus(): UseTrialStatusReturn {
translationEntryId,
translationEntryValues,
status,
over,
} = getFeedbackPayload(expireAt);
return {
message: formatMessage(translationEntryId, translationEntryValues),
expireAt,
over,
status
};
}