diff --git a/.env.development b/.env.development index 71abb0d8..4ff41f4d 100644 --- a/.env.development +++ b/.env.development @@ -2,6 +2,7 @@ NEXT_PUBLIC_API_MOCKING=enabled SERVERSIDE_LOGIN=disabled NEXT_PUBLIC_TELEMETRY_URL=http://localhost:12347/collect +NEXT_PUBLIC_SANITY_DATASET=development INNSYN_API=https://dp-innsyn.intern.dev.nav.no IDPORTEN_REDIRECT_URI=http://localhost:3000/api/auth/callback @@ -12,3 +13,5 @@ AMPLITUDE_API_KEY= SOKNADSDIALOG_URL=https://arbeid.intern.dev.nav.no/dagpenger/dialog NEXT_PUBLIC_LOCALHOST=true + +APP_ENV=localhost \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yaml b/.github/workflows/dependabot-auto-merge.yaml index 3d732c5f..128daf8a 100644 --- a/.github/workflows/dependabot-auto-merge.yaml +++ b/.github/workflows/dependabot-auto-merge.yaml @@ -8,7 +8,7 @@ permissions: jobs: dependabot: runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} + if: github.event.pull_request.user.login == 'dependabot[bot]' steps: - name: Dependabot metadata id: metadata diff --git a/.nais/nais.yaml b/.nais/nais.yaml index 61fa6d64..ae92ac04 100644 --- a/.nais/nais.yaml +++ b/.nais/nais.yaml @@ -56,6 +56,8 @@ spec: value: {{uxsignalsMode}} - name: APP_ENV value: {{appEnv}} + - name: NEXT_PUBLIC_SANITY_DATASET + value: {{sanity_dataset}} ingresses: {{#each ingresses as |url|}} - {{url}} diff --git a/.nais/vars-dev.yaml b/.nais/vars-dev.yaml index 4471f6a2..0e721e59 100644 --- a/.nais/vars-dev.yaml +++ b/.nais/vars-dev.yaml @@ -20,4 +20,5 @@ soknadsdialog: ingress: https://arbeid.intern.dev.nav.no/dagpenger/dialog uxsignalsEnabled: enabled uxsignalsMode: demo -appEnv: dev \ No newline at end of file +appEnv: dev +sanity_dataset: development \ No newline at end of file diff --git a/.nais/vars-prod.yaml b/.nais/vars-prod.yaml index 30935acf..a72712fe 100644 --- a/.nais/vars-prod.yaml +++ b/.nais/vars-prod.yaml @@ -19,4 +19,5 @@ soknadsdialog: ingress: https://www.nav.no/dagpenger/dialog uxsignalsEnabled: enabled uxsignalsMode: production -appEnv: production \ No newline at end of file +appEnv: production +sanity_dataset: production \ No newline at end of file diff --git a/src/components/UxSignalsWidget.tsx b/src/components/UxSignalsWidget.tsx index 25424f0f..989bfe42 100644 --- a/src/components/UxSignalsWidget.tsx +++ b/src/components/UxSignalsWidget.tsx @@ -23,7 +23,7 @@ export function UxSignalsWidget({ enabled, mode }: IProps) { src="https://uxsignals-frontend.uxsignals.app.iterate.no/embed.js" />
diff --git a/src/context/sanity-context.tsx b/src/context/sanity-context.tsx index 4f7d7970..0059c7fe 100644 --- a/src/context/sanity-context.tsx +++ b/src/context/sanity-context.tsx @@ -37,9 +37,9 @@ function useSanity() { return context?.settings?.find((setting) => setting.settingId === settingId)?.settingValue; } - function getRichText(slug: string): TypedObject | TypedObject[] | undefined { + function getRichText(textId: string): TypedObject | TypedObject[] | undefined { const richText = context?.richTexts?.find((richText) => { - return richText.slug === slug; + return richText.textId === textId; }); return richText?.body; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 3765fb38..1445c8da 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -15,6 +15,8 @@ import { innenfor12Uker } from "../util/soknadDato.util"; import { PaabegyntSoknad, hentPaabegynteSoknader } from "./api/paabegynteSoknader"; import { Søknad, hentSoknader } from "./api/soknader"; import { UxSignalsWidget } from "../components/UxSignalsWidget"; +import { useRouter } from "next/router"; +import { useEffect } from "react"; interface Props { fullforteSoknader: Søknad[] | null; @@ -24,6 +26,7 @@ interface Props { interface IEnv { soknadsdialogIngress: string; + appEnv; uxSignals: { enabled: boolean; mode: string; @@ -81,6 +84,7 @@ export async function getServerSideProps( paabegynteSoknader, env: { soknadsdialogIngress: process.env.SOKNADSDIALOG_URL, + appEnv: process.env.APP_ENV, uxSignals: { enabled: process.env.UXSIGNALS_ENABLED === "enabled", mode: process.env.UXSIGNALS_MODE === "demo" ? "demo" : "", @@ -92,6 +96,28 @@ export async function getServerSideProps( export default function Status({ fullforteSoknader, paabegynteSoknader, env }: Props) { const { getAppText } = useSanity(); + const router = useRouter(); + + useEffect(() => { + // Task analytic Spørreundersøkelse for gammel og ny vedtaksbrev + const nyBrev = env.appEnv === "production" ? "03409" : "03400"; + const gammelBrev = env.appEnv === "production" ? "03408" : "03400"; + + setTimeout(() => { + //@ts-ignore Ukjent TA type + if (router.query && typeof window.TA === "function") { + if (router.query.brev === "ny") { + //@ts-ignore Ukjent TA type + window.TA("start", nyBrev); + } + + if (router.query.brev === "gammel") { + //@ts-ignore Ukjent TA type + window.TA("start", gammelBrev); + } + } + }, 2000); + }); return ( <> diff --git a/src/sanity/sanity-client.ts b/src/sanity/sanity-client.ts index ff9c541d..9ef98ee5 100644 --- a/src/sanity/sanity-client.ts +++ b/src/sanity/sanity-client.ts @@ -2,7 +2,7 @@ import { createClient } from "@sanity/client"; export const innsynSanityClient = createClient({ projectId: "rt6o382n", - dataset: "production", + dataset: process.env.NEXT_PUBLIC_SANITY_DATASET || "production", apiVersion: "2021-06-21", useCdn: process.env.NODE_ENV === "production", }); diff --git a/src/sanity/sanity-queries.ts b/src/sanity/sanity-queries.ts index 6bb79ba8..d7bf8064 100644 --- a/src/sanity/sanity-queries.ts +++ b/src/sanity/sanity-queries.ts @@ -8,8 +8,8 @@ const settingFields = `{ settingValue, }`; -const infoTextsFields = `{ - "slug": slug.current, +const richTextsFields = `{ + textId, body }`; @@ -20,25 +20,25 @@ const linkFields = `{ linkDescription }`; -export const appTextsGroq = `* [_type=="mineDagpengerAppText" && __i18n_lang==$baseLang]{ - ...coalesce(* [_id==^._id + "__i18n_" + $lang][0]${appTextFields}, ${appTextFields}) - }`; +export const appTextsGroq = `* [_type=="mineDagpengerAppText" && language==$baseLang]{ + ...coalesce(* [textId==^.textId && language==$lang][0]${appTextFields}, ${appTextFields}) +}`; -const infoTextsGroq = `* [_type=="mineDagpengerRichText" && __i18n_lang==$baseLang]{ - ...coalesce(* [_id==^._id + "__i18n_" + $lang][0]${infoTextsFields}, ${infoTextsFields}) - }`; +const richTextsGroq = `* [_type=="mineDagpengerRichText" && language==$baseLang]{ + ...coalesce(* [textId==^.textId && language==$lang][0]${richTextsFields}, ${richTextsFields}) +}`; -const linksGroq = `* [_type=="mineDagpengerLink" && __i18n_lang==$baseLang]{ - ...coalesce(* [_id==^._id + "__i18n_" + $lang][0]${linkFields}, ${linkFields}) - }`; +const linksGroq = `* [_type=="mineDagpengerLink" && language==$baseLang]{ + ...coalesce(* [linkId==^.linkId && language==$lang][0]${linkFields}, ${linkFields}) +}`; -const settingsGroq = `* [_type=="mineDagpengerSetting" && __i18n_lang==$baseLang]{ - ...coalesce(* [_id==^._id + "__i18n_" + $lang][0]${settingFields}, ${settingFields}) - }`; +const settingsGroq = `* [_type=="mineDagpengerSetting" && language==$baseLang]{ + ...coalesce(* [settingId==^.settingId && language==$lang][0]${settingFields}, ${settingFields}) +}`; export const allTextsQuery = `{ "appTexts": ${appTextsGroq}, - "richTexts": ${infoTextsGroq}, + "richTexts": ${richTextsGroq}, "links": ${linksGroq}, "settings": ${settingsGroq} }`; diff --git a/src/types/sanity.types.ts b/src/types/sanity.types.ts index 8772c4c2..ab9d2b93 100644 --- a/src/types/sanity.types.ts +++ b/src/types/sanity.types.ts @@ -16,7 +16,7 @@ export interface ISanitySetting { } export interface ISanityRichText { - slug: string; + textId: string; body: TypedObject | TypedObject[]; }