-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sentraliser kode ifm. DeltakerRegistrering
- Loading branch information
Showing
12 changed files
with
115 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
frontend/mulighetsrommet-veileder-flate/src/core/api/getEnvironment.ts
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
frontend/mulighetsrommet-veileder-flate/src/core/api/useLoadDeltakerRegistreringApp.ts
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
frontend/mulighetsrommet-veileder-flate/src/environment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export enum Environment { | ||
PROD = "PROD", | ||
DEV = "DEV", | ||
LOCAL = "LOCAL", | ||
} | ||
|
||
export const environment: Environment = getEnvironment(); | ||
|
||
export const isProduction = window.location.origin.endsWith(".intern.nav.no"); | ||
|
||
export const isDevelopment = window.location.origin.endsWith(".intern.dev.nav.no"); | ||
|
||
function getEnvironment() { | ||
if (isProduction) { | ||
return Environment.PROD; | ||
} | ||
|
||
if (isDevelopment) { | ||
return Environment.DEV; | ||
} | ||
|
||
return Environment.LOCAL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...tsrommet-veileder-flate/src/microfrontends/deltaker-registrering/DeltakerRegistrering.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Alert, Button } from "@navikt/ds-react"; | ||
import React from "react"; | ||
import { ErrorBoundary } from "react-error-boundary"; | ||
import { useLoadDeltakerRegistreringApp } from "@/microfrontends/deltaker-registrering/useLoadDeltakerRegistreringApp"; | ||
import { useGetTiltaksgjennomforingIdFraUrl } from "@/core/api/queries/useGetTiltaksgjennomforingIdFraUrl"; | ||
import { useAppContext } from "@/hooks/useAppContext"; | ||
|
||
export function DeltakerRegistrering() { | ||
return ( | ||
<React.Suspense fallback="Laster..."> | ||
<ErrorBoundary | ||
FallbackComponent={({ resetErrorBoundary }) => { | ||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: "1rem", | ||
}} | ||
> | ||
<Alert variant="error">Klarte ikke laste deltakerregistrering</Alert> | ||
<Button onClick={resetErrorBoundary}>Prøv på nytt</Button> | ||
</div> | ||
); | ||
}} | ||
> | ||
<DeltakerRegistreringApp /> | ||
</ErrorBoundary> | ||
</React.Suspense> | ||
); | ||
} | ||
|
||
function DeltakerRegistreringApp() { | ||
useLoadDeltakerRegistreringApp(); | ||
|
||
const tiltaksgjennomforingId = useGetTiltaksgjennomforingIdFraUrl(); | ||
|
||
const { fnr, enhet } = useAppContext(); | ||
|
||
return React.createElement("arbeidsmarkedstiltak-deltaker", { | ||
"data-personident": fnr, | ||
"data-deltakerlisteId": tiltaksgjennomforingId, | ||
"data-enhetId": enhet, | ||
}); | ||
} |
40 changes: 40 additions & 0 deletions
40
...veileder-flate/src/microfrontends/deltaker-registrering/useLoadDeltakerRegistreringApp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import { environment } from "@/environment"; | ||
import { headers } from "@/core/api/headers"; | ||
|
||
export const DELTAKERREGISTRERING_ENTRY = "src/webComponentWrapper.tsx"; | ||
|
||
const DELTAKERREGISTRERING_KOMET = { | ||
LOCAL: "http://localhost:4173", | ||
DEV: "https://amt-deltaker-flate.intern.dev.nav.no", // URL til bundle som blir hostet et sted i dev | ||
PROD: "", // URL til bundle som blir hostet et sted i prod | ||
}; | ||
|
||
const deltakerRegistreringOrigin = DELTAKERREGISTRERING_KOMET[environment]; | ||
|
||
const deltakerregistreringKometManifestUrl = `${deltakerRegistreringOrigin}/asset-manifest.json`; | ||
|
||
interface DeltakerRegistreringAssetManifest { | ||
"src/webComponentWrapper.tsx": { | ||
file: string; | ||
}; | ||
} | ||
|
||
export function useLoadDeltakerRegistreringApp() { | ||
return useSuspenseQuery<any>({ | ||
queryKey: ["deltaker-registrering-asset-manifest"], | ||
queryFn: async () => { | ||
const response = await fetch(deltakerregistreringKometManifestUrl, { | ||
headers, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to load DeltakerRegistrering"); | ||
} | ||
|
||
const manifest: DeltakerRegistreringAssetManifest = await response.json(); | ||
const entry = manifest[DELTAKERREGISTRERING_ENTRY].file; | ||
return import(/* @vite-ignore */ `${deltakerRegistreringOrigin}/${entry}`); | ||
}, | ||
}); | ||
} |
2 changes: 0 additions & 2 deletions
2
frontend/mulighetsrommet-veileder-flate/src/microfrontends/entrypoints.ts
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
...end/mulighetsrommet-veileder-flate/src/microfrontends/team_komet/DeltakerRegistrering.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters