Update application structure (#224)

Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
GermeyandAceDataCloud authored and GitHub committed 2025-07-19 12:08:26 +08:00
1 parent d49b7e6f6c
commit 9ae4229256
135 files changed
+2849 -2324

No files matched your search

+7 -1
View File
@@ -49,15 +49,21 @@ export function getFinalApplication(
applications: IApplication[],
currentApplication?: IApplication
): IApplication | undefined {
if (currentApplication && isApplicationUsable(currentApplication)) {
if (
currentApplication &&
isApplicationUsable(currentApplication) &&
applications?.some((app) => app.id === currentApplication.id)
) {
console.debug('current application is usable', currentApplication);
return currentApplication;
}
console.debug('get final application from applications', applications);
// check if there is any application with 'Period' type firstly, if yes, use it
const application = applications?.find((application) => application?.type === IApplicationType.PERIOD);
console.debug('application with Period type', application);
// else use the application with 'Usage' type
const application2 = applications?.find((application) => application?.type === IApplicationType.USAGE);
console.debug('application with Usage type', application2);
const finalApplication = application && isApplicationUsable(application) ? application : application2;
console.debug('final application', finalApplication);
return finalApplication;