Skip to content

Commit

Permalink
Merge branch 'main' into DDFBRA-145-automatisk-tilgaengeligheds-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamik10 committed Nov 11, 2024
2 parents edf2a7e + dab3e25 commit 446e85b
Show file tree
Hide file tree
Showing 20 changed files with 247 additions and 220 deletions.
13 changes: 4 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
{
"root": true,
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"extends": [
"next/core-web-vitals",
"next/typescript",
"plugin:storybook/recommended"
"plugin:storybook/recommended",
"prettier"
],
"rules": {
"no-console": [
"error",
{
"allow": [
"warn",
"error",
"info"
]
"allow": ["warn", "error", "info"]
}
],
"@typescript-eslint/ban-ts-comment": "off"
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/prettier-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Prettier check

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Make sure the actual branch is checked out when running on pull requests.
ref: ${{ github.head_ref }}
fetch-depth: 0 # 👈 Required to retrieve git history

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Check Prettier formatting
run: yarn run format:check
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.next
generated
node_modules
3 changes: 1 addition & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ vars:
# Where is the docker file(s) we use for our builds residing?
LAGOON_DIR: "lagoon"


tasks:
ghcr:login:
summary: Login into Github Container Registry
Expand All @@ -33,7 +32,7 @@ tasks:
preconditions:
- sh: "[ ! -z {{.CR_PAT}} ]"
msg: "Env variable CR_PAT is not set or empty."

source:build:
summary: Build node image.
cmds:
Expand Down
14 changes: 7 additions & 7 deletions app/auth/callback/unilogin/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { z } from "zod";
import { z } from "zod"

const schemas = {
tokenSet: z.object({
access_token: z.string(),
refresh_token: z.string(),
id_token: z.string(),
expires_in: z.number(),
refresh_expires_in: z.number()
refresh_expires_in: z.number(),
}),
introspect: z.object({
uniid: z.string(),
institutionIds: z.string()
institutionIds: z.string(),
}),
userInfo: z.object({
sub: z.string()
})
};
sub: z.string(),
}),
}

export default schemas;
export default schemas
25 changes: 11 additions & 14 deletions app/auth/login/unilogin/route.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import { generators } from "openid-client";
import { generators } from "openid-client"

import {
getUniloginClient,
uniloginClientConfig
} from "@/lib/session/oauth/uniloginClient";
import { getSession } from "@/lib/session/session";
import { getUniloginClient, uniloginClientConfig } from "@/lib/session/oauth/uniloginClient"
import { getSession } from "@/lib/session/session"

export async function GET() {
const session = await getSession();
const session = await getSession()

session.code_verifier = generators.codeVerifier();
session.code_verifier = generators.codeVerifier()

const code_challenge = generators.codeChallenge(session.code_verifier);
const code_challenge = generators.codeChallenge(session.code_verifier)

const client = await getUniloginClient();
const client = await getUniloginClient()
const url = client.authorizationUrl({
scope: uniloginClientConfig.scope,
audience: uniloginClientConfig.audience,
redirect_uri: uniloginClientConfig.redirect_uri,
code_challenge,
code_challenge_method: "S256"
});
code_challenge_method: "S256",
})

await session.save();
return Response.redirect(url);
await session.save()
return Response.redirect(url)
}
12 changes: 6 additions & 6 deletions app/auth/session/route.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { defaultSession, getSession } from "@/lib/session/session";
import { defaultSession, getSession } from "@/lib/session/session"

export async function GET() {
try {
const session = await getSession();
const session = await getSession()
if (!session) {
return Response.json({ defaultSession });
return Response.json({ defaultSession })
}
return Response.json({
isLoggedIn: session.isLoggedIn,
userInfo: session.userInfo
});
userInfo: session.userInfo,
})
} catch (e) {
return Response.json({ error: e }, { status: 500 });
return Response.json({ error: e }, { status: 500 })
}
}
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Image from "next/image";
import Image from "next/image"

export default async function Home() {
return (
Expand Down
2 changes: 1 addition & 1 deletion components/shared/badge/BadgeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const BadgeButton = ({ onClick, isActive = false, classNames, children }: BadgeB
`focus-visible h-[29px] w-auto self-start whitespace-nowrap rounded-full bg-background-overlay px-4
py-2 text-typo-caption hover:animate-wiggle`,
isActive && "bg-foreground text-background",
classNames,
classNames
)}>
{children}
</button>
Expand Down
1 change: 1 addition & 0 deletions components/shared/workCard/WorkCardAvailabilityItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react"

import Icon from "../icon/Icon"

type WorkCardAvailabilityItemProps = {
Expand Down
43 changes: 18 additions & 25 deletions lib/fetchers/types.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
export type FetchParams =
| string
| string[][]
| Record<string, string>
| URLSearchParams
| undefined;
export type FetchParams = string | string[][] | Record<string, string> | URLSearchParams | undefined

export type FetcherOptions = {
bearerToken?: string;
baseUrl: string;
};
bearerToken?: string
baseUrl: string
}
export type RequestOptions = {
bearerToken?: string;
baseUrl?: string;
};
bearerToken?: string
baseUrl?: string
}
export type RequestArguments = {
url: string;
method: "get" | "post" | "put" | "delete" | "patch";
headers: Record<string, string>;
params?: FetchParams;
data?: BodyType<unknown>;
responseType?: string;
signal?: AbortSignal;
};
export type RequestCallback = (
options: RequestArguments
) => RequestArguments & RequestOptions;
url: string
method: "get" | "post" | "put" | "delete" | "patch"
headers: Record<string, string>
params?: FetchParams
data?: BodyType<unknown>
responseType?: string
signal?: AbortSignal
}
export type RequestCallback = (options: RequestArguments) => RequestArguments & RequestOptions

export type ErrorType<TErrorData> = TErrorData;
export type ErrorType<TErrorData> = TErrorData

export type BodyType<TBodyData> = TBodyData;
export type BodyType<TBodyData> = TBodyData
8 changes: 4 additions & 4 deletions lib/getQueryClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryClient } from "@tanstack/react-query";
import { cache } from "react";
import { QueryClient } from "@tanstack/react-query"
import { cache } from "react"

const getQueryClient = cache(() => new QueryClient());
export default getQueryClient;
const getQueryClient = cache(() => new QueryClient())
export default getQueryClient
5 changes: 3 additions & 2 deletions lib/helpers/helper.cn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { extendedTheme } from "@/tailwind.config"
import { type ClassValue, clsx } from "clsx"
import { extendTailwindMerge } from "tailwind-merge"

import { extendedTheme } from "@/tailwind.config"

const customTwMerge = extendTailwindMerge({
extend: {
classGroups: {
'font-size': [
"font-size": [
{
text: Object.keys(extendedTheme.fontSize),
},
Expand Down
14 changes: 7 additions & 7 deletions lib/providers/ReactQueryProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"use client";
"use client"

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { useState } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { useState } from "react"

function ReactQueryProvider({ children }: React.PropsWithChildren) {
const [client] = useState(new QueryClient());
const [client] = useState(new QueryClient())

return (
<QueryClientProvider client={client}>
{children}
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
)
}

export default ReactQueryProvider;
export default ReactQueryProvider
Loading

0 comments on commit 446e85b

Please sign in to comment.