Skip to content

Commit

Permalink
use dynamic env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll committed Nov 2, 2023
1 parent 505011e commit ff645f2
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions src/lib/utils/product.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import {
PUBLIC_TMAIL_PLAYSTORE_URL,
PUBLIC_TWAKE_PLAYSTORE_URL,
PUBLIC_TMAIL_APPSTORE_URL,
PUBLIC_TWAKE_APPSTORE_URL,
PUBLIC_TDRIVE_MAGIC_LINK,
PUBLIC_TMAIL_MAGIC_LINK,
PUBLIC_TWAKE_MAGIC_LINK,
PUBLIC_TDRIVE_WEB,
PUBLIC_TMAIL_WEB,
PUBLIC_TWAKE_WEB
} from '$env/static/public';
import { env } from '$env/dynamic/public';
import type { ApplicationType, IApplicationStorePayload } from '../../types';
import { isMobile, getPlatform } from './device';

Expand All @@ -27,28 +16,28 @@ export const getApplicationStoreUrl = (
if (platform === 'android' && app === 'tmail') {
return {
type: 'play_store_url',
url: PUBLIC_TMAIL_PLAYSTORE_URL
url: env.PUBLIC_TMAIL_PLAYSTORE_URL
};
}

if (platform === 'android' && app === 'twake') {
return {
type: 'play_store_url',
url: PUBLIC_TWAKE_PLAYSTORE_URL
url: env.PUBLIC_TWAKE_PLAYSTORE_URL
};
}

if (platform === 'ios' && app === 'tmail') {
return {
type: 'app_store_url',
url: PUBLIC_TMAIL_APPSTORE_URL
url: env.PUBLIC_TMAIL_APPSTORE_URL
};
}

if (platform === 'ios' && app === 'twake') {
return {
type: 'app_store_url',
url: PUBLIC_TWAKE_APPSTORE_URL
url: env.PUBLIC_TWAKE_APPSTORE_URL
};
}
}
Expand All @@ -62,15 +51,15 @@ export const getApplicationStoreUrl = (
*/
export const getApplicationDeepLink = (app: ApplicationType): string | undefined => {
if (app === 'tdrive') {
return PUBLIC_TDRIVE_MAGIC_LINK;
return env.PUBLIC_TDRIVE_MAGIC_LINK;
}

if (app === 'tmail') {
return PUBLIC_TMAIL_MAGIC_LINK;
return env.PUBLIC_TMAIL_MAGIC_LINK;
}

if (app === 'twake') {
return PUBLIC_TWAKE_MAGIC_LINK;
return env.PUBLIC_TWAKE_MAGIC_LINK;
}
};

Expand All @@ -82,20 +71,20 @@ export const getApplicationDeepLink = (app: ApplicationType): string | undefined
*/
export const getApplicationGotoLink = (app: ApplicationType): string => {
if (app === 'tdrive') {
return PUBLIC_TDRIVE_WEB;
return env.PUBLIC_TDRIVE_WEB;
}

if (isMobile()) {
if (app === 'tmail') {
return `${PUBLIC_TMAIL_MAGIC_LINK}registered`;
return `${env.PUBLIC_TMAIL_MAGIC_LINK}registered`;
}

return `${PUBLIC_TWAKE_MAGIC_LINK}registered`;
return `${env.PUBLIC_TWAKE_MAGIC_LINK}registered`;
}

if (app === 'tmail') {
return PUBLIC_TMAIL_WEB;
return env.PUBLIC_TMAIL_WEB;
}

return PUBLIC_TWAKE_WEB;
return env.PUBLIC_TWAKE_WEB;
};

0 comments on commit ff645f2

Please sign in to comment.