Skip to content

Commit

Permalink
fix(ui): Fix the date issue on Create Access token Modal (datahub-pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankit-Keshari-Vituity authored and cccs-tom committed Nov 18, 2022
1 parent c1a49c0 commit e440ef0
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions datahub-web-react/src/app/settings/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,16 @@ const addDays = (days: number) => {
return `The token will expire on ${result.toLocaleDateString()} at ${result.toLocaleTimeString()}.`;
};

const addMonths = (month: number) => {
const result = new Date();
result.setMonth(result.getMonth() + month);
return `The token will expire on ${result.toLocaleDateString()} at ${result.toLocaleTimeString()}.`;
};

export const getTokenExpireDate = (duration: AccessTokenDuration) => {
switch (duration) {
case AccessTokenDuration.OneHour:
return addHours(1);
case AccessTokenDuration.OneDay:
return addDays(1);
case AccessTokenDuration.OneMonth:
return addMonths(1);
return addDays(30);
case AccessTokenDuration.ThreeMonths:
return addMonths(3);
return addDays(90);
case AccessTokenDuration.NoExpiry:
return 'This token will never expire.';
default:
Expand Down

0 comments on commit e440ef0

Please sign in to comment.