Skip to content

Commit

Permalink
mock context link urls (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
andnorda authored Jul 10, 2024
1 parent 9cae573 commit c9f7e47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
13 changes: 1 addition & 12 deletions packages/client/src/views/context-link.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { tryParse } from "decorator-shared/json";
import { Context } from "decorator-shared/params";
import { erNavDekoratoren } from "decorator-shared/urls";
import { amplitudeEvent } from "../analytics/amplitude";
import { type AnalyticsEventArgs } from "../analytics/constants";
import { defineCustomElement } from "../custom-elements";
import { CustomLinkElement } from "../helpers/custom-link-element";
import { updateDecoratorParams } from "../params";
import headerClasses from "../styles/header.module.css";

class ContextLink extends CustomLinkElement {
handleClick = (e: MouseEvent) => {
if (erNavDekoratoren(window.location.href)) {
e.preventDefault();
}

handleClick = () => {
const rawEventArgs = this.getAttribute("data-analytics-event-args");
const eventArgs = tryParse<AnalyticsEventArgs, null>(
rawEventArgs,
null,
);

updateDecoratorParams({
context: this.getAttribute("data-context") as Context,
});

if (eventArgs) {
const payload = {
context: window.__DECORATOR_DATA__.params.context,
Expand Down
15 changes: 12 additions & 3 deletions packages/server/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ export const makeContextLinks = (language: Language): ContextLink[] =>
isNorwegian(language)
? [
{
url: `${env.XP_BASE_URL}`,
url:
env.ENV === "prod"
? `${env.XP_BASE_URL}`
: "?context=privatperson",
lenkeTekstId: "rolle_privatperson",
context: "privatperson",
},
{
url: `${env.XP_BASE_URL}/no/bedrift`,
url:
env.ENV === "prod"
? `${env.XP_BASE_URL}/no/bedrift`
: "?context=arbeidsgiver",
lenkeTekstId: "rolle_arbeidsgiver",
context: "arbeidsgiver",
},
{
url: `${env.XP_BASE_URL}/no/samarbeidspartner`,
url:
env.ENV === "prod"
? `${env.XP_BASE_URL}/no/samarbeidspartner`
: "?context=samarbeidspartner",
lenkeTekstId: "rolle_samarbeidspartner",
context: "samarbeidspartner",
},
Expand Down

0 comments on commit c9f7e47

Please sign in to comment.