Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

feat: add regSource to signup url #73

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -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" },
];
16 changes: 13 additions & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
@@ -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 ? "&regSource=" + regSource : ""}`;
};

/**
* Generate Business Login URL