Skip to content

Commit

Permalink
Konverter til TS (#857)
Browse files Browse the repository at this point in the history
Slett Typeahead, erstattet av combobox
Slett hotjar.ts finner ikke bruk av initHotjar
Konverter commont filer til ts
Konverter enkle filer utenfor common
  • Loading branch information
St3ff1 authored Nov 5, 2024
1 parent c5637e5 commit e36a0e3
Show file tree
Hide file tree
Showing 34 changed files with 231 additions and 527 deletions.
File renamed without changes.
127 changes: 118 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@navikt/oasis": "^3.2.2",
"@neshca/cache-handler": "^1.3.1",
"@sentry/nextjs": "^7.114.0",
"@sentry/types": "^8.36.0",
"@vercel/otel": "^1.8.2",
"browser-cookies": "^1.2.0",
"date-fns": "^3.6.0",
Expand All @@ -56,7 +57,7 @@
"@next/eslint-plugin-next": "^14.2.1",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.2",
"@types/node": "20.12.12",
"@types/node": "22.8.7",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@types/testing-library__jest-dom": "^6.0.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/(sok)/_components/filters/DrivingDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function DrivingDistance({ postcodes, errors }: DrivingDistanceProps): ReactElem
}
logFilterChanged({
name: "Reisevei",
value: value || query.get(QueryNames.DISTANCE),
value: value || query.get(QueryNames.DISTANCE) || undefined,
level: "Avstand",
checked: !hasNoValue && selectedPostcode.length > 0,
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/(sok)/page.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createQuery, defaultQuery, SEARCH_CHUNK_SIZE, toApiQuery } from "@/app/(sok)/_utils/query";
import { fetchCachedSimplifiedElasticSearch } from "@/app/(sok)/_utils/fetchElasticSearch";
import * as actions from "@/app/_common/actions";
import * as actions from "@/app/_common/actions/index";
import { Button, VStack } from "@navikt/ds-react";
import Link from "next/link";
import React from "react";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ import { revalidatePath } from "next/cache";
import { incrementAdUserRequests } from "@/metrics";

const ADUSER_FAVOURITES_URL = `${process.env.PAMADUSER_URL}/api/v1/userfavouriteads`;

type Favourite = {
uuid: string;
source: string | undefined;
reference: string | undefined;
title: string | undefined;
jobTitle?: string;
status: string | undefined;
applicationdue?: string;
location?: string;
employer?: string | null | undefined;
published: string | Date | undefined;
expires: string | Date | undefined;
};
export async function getFavouritesAction() {
const oboToken = await getAdUserOboToken();

Expand All @@ -31,7 +43,7 @@ export async function getFavouritesAction() {
return data ? data.content : [];
}

export async function addFavouriteAction(favouriteAd) {
export async function addFavouriteAction(favouriteAd: Favourite) {
logger.info("Add favourite", { uuid: favouriteAd.uuid });
const oboToken = await getAdUserOboToken();
const res = await fetch(ADUSER_FAVOURITES_URL, {
Expand All @@ -52,7 +64,7 @@ export async function addFavouriteAction(favouriteAd) {
return res.json();
}

export async function deleteFavouriteAction(uuid) {
export async function deleteFavouriteAction(uuid: string) {
logger.info("DELETE favourite ", { uuid });
const oboToken = await getAdUserOboToken();
const res = await fetch(`${ADUSER_FAVOURITES_URL}/${uuid}`, {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/app/_common/auth/auth.js → src/app/_common/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function getAdUserOboToken() {
throw new Error("Failed to validate token");
}

const oboResult = await requestTokenxOboToken(token, process.env.ADUSER_AUDIENCE);
const oboResult = await requestTokenxOboToken(token, process.env.ADUSER_AUDIENCE || "");

if (!oboResult.ok) {
throw new Error("Failed to get exchange token");
Expand All @@ -27,7 +27,7 @@ export async function getAdUserOboToken() {
return oboResult.token;
}

export function getDefaultAuthHeaders(oboToken) {
export function getDefaultAuthHeaders(oboToken: string) {
// eslint-disable-next-line
const headers = getDefaultHeaders();

Expand All @@ -36,7 +36,7 @@ export function getDefaultAuthHeaders(oboToken) {
return headers;
}

export function getAdUserDefaultAuthHeadersWithCsrfToken(oboToken) {
export function getAdUserDefaultAuthHeadersWithCsrfToken(oboToken: string) {
const csrfToken = cookies().get(ADUSER_XSRF_COOKIE_NAME)?.value;

if (!csrfToken) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
"use client";

import React from "react";
import PropTypes from "prop-types";
import { LoginPage } from "@navikt/arbeidsplassen-react";

function LoginIsRequiredPage({ redirect = "/stillinger" }) {
type LoginIsRequiredPageProps = {
redirect?: string;
};
const LoginIsRequiredPage = ({ redirect = "/stillinger" }: LoginIsRequiredPageProps) => {
return (
<section className="container-small mt-12 mb-12">
<LoginPage link={`/stillinger/oauth2/login?redirect=${redirect}`} />
</section>
);
}

LoginIsRequiredPage.propTypes = {
redirect: PropTypes.string,
};

export default LoginIsRequiredPage;
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from "react";
import PropTypes from "prop-types";
import { BodyLong, Button, HStack, Modal, VStack } from "@navikt/ds-react";
import { FigureWithKey } from "@navikt/arbeidsplassen-react";
import { EnterIcon } from "@navikt/aksel-icons";

function LoginModal({ onLoginClick, onCloseClick }) {
type LoginModalProps = {
onLoginClick: () => void;
onCloseClick: () => void;
};
function LoginModal({ onLoginClick, onCloseClick }: LoginModalProps) {
return (
<Modal
width="small"
Expand Down Expand Up @@ -42,9 +45,4 @@ function LoginModal({ onLoginClick, onCloseClick }) {
);
}

LoginModal.propTypes = {
onCloseClick: PropTypes.func.isRequired,
onLoginClick: PropTypes.func.isRequired,
};

export default LoginModal;
Loading

0 comments on commit e36a0e3

Please sign in to comment.