Skip to content

Commit c4e1ac7

Browse files
committed
feat: update Devtron license DTO to allow nullable fields and improve license status logic
1 parent af03d8c commit c4e1ac7

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

src/Shared/Helpers.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ const getDevtronLicenseStatus = ({
10761076
return LicenseStatus.EXPIRED
10771077
}
10781078

1079-
if (ttl < reminderThreshold) {
1079+
if (ttl < reminderThreshold * 24 * 60 * 60) {
10801080
return LicenseStatus.REMINDER_THRESHOLD_REACHED
10811081
}
10821082

@@ -1087,23 +1087,15 @@ export const parseDevtronLicenseDTOIntoLicenseCardData = <isCentralDashboard ext
10871087
licenseDTO: DevtronLicenseDTO<isCentralDashboard>,
10881088
currentUserEmail?: isCentralDashboard extends true ? string : never,
10891089
): DevtronLicenseCardProps => {
1090-
const {
1091-
isTrial,
1092-
expiry,
1093-
ttl,
1094-
reminderThreshold,
1095-
organisationMetadata,
1096-
license,
1097-
licenseSuffix,
1098-
claimedByUserDetails,
1099-
} = licenseDTO || {}
1090+
const { isTrial, expiry, ttl, reminderThreshold, organisationMetadata, license, claimedByUserDetails } =
1091+
licenseDTO || {}
11001092

11011093
return {
11021094
enterpriseName: organisationMetadata?.name || '',
11031095
expiryDate: expiry ? moment(expiry).format(DATE_TIME_FORMATS['DD/MM/YYYY']) : '',
11041096
ttl,
11051097
licenseStatus: getDevtronLicenseStatus({ ttl, reminderThreshold }),
11061098
isTrial,
1107-
...(currentUserEmail === claimedByUserDetails?.email ? { licenseKey: license } : { licenseSuffix }),
1099+
...(currentUserEmail === claimedByUserDetails?.email ? { licenseKey: license } : { licenseSuffix: license }),
11081100
}
11091101
}

src/Shared/types.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,25 +1033,26 @@ export interface AppEnvIdType {
10331033
}
10341034

10351035
export interface DevtronLicenseBaseDTO {
1036-
fingerprint: string
1037-
isTrial: boolean
1036+
fingerprint: string | null
1037+
isTrial: boolean | null
10381038
/**
10391039
* In timestamp format
10401040
*/
1041-
expiry: string
1041+
expiry: string | null
10421042
/**
10431043
* Can be negative, depicts time left in seconds for license to expire
10441044
*/
1045-
ttl: number
1045+
ttl: number | null
10461046
/**
10471047
* Show a reminder after these many DAYS left for license to expire, i.e,
10481048
* Show if `ttl` is less than `reminderThreshold` [converted to seconds]
10491049
*/
1050-
reminderThreshold: number
1050+
reminderThreshold: number | null
10511051
organisationMetadata: {
1052-
name: string
1053-
domain: string
1054-
}
1052+
name: string | null
1053+
domain: string | null
1054+
} | null
1055+
license: string | null
10551056
}
10561057

10571058
export type DevtronLicenseDTO<isCentralDashboard extends boolean = false> = DevtronLicenseBaseDTO &
@@ -1061,12 +1062,8 @@ export type DevtronLicenseDTO<isCentralDashboard extends boolean = false> = Devt
10611062
firstName: string
10621063
lastName: string
10631064
email: string
1064-
}
1065-
license: string
1066-
licenseSuffix?: never
1065+
} | null
10671066
}
10681067
: {
10691068
claimedByUserDetails?: never
1070-
license?: never
1071-
licenseSuffix: string
10721069
})

0 commit comments

Comments
 (0)