Skip to content

Commit

Permalink
refactor: minor updates
Browse files Browse the repository at this point in the history
- updates param names and documentation for `getCurrencySymbolByCode`
- moves ConfigType to tenant.config and renames tenant.config as a .ts file
- adds type for `setViewPort` in `zoomToPlantLocation`
- removes {} as a possible type for the `project` prop in `ManageProjects`
  • Loading branch information
mohitb35 committed Jul 4, 2023
1 parent 633826d commit 463351e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/features/user/ManageProjects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { handleError, APIError, ProjectExtended } from '@planet-sdk/common';
interface Props {
GUID?: string | null;
token: string | null;
project?: ProjectExtended | {};
project?: ProjectExtended;
}

export default function ManageProjects({ GUID, token, project }: Props) {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/countryCurrency/getCurrencySymbolByCode.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Retrieves the currency symbol for a given number.
* Retrieves the appropriate currency symbol for a given currency and amount.
* @param {string} langCode - The language code.
* @param {string} currency - The currency code.
* @param {number} number - The number used to determine the currency symbol.
* @param {amount} number - The amount/value in the specified currency
*/

export default function getCurrencySymbolByCode(
langCode: string,
currency: string,
number: number
amount: number
) {
const options = {
// These options are needed to round to whole numbers if that's what you want.
Expand All @@ -18,7 +18,7 @@ export default function getCurrencySymbolByCode(
};
const formatter = new Intl.NumberFormat(langCode, options);
const currencySymbol = formatter
.formatToParts(number)
.formatToParts(amount)
.filter((part) => part.type == 'currency');

return Array.isArray(currencySymbol) && currencySymbol.length > 0
Expand Down
49 changes: 1 addition & 48 deletions src/utils/countryCurrency/getStoredCurrency.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,6 @@
import tenantConfig from '../../../tenant.config';

interface ConfigType {
tenantName: string;
tenantURL: string;
languages: string[];
fallbackCurrency?: string;
tenantGoal?: number | null;
showUNDecadeLogo?: boolean;
font: {
primaryFontFamily: string;
secondaryFontFamily: string;
primaryFontURL?: string;
secondaryFontURL?: string;
};
header: {
isSecondaryTenant: boolean;
tenantLogoURL: string;
mobileLogoURL?: string;
tenantLogoLink: string;
items: {
[key: string]: {
title: string;
loggedInTitle?: string;
onclick: string;
visible: boolean;
subMenu?: {
title: string;
onclick: string;
visible: boolean;
}[];
};
};
};
meta: {
title: string;
appTitle?: string;
description: string;
image: string;
twitterHandle: string;
locale: string;
};
footerLinks: string[];
manifest?: string;
home?: {
image: string;
};
}

const config: ConfigType = tenantConfig();
const config = tenantConfig();

export default function getStoredCurrency() {
let currencyCode;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/maps/plantLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function zoomToPlantLocation(
coordinates: turf.Position[],
viewport: ViewPort,
isMobile: boolean,
setViewPort: Function,
setViewPort: SetState<ViewPort>,
duration = 1200
) {
if (viewport.width && viewport.height) {
Expand Down
49 changes: 48 additions & 1 deletion tenant.config.js → tenant.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,54 @@ import sitex from './public/tenants/sitex/config';
import T3pleset from './public/tenants/3pleset/config';
import weareams from './public/tenants/weareams/config';

export default function tenantConfig() {
interface ConfigType {
tenantName: string;
tenantURL: string;
languages: string[];
fallbackCurrency?: string;
tenantGoal?: number | null;
showUNDecadeLogo?: boolean;
font: {
primaryFontFamily: string;
secondaryFontFamily: string;
primaryFontURL?: string;
secondaryFontURL?: string;
};
header: {
isSecondaryTenant: boolean;
tenantLogoURL: string;
mobileLogoURL?: string;
tenantLogoLink: string;
items: {
[key: string]: {
title: string;
loggedInTitle?: string;
onclick: string;
visible: boolean;
subMenu?: {
title: string;
onclick: string;
visible: boolean;
}[];
};
};
};
meta: {
title: string;
appTitle?: string;
description: string;
image: string;
twitterHandle: string;
locale: string;
};
footerLinks: string[];
manifest?: string;
home?: {
image: string;
};
}

export default function tenantConfig(): ConfigType {
switch (process.env.TENANT) {
case 'planet':
return planetConfig;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"**/*.ts",
"**/*.tsx",
"./src/**/*",
"tenant.config.js",
"tenant.config.ts",
"public/assets"
]
}

0 comments on commit 463351e

Please sign in to comment.