diff --git a/.circleci/config.yml b/.circleci/config.yml index b6b24da..1fa563f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,7 +74,7 @@ workflows: branches: only: - dev - - feat/onboarding-app + - feat/regsource # Production builds are exectuted only on tagged commits to the # master branch. diff --git a/src/constants/index.js b/src/constants/index.js index fc846e0..502c2e7 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -48,3 +48,8 @@ export const PLATFORM_DOMAIN = process.env.APPENV === "local" ? window.location.origin : config.URL.PLATFORM_DOMAIN; + +export const PATH_REG_SOURCE_MAP = [ + { path: "/earn/gigs", regSource: "gigs" }, + { path: "/earn/find/challenges", regSource: "challenges" }, +]; diff --git a/src/utils/index.js b/src/utils/index.js index 1e7ebf1..ca020a9 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,6 +1,7 @@ import _ from "lodash"; import moment from "moment"; import config from "../../config"; +import { PATH_REG_SOURCE_MAP } from "../constants"; /** * Generate Logout URL @@ -13,10 +14,19 @@ export const getLogoutUrl = () => /** * Generate Login URL */ -export const getLoginUrl = () => - `${config.URL.AUTH}?retUrl=${encodeURIComponent( +export const getLoginUrl = () => { + let regSource = null; + const pathname = window.location.pathname; + for (const { path, regSource: source } of PATH_REG_SOURCE_MAP) { + if (pathname.indexOf(path) != -1) { + regSource = source; + } + } + + return `${config.URL.AUTH}?retUrl=${encodeURIComponent( window.location.href.match(/[^?]*/)[0] - )}`; + )}${regSource != null ? "®Source=" + regSource : ""}`; +}; /** * Generate Business Login URL