512 lines
14 KiB
TypeScript
512 lines
14 KiB
TypeScript
import DefaultDarkLogo from "../assets/whitelabels/darkLogo.png";
|
|
import DefaultLightLogo from "../assets/whitelabels/lightLogo.png";
|
|
import AdapativeAgLogo from "../assets/whitelabels/AdaptiveAgriculture/logo.png";
|
|
import AdaptiveAgThumbnail from "../assets/whitelabels/AdaptiveAgriculture/thumbnail.jpg";
|
|
import AdConLogo from "../assets/whitelabels/AdaptiveConstruction/AdConLogoWhite.png";
|
|
import BXTLightLogo from "../assets/whitelabels/BXT/lightLogo.png";
|
|
import BXTDarkLogo from "../assets/whitelabels/BXT/darkLogo.png";
|
|
import AeroGrowDarkLogo from "../assets/whitelabels/AeroGrow/darkLogo.png";
|
|
import AeroGrowLightLogo from "../assets/whitelabels/AeroGrow/lightLogo.png";
|
|
import MiVentLightLogo from "../assets/whitelabels/MiVent/lightLogo.png";
|
|
import MiPCALogo from "../assets/whitelabels/MiPCA/MiPCALogo.png";
|
|
import StreamlineLogo from "../assets/whitelabels/Streamline/stream-logo.png"
|
|
import IntellifarmsLogo from "../assets/whitelabels/Intellifarms/IFND-2023-Logo.png"
|
|
import IntellifarmsLogoWhite from "../assets/whitelabels/Intellifarms/IFND-2023-Logo-White.png"
|
|
|
|
const protips: string[] = [
|
|
"You can see the latest measurements for a device by starring its components!",
|
|
"You can search for devices based on keywords in their name, description, and many other settings!",
|
|
"You can quickly change the set points for an interaction with the sliders on a component card!",
|
|
"Make sure your devices have the newest features and improvements by enabling automatic upgrades!",
|
|
"Make sure your devices don't miss a measurement by ensuring they have a strong network connection! You can monitor this with the modem component!",
|
|
"Starring your components will show you the latest measurement in all sorts of places so you can keep a close eye on what you care about!",
|
|
"Want to share what your device is doing with friends or family? Create a shareable link and send it to them!",
|
|
"Keep an eye on your data usage! Only set components to report as often as you need.",
|
|
"Changes pending? Make sure your device is checking in every 10 minutes or so.",
|
|
"Our development team is fully remote capable, so you can be sure we're working hard even during a pandemic.",
|
|
"Our devices are proudly designed and assembled in Canada.",
|
|
"Want to receive text messages about your devices? Update your phone number and enable SMS notifications!"
|
|
];
|
|
|
|
export interface WhiteLabelFeatures {
|
|
bins: boolean;
|
|
visualFarm: boolean;
|
|
contracts: boolean;
|
|
transactions: boolean;
|
|
fields: boolean;
|
|
grainTypes: boolean;
|
|
grainUnit: boolean;
|
|
marketplace: boolean;
|
|
cableEstimator: boolean;
|
|
ventilation: boolean;
|
|
mines: boolean;
|
|
constructionMap: boolean;
|
|
jobsites: boolean;
|
|
heaters: boolean;
|
|
aviationMap: boolean;
|
|
terminals: boolean;
|
|
security: boolean;
|
|
}
|
|
|
|
interface WhiteLabel {
|
|
slug: string;
|
|
name: string;
|
|
primaryColour: any;
|
|
secondaryColour: any;
|
|
signatureColour: any;
|
|
signatureAccentColour: any;
|
|
auth0ClientId: string;
|
|
redirectOnLogout: boolean;
|
|
logoutRedirectTarget: string;
|
|
darkLogo: any;
|
|
lightLogo: any;
|
|
transparentLogoBG: boolean;
|
|
blacklist: string[];
|
|
features: WhiteLabelFeatures;
|
|
hotjarID?: string;
|
|
docs: string;
|
|
protips: string[];
|
|
tutorialPlaylistID?: string;
|
|
thumbnail?: string;
|
|
tutorialFiles?: { name: string; url: string }[];
|
|
homePage: string;
|
|
}
|
|
|
|
const AG_FEATURES: WhiteLabelFeatures = {
|
|
bins: true,
|
|
visualFarm: true,
|
|
contracts: true,
|
|
transactions: true,
|
|
fields: true,
|
|
grainTypes: true,
|
|
grainUnit: true,
|
|
marketplace: true,
|
|
cableEstimator: true,
|
|
ventilation: false,
|
|
mines: false,
|
|
constructionMap: false,
|
|
jobsites: false,
|
|
heaters: false,
|
|
aviationMap: false,
|
|
terminals: false,
|
|
security: false,
|
|
};
|
|
|
|
const CONSTRUCTION_FEATURES: WhiteLabelFeatures = {
|
|
bins: false,
|
|
visualFarm: false,
|
|
contracts: false,
|
|
transactions: false,
|
|
fields: false,
|
|
grainTypes: false,
|
|
grainUnit: false,
|
|
marketplace: false,
|
|
cableEstimator: false,
|
|
ventilation: false,
|
|
mines: false,
|
|
constructionMap: true,
|
|
jobsites: true,
|
|
heaters: true,
|
|
aviationMap: false,
|
|
terminals: false,
|
|
security: false,
|
|
};
|
|
|
|
const AVIATION_FEATURES: WhiteLabelFeatures = {
|
|
bins: false,
|
|
visualFarm: false,
|
|
contracts: false,
|
|
transactions: false,
|
|
fields: false,
|
|
grainTypes: false,
|
|
grainUnit: false,
|
|
marketplace: false,
|
|
cableEstimator: false,
|
|
ventilation: false,
|
|
mines: false,
|
|
constructionMap: false,
|
|
jobsites: false,
|
|
heaters: false,
|
|
aviationMap: true,
|
|
terminals: true,
|
|
security: false,
|
|
};
|
|
|
|
const MIVENT_FEATURES: WhiteLabelFeatures = {
|
|
bins: false,
|
|
visualFarm: false,
|
|
contracts: false,
|
|
transactions: false,
|
|
fields: false,
|
|
grainTypes: false,
|
|
grainUnit: false,
|
|
marketplace: false,
|
|
cableEstimator: false,
|
|
ventilation: true,
|
|
mines: true,
|
|
constructionMap: false,
|
|
jobsites: false,
|
|
heaters: false,
|
|
aviationMap: false,
|
|
terminals: false,
|
|
security: false,
|
|
};
|
|
|
|
const BASE_FEATURES: WhiteLabelFeatures = {
|
|
bins: false,
|
|
visualFarm: false,
|
|
contracts: false,
|
|
transactions: false,
|
|
fields: false,
|
|
grainTypes: false,
|
|
grainUnit: false,
|
|
marketplace: false,
|
|
cableEstimator: false,
|
|
ventilation: false,
|
|
mines: false,
|
|
constructionMap: false,
|
|
jobsites: false,
|
|
heaters: false,
|
|
aviationMap: false,
|
|
terminals: false,
|
|
security: false,
|
|
};
|
|
|
|
const registry: Record<string, WhiteLabel> = {
|
|
"bxt": {
|
|
slug: "bxt",
|
|
name: "Brand X Technologies",
|
|
primaryColour: "blue",
|
|
secondaryColour: "yellow",
|
|
signatureColour: "#005bb0",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_DEV_CLIENT_ID,
|
|
|
|
redirectOnLogout: false,
|
|
logoutRedirectTarget: "",
|
|
darkLogo: BXTDarkLogo,
|
|
lightLogo: BXTLightLogo,
|
|
transparentLogoBG: false,
|
|
blacklist: [],
|
|
features: { ...BASE_FEATURES, security: true },
|
|
hotjarID: import.meta.env.REACT_APP_HOTJAR_ID_BXT,
|
|
docs: "Platform",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
"staging": {
|
|
slug: "staging",
|
|
name: "Staging",
|
|
primaryColour: import.meta.env.VITE_APP_PRIMARY_COLOUR,
|
|
secondaryColour: import.meta.env.VITE_APP_SECONDARY_COLOUR,
|
|
signatureColour: import.meta.env.VITE_APP_SIGNATURE_COLOUR,
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_STAGING_CLIENT_ID,
|
|
|
|
redirectOnLogout: false,
|
|
logoutRedirectTarget: "",
|
|
darkLogo: DefaultDarkLogo,
|
|
lightLogo: DefaultLightLogo,
|
|
transparentLogoBG: false,
|
|
blacklist: [],
|
|
features: AG_FEATURES,
|
|
hotjarID: import.meta.env.REACT_APP_HOTJAR_ID_BXT,
|
|
docs: "Platform",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
"adaptive-ag": {
|
|
slug: "adaptive-ag",
|
|
name: "Adaptive Agriculture",
|
|
primaryColour: "green",
|
|
secondaryColour: "yellow",
|
|
signatureColour: "#272727",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_ADAPTIVE_AGRICULTURE_CLIENT_ID,
|
|
|
|
redirectOnLogout: true,
|
|
logoutRedirectTarget: "https://adaptiveagriculture.ca",
|
|
darkLogo: AdapativeAgLogo,
|
|
lightLogo: AdapativeAgLogo,
|
|
transparentLogoBG: true,
|
|
blacklist: ["cost"],
|
|
features: AG_FEATURES,
|
|
hotjarID: import.meta.env.REACT_APP_HOTJAR_ID_ADAPTIVE_AGRICULTURE,
|
|
docs: "AdaptiveAg",
|
|
protips: protips,
|
|
tutorialPlaylistID: "PLpLmJnI66Jfl5FXME31ckGam-sD8gB1s2",
|
|
thumbnail: AdaptiveAgThumbnail,
|
|
tutorialFiles: [
|
|
{
|
|
name: "Bindapt+",
|
|
url: "https://adaptiveagriculture.ca/wp-content/uploads/2023/08/Bindapt-Set-Up-Guide.pdf"
|
|
},
|
|
{
|
|
name: "Adapter Plate",
|
|
url: "https://adaptiveagriculture.ca/wp-content/uploads/2023/08/Bindapt-Adapter-Plate-Set-Up-Guide.pdf"
|
|
}
|
|
],
|
|
homePage: "/bins",
|
|
},
|
|
"intellifarms": {
|
|
slug: "intellifarms",
|
|
name: "Intellifarms",
|
|
primaryColour: "#9E1B32",
|
|
secondaryColour: "#4A4F55",
|
|
signatureColour: "#272727",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_INTELLIFARMS_CLIENT_ID,
|
|
|
|
redirectOnLogout: true,
|
|
logoutRedirectTarget: "https://myintellifarms.com",
|
|
darkLogo: IntellifarmsLogo,
|
|
lightLogo: IntellifarmsLogoWhite,
|
|
transparentLogoBG: true,
|
|
blacklist: [],
|
|
features: AG_FEATURES,
|
|
docs: "Platform",
|
|
protips: protips,
|
|
homePage: "/bins",
|
|
},
|
|
"streamline": {
|
|
slug: "streamline",
|
|
name: "Streamline",
|
|
primaryColour: "#FFFF",
|
|
secondaryColour: "yellow",
|
|
signatureColour: "#005bb0",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_STREAMLINE_CLIENT_ID,
|
|
|
|
redirectOnLogout: false,
|
|
logoutRedirectTarget: "",
|
|
darkLogo: StreamlineLogo,
|
|
lightLogo: StreamlineLogo,
|
|
transparentLogoBG: false,
|
|
blacklist: [],
|
|
features: AG_FEATURES,
|
|
docs: "Platform",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
"aerogrow": {
|
|
slug: "aerogrow",
|
|
name: "AeroGrow",
|
|
primaryColour: "green",
|
|
secondaryColour: "cyan",
|
|
signatureColour: "#fff",
|
|
signatureAccentColour: "#000",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_AEROGROW_CLIENT_ID,
|
|
|
|
redirectOnLogout: true,
|
|
logoutRedirectTarget: "https://www.aerogrowmanufacturing.com",
|
|
darkLogo: AeroGrowDarkLogo,
|
|
lightLogo: AeroGrowLightLogo,
|
|
transparentLogoBG: true,
|
|
blacklist: [],
|
|
features: BASE_FEATURES,
|
|
hotjarID: import.meta.env.REACT_APP_HOTJAR_ID_AEROGROW,
|
|
docs: "Platform",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
"mivent": {
|
|
slug: "mivent",
|
|
name: "MiVent",
|
|
primaryColour: "green",
|
|
secondaryColour: "yellow",
|
|
signatureColour: "#272727",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_MIVENT_CLIENT_ID,
|
|
|
|
redirectOnLogout: true,
|
|
logoutRedirectTarget: "https://mivent.ca",
|
|
darkLogo: MiVentLightLogo,
|
|
lightLogo: MiVentLightLogo,
|
|
transparentLogoBG: true,
|
|
blacklist: ["cost"],
|
|
features: MIVENT_FEATURES,
|
|
hotjarID: import.meta.env.REACT_APP_HOTJAR_ID_MIVENT,
|
|
docs: "Platform",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
"adaptive-construction": {
|
|
slug: "adaptive-construction",
|
|
name: "Adaptive Construction",
|
|
primaryColour: "blue",
|
|
secondaryColour: "blue",
|
|
signatureColour: "#272727",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_ADAPTIVE_CONSTRUCTION_CLIENT_ID,
|
|
|
|
redirectOnLogout: true,
|
|
logoutRedirectTarget: "https://adaptiveconstruction.ca",
|
|
darkLogo: AdConLogo,
|
|
lightLogo: AdConLogo,
|
|
transparentLogoBG: true,
|
|
blacklist: ["cost"],
|
|
features: CONSTRUCTION_FEATURES,
|
|
hotjarID: import.meta.env.REACT_APP_HOTJAR_ID_ADAPTIVE_CONSTRUCTION,
|
|
docs: "AdaptiveConstruction",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
"omniair": {
|
|
slug: "omniair",
|
|
name: "OmniAir",
|
|
primaryColour: "#004f9b",
|
|
secondaryColour: "yellow",
|
|
signatureColour: "#272727",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_OMNIAIR_CLIENT_ID,
|
|
|
|
redirectOnLogout: true,
|
|
logoutRedirectTarget: "https://omniairsystems.com",
|
|
darkLogo: MiPCALogo,
|
|
lightLogo: MiPCALogo,
|
|
transparentLogoBG: true,
|
|
blacklist: ["cost"],
|
|
features: AVIATION_FEATURES,
|
|
docs: "OmniAir",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
"mipca": {
|
|
slug: "mipca",
|
|
name: "MiPCA",
|
|
primaryColour: "#004f9b",
|
|
secondaryColour: "yellow",
|
|
signatureColour: "#272727",
|
|
signatureAccentColour: "#fff",
|
|
auth0ClientId: import.meta.env.VITE_AUTH0_OMNIAIR_CLIENT_ID,
|
|
|
|
redirectOnLogout: true,
|
|
logoutRedirectTarget: "https://mionetech.com",
|
|
darkLogo: MiPCALogo,
|
|
lightLogo: MiPCALogo,
|
|
transparentLogoBG: true,
|
|
blacklist: ["cost"],
|
|
features: AVIATION_FEATURES,
|
|
docs: "MiPCA",
|
|
protips: protips,
|
|
homePage: "/devices",
|
|
},
|
|
};
|
|
|
|
// Ordered most-specific to least-specific
|
|
const DOMAIN_RULES: [RegExp, string][] = [
|
|
[/bxt-dev/, "bxt"],
|
|
[/staging\.brandxtech/, "staging"],
|
|
[/streamline\./, "streamline"],
|
|
[/brandxtech|brandxducks/, "bxt"],
|
|
[/adaptiveagriculture|adaptiveag/, "adaptive-ag"],
|
|
[/adaptiveconstruction/, "adaptive-construction"],
|
|
[/aerogrowmanufacturing/, "aerogrow"],
|
|
[/mivent/, "mivent"],
|
|
[/omniair/, "omniair"],
|
|
[/mionetech|mipca/, "mipca"],
|
|
[/myintellifarms|intellifarms/, "intellifarms"],
|
|
];
|
|
|
|
function resolveSlug(): string {
|
|
const override = import.meta.env.VITE_WHITELABEL;
|
|
if (override && registry[override]) return override;
|
|
|
|
const host = window.location.hostname;
|
|
for (const [pattern, slug] of DOMAIN_RULES) {
|
|
if (pattern.test(host)) return slug;
|
|
}
|
|
return "adaptive-ag";
|
|
}
|
|
|
|
let cached: WhiteLabel | null = null;
|
|
|
|
export function getWhitelabel(): WhiteLabel {
|
|
if (!cached) {
|
|
cached = registry[resolveSlug()];
|
|
}
|
|
return cached;
|
|
}
|
|
|
|
export function getFeatures(): WhiteLabelFeatures {
|
|
return getWhitelabel().features;
|
|
}
|
|
|
|
export function getPrimaryColour(): any {
|
|
return getWhitelabel().primaryColour;
|
|
}
|
|
|
|
export function getSecondaryColour(): any {
|
|
return getWhitelabel().secondaryColour;
|
|
}
|
|
|
|
export function getSignatureColour(): any {
|
|
return getWhitelabel().signatureColour;
|
|
}
|
|
|
|
export function getSignatureAccentColour(): any {
|
|
return getWhitelabel().signatureAccentColour;
|
|
}
|
|
|
|
export function getAuth0ClientId(): string {
|
|
return getWhitelabel().auth0ClientId;
|
|
}
|
|
|
|
export function redirectOnLogout(): boolean {
|
|
return getWhitelabel().redirectOnLogout;
|
|
}
|
|
|
|
export function getLogoutRedirectTarget(): string {
|
|
return getWhitelabel().logoutRedirectTarget;
|
|
}
|
|
|
|
export function getDarkLogo(): any {
|
|
return getWhitelabel().darkLogo;
|
|
}
|
|
|
|
export function getLightLogo(): any {
|
|
return getWhitelabel().lightLogo;
|
|
}
|
|
|
|
export function hideLogo(): boolean {
|
|
return getWhitelabel().name === "";
|
|
}
|
|
|
|
export function hasTransparentLogoBG(): boolean {
|
|
return getWhitelabel().transparentLogoBG;
|
|
}
|
|
|
|
export function getName(): string {
|
|
return getWhitelabel().name;
|
|
}
|
|
|
|
export function isBlacklisted(context: string): boolean {
|
|
return getWhitelabel().blacklist.includes(context);
|
|
}
|
|
|
|
export function getHotjarID(): string | undefined {
|
|
return getWhitelabel().hotjarID;
|
|
}
|
|
|
|
export function hasTutorialPlaylist(): boolean {
|
|
return getWhitelabel().tutorialPlaylistID !== undefined;
|
|
}
|
|
|
|
export function getTutorialPlaylistID(): string {
|
|
const id = getWhitelabel().tutorialPlaylistID;
|
|
return id ? id : "";
|
|
}
|
|
|
|
export function hasThumbnail(): boolean {
|
|
return getWhitelabel().thumbnail !== undefined;
|
|
}
|
|
|
|
export function getThumbnail(): string {
|
|
const thumbnail = getWhitelabel().thumbnail;
|
|
return thumbnail ? thumbnail : "";
|
|
}
|
|
|
|
export function getTutorialFiles() {
|
|
const files = getWhitelabel().tutorialFiles;
|
|
return files ? files : [];
|
|
}
|