diff --git a/.eslintrc.json b/.eslintrc.json index 5ff510b4..c122dbfe 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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" diff --git a/.github/workflows/prettier-check.yml b/.github/workflows/prettier-check.yml new file mode 100644 index 00000000..a14646d9 --- /dev/null +++ b/.github/workflows/prettier-check.yml @@ -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 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..ed090c7a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +.next +generated +node_modules diff --git a/Taskfile.yml b/Taskfile.yml index 185bf838..0fb552f9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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 @@ -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: diff --git a/app/auth/callback/unilogin/schemas.ts b/app/auth/callback/unilogin/schemas.ts index fd4a398c..2c855524 100644 --- a/app/auth/callback/unilogin/schemas.ts +++ b/app/auth/callback/unilogin/schemas.ts @@ -1,4 +1,4 @@ -import { z } from "zod"; +import { z } from "zod" const schemas = { tokenSet: z.object({ @@ -6,15 +6,15 @@ const schemas = { 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 diff --git a/app/auth/login/unilogin/route.ts b/app/auth/login/unilogin/route.ts index 5728e079..ea6434e3 100644 --- a/app/auth/login/unilogin/route.ts +++ b/app/auth/login/unilogin/route.ts @@ -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) } diff --git a/app/auth/session/route.ts b/app/auth/session/route.ts index 5dd92609..1463f489 100644 --- a/app/auth/session/route.ts +++ b/app/auth/session/route.ts @@ -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 }) } } diff --git a/app/page.tsx b/app/page.tsx index 43fa05e7..3ae0fd9c 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,4 +1,4 @@ -import Image from "next/image"; +import Image from "next/image" export default async function Home() { return ( diff --git a/components/shared/badge/BadgeButton.tsx b/components/shared/badge/BadgeButton.tsx index ca526f41..dda02364 100644 --- a/components/shared/badge/BadgeButton.tsx +++ b/components/shared/badge/BadgeButton.tsx @@ -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} diff --git a/components/shared/workCard/WorkCardAvailabilityItem.tsx b/components/shared/workCard/WorkCardAvailabilityItem.tsx index 2bae9851..8b7c25d4 100644 --- a/components/shared/workCard/WorkCardAvailabilityItem.tsx +++ b/components/shared/workCard/WorkCardAvailabilityItem.tsx @@ -1,4 +1,5 @@ import React from "react" + import Icon from "../icon/Icon" type WorkCardAvailabilityItemProps = { diff --git a/lib/fetchers/types.ts b/lib/fetchers/types.ts index 97fa7190..f55326f2 100644 --- a/lib/fetchers/types.ts +++ b/lib/fetchers/types.ts @@ -1,31 +1,24 @@ -export type FetchParams = - | string - | string[][] - | Record - | URLSearchParams - | undefined; +export type FetchParams = string | string[][] | Record | 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; - params?: FetchParams; - data?: BodyType; - responseType?: string; - signal?: AbortSignal; -}; -export type RequestCallback = ( - options: RequestArguments -) => RequestArguments & RequestOptions; + url: string + method: "get" | "post" | "put" | "delete" | "patch" + headers: Record + params?: FetchParams + data?: BodyType + responseType?: string + signal?: AbortSignal +} +export type RequestCallback = (options: RequestArguments) => RequestArguments & RequestOptions -export type ErrorType = TErrorData; +export type ErrorType = TErrorData -export type BodyType = TBodyData; +export type BodyType = TBodyData diff --git a/lib/getQueryClient.ts b/lib/getQueryClient.ts index ea712cc0..555961d0 100644 --- a/lib/getQueryClient.ts +++ b/lib/getQueryClient.ts @@ -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 diff --git a/lib/helpers/helper.cn.ts b/lib/helpers/helper.cn.ts index d71156f6..20a21b50 100644 --- a/lib/helpers/helper.cn.ts +++ b/lib/helpers/helper.cn.ts @@ -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), }, diff --git a/lib/providers/ReactQueryProvider.tsx b/lib/providers/ReactQueryProvider.tsx index 006f7080..8b50e5e3 100644 --- a/lib/providers/ReactQueryProvider.tsx +++ b/lib/providers/ReactQueryProvider.tsx @@ -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 ( {children} - ); + ) } -export default ReactQueryProvider; +export default ReactQueryProvider diff --git a/lib/rest/publizon-api/publizon-adapter.yaml b/lib/rest/publizon-api/publizon-adapter.yaml index c1a8d4c3..3b46a365 100644 --- a/lib/rest/publizon-api/publizon-adapter.yaml +++ b/lib/rest/publizon-api/publizon-adapter.yaml @@ -2,7 +2,7 @@ openapi: 3.0.1 info: title: Publizon Library API description: "Pubhub exists in two separate environments, each with their own server, code and database. Please use the web service located at library-api.qa.pubhub.dk when developing and testing.\nOrders/loans created in test environment will not be invoiced. Please request a new license key for the production environment when you're ready to go live." - version: '1' + version: "1" paths: /v1/user/cardnumber/friendly: get: @@ -31,39 +31,39 @@ paths: schema: type: string responses: - '200': + "200": description: Successfully retrieved the friendly card number. content: text/plain: schema: type: array items: - $ref: '#/components/schemas/FriendlyCardResult' - example: {"friendlyCardNumber":"AABBCC123","code":101,"message":"OK"} + $ref: "#/components/schemas/FriendlyCardResult" + example: { "friendlyCardNumber": "AABBCC123", "code": 101, "message": "OK" } application/json: schema: type: array items: - $ref: '#/components/schemas/FriendlyCardResult' - example: {"friendlyCardNumber":"AABBCC123","code":101,"message":"OK"} + $ref: "#/components/schemas/FriendlyCardResult" + example: { "friendlyCardNumber": "AABBCC123", "code": 101, "message": "OK" } text/json: schema: type: array items: - $ref: '#/components/schemas/FriendlyCardResult' - example: {"friendlyCardNumber":"AABBCC123","code":101,"message":"OK"} - '400': - description: 'Error occurred, see message.' + $ref: "#/components/schemas/FriendlyCardResult" + example: { "friendlyCardNumber": "AABBCC123", "code": 101, "message": "OK" } + "400": + description: "Error occurred, see message." content: text/plain: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" application/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" text/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" /v1/user/checklist: get: tags: @@ -87,19 +87,19 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ChecklistResult' + $ref: "#/components/schemas/ChecklistResult" application/json: schema: - $ref: '#/components/schemas/ChecklistResult' + $ref: "#/components/schemas/ChecklistResult" text/json: schema: - $ref: '#/components/schemas/ChecklistResult' - '/v1/user/checklist/{identifier}': + $ref: "#/components/schemas/ChecklistResult" + "/v1/user/checklist/{identifier}": post: tags: - Checklist @@ -127,18 +127,18 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" application/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" text/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" delete: tags: - Checklist @@ -166,18 +166,18 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" application/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" text/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" /v1/library/profile: get: tags: @@ -195,18 +195,18 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/LibraryProfile' + $ref: "#/components/schemas/LibraryProfile" application/json: schema: - $ref: '#/components/schemas/LibraryProfile' + $ref: "#/components/schemas/LibraryProfile" text/json: schema: - $ref: '#/components/schemas/LibraryProfile' + $ref: "#/components/schemas/LibraryProfile" /v1/user/loans: get: tags: @@ -231,23 +231,23 @@ paths: type: string - name: bookType in: query - description: '0 = Ebook, 1 = Audio' + description: "0 = Ebook, 1 = Audio" schema: - $ref: '#/components/schemas/BookTypes' + $ref: "#/components/schemas/BookTypes" responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/LoanListResult' + $ref: "#/components/schemas/LoanListResult" application/json: schema: - $ref: '#/components/schemas/LoanListResult' + $ref: "#/components/schemas/LoanListResult" text/json: schema: - $ref: '#/components/schemas/LoanListResult' - '/v1/user/loans/{identifier}': + $ref: "#/components/schemas/LoanListResult" + "/v1/user/loans/{identifier}": get: tags: - Loan @@ -277,18 +277,18 @@ paths: minLength: 13 type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/LoanResult' + $ref: "#/components/schemas/LoanResult" application/json: schema: - $ref: '#/components/schemas/LoanResult' + $ref: "#/components/schemas/LoanResult" text/json: schema: - $ref: '#/components/schemas/LoanResult' + $ref: "#/components/schemas/LoanResult" post: tags: - Loan @@ -324,19 +324,19 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/CreateLoanResult' + $ref: "#/components/schemas/CreateLoanResult" application/json: schema: - $ref: '#/components/schemas/CreateLoanResult' + $ref: "#/components/schemas/CreateLoanResult" text/json: schema: - $ref: '#/components/schemas/CreateLoanResult' - '/v1/loanstatus/{identifier}': + $ref: "#/components/schemas/CreateLoanResult" + "/v1/loanstatus/{identifier}": get: tags: - LoanStatus @@ -364,18 +364,18 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/LoanStatusResult' + $ref: "#/components/schemas/LoanStatusResult" application/json: schema: - $ref: '#/components/schemas/LoanStatusResult' + $ref: "#/components/schemas/LoanStatusResult" text/json: schema: - $ref: '#/components/schemas/LoanStatusResult' + $ref: "#/components/schemas/LoanStatusResult" /v1/loanstatus: post: tags: @@ -416,19 +416,19 @@ paths: items: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/LoanStatusListResult' + $ref: "#/components/schemas/LoanStatusListResult" application/json: schema: - $ref: '#/components/schemas/LoanStatusListResult' + $ref: "#/components/schemas/LoanStatusListResult" text/json: schema: - $ref: '#/components/schemas/LoanStatusListResult' - '/v1/products/{identifier}': + $ref: "#/components/schemas/LoanStatusListResult" + "/v1/products/{identifier}": get: tags: - Product @@ -451,18 +451,18 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ProductResult' + $ref: "#/components/schemas/ProductResult" application/json: schema: - $ref: '#/components/schemas/ProductResult' + $ref: "#/components/schemas/ProductResult" text/json: schema: - $ref: '#/components/schemas/ProductResult' + $ref: "#/components/schemas/ProductResult" /v1/products: get: tags: @@ -481,18 +481,18 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ProductListResult' + $ref: "#/components/schemas/ProductListResult" application/json: schema: - $ref: '#/components/schemas/ProductListResult' + $ref: "#/components/schemas/ProductListResult" text/json: schema: - $ref: '#/components/schemas/ProductListResult' + $ref: "#/components/schemas/ProductListResult" /v1/user/reservations: get: tags: @@ -516,19 +516,19 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ReservationListResult' + $ref: "#/components/schemas/ReservationListResult" application/json: schema: - $ref: '#/components/schemas/ReservationListResult' + $ref: "#/components/schemas/ReservationListResult" text/json: schema: - $ref: '#/components/schemas/ReservationListResult' - '/v1/user/reservations/{identifier}': + $ref: "#/components/schemas/ReservationListResult" + "/v1/user/reservations/{identifier}": post: tags: - Reservation @@ -559,26 +559,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ReservationInput' + $ref: "#/components/schemas/ReservationInput" text/json: schema: - $ref: '#/components/schemas/ReservationInput' + $ref: "#/components/schemas/ReservationInput" application/*+json: schema: - $ref: '#/components/schemas/ReservationInput' + $ref: "#/components/schemas/ReservationInput" responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" application/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" text/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" patch: tags: - Reservation @@ -609,26 +609,26 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ReservationInput' + $ref: "#/components/schemas/ReservationInput" text/json: schema: - $ref: '#/components/schemas/ReservationInput' + $ref: "#/components/schemas/ReservationInput" application/*+json: schema: - $ref: '#/components/schemas/ReservationInput' + $ref: "#/components/schemas/ReservationInput" responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" application/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" text/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" delete: tags: - Reservation @@ -656,18 +656,18 @@ paths: schema: type: string responses: - '200': + "200": description: Success content: text/plain: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" application/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" text/json: schema: - $ref: '#/components/schemas/ApiResult' + $ref: "#/components/schemas/ApiResult" components: schemas: ApiResponseCode: @@ -697,13 +697,13 @@ components: - 152 - 153 type: integer - description: '101 = Success, 105 = InvalidContentIdentifier, 118 = InvalidRequestIdentity, 120 = MaxConcurrentLoansPerBorrowerExceeded, 125 = MaxAmountPerMonthExceeded, 128 = ContentNotFound, 131 = NotLoanable, 134 = CardTemporarilyBlocked, 135 = MaxLoansOnTitleReached, 136 = InsufficientCopiesException, 137 = ReservationLimitReached, 138 = GenericFault, 139 = InvalidAgreement, 140 = AlreadyReserved, 141 = InvalidEmail, 142 = InvalidPhone, 143 = CostFreeLimitReached, 147 = CountryNotFound, 148 = InvalidInstitutionId, 149 = InvalidCardFormat, 150 = InvalidCardByCulr, 151 = CardNotFound, 152 = InvalidClientId, 153 = LoanNotFound' + description: "101 = Success, 105 = InvalidContentIdentifier, 118 = InvalidRequestIdentity, 120 = MaxConcurrentLoansPerBorrowerExceeded, 125 = MaxAmountPerMonthExceeded, 128 = ContentNotFound, 131 = NotLoanable, 134 = CardTemporarilyBlocked, 135 = MaxLoansOnTitleReached, 136 = InsufficientCopiesException, 137 = ReservationLimitReached, 138 = GenericFault, 139 = InvalidAgreement, 140 = AlreadyReserved, 141 = InvalidEmail, 142 = InvalidPhone, 143 = CostFreeLimitReached, 147 = CountryNotFound, 148 = InvalidInstitutionId, 149 = InvalidCardFormat, 150 = InvalidCardByCulr, 151 = CardNotFound, 152 = InvalidClientId, 153 = LoanNotFound" format: int32 ApiResult: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true @@ -714,7 +714,7 @@ components: - 0 - 1 type: integer - description: '0 = Ebook, 1 = Audio' + description: "0 = Ebook, 1 = Audio" format: int32 ChecklistItem: type: object @@ -734,14 +734,14 @@ components: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true items: type: array items: - $ref: '#/components/schemas/ChecklistItem' + $ref: "#/components/schemas/ChecklistItem" nullable: true additionalProperties: false description: "Get checklist result. Checklist items are found in\r\n
Items\r\n." @@ -755,13 +755,13 @@ components: - 5 - 6 type: integer - description: '' + description: "" format: int32 CreateLoanResult: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true @@ -782,13 +782,13 @@ components: - 3 - 4 type: integer - description: '' + description: "" format: int32 FriendlyCardResult: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true @@ -802,7 +802,7 @@ components: - 3 - 15 type: integer - description: '' + description: "" format: int32 LibraryBook: type: object @@ -811,7 +811,7 @@ components: type: string nullable: true identifierType: - $ref: '#/components/schemas/IdentifierTypeEnum' + $ref: "#/components/schemas/IdentifierTypeEnum" title: type: string nullable: true @@ -862,7 +862,7 @@ components: type: object properties: idType: - $ref: '#/components/schemas/IdentifierTypeEnum' + $ref: "#/components/schemas/IdentifierTypeEnum" id: type: string nullable: true @@ -920,7 +920,7 @@ components: testCards: type: array items: - $ref: '#/components/schemas/TestCard' + $ref: "#/components/schemas/TestCard" nullable: true additionalProperties: false Loan: @@ -941,48 +941,48 @@ components: isSubscriptionLoan: type: boolean libraryBook: - $ref: '#/components/schemas/LibraryBook' + $ref: "#/components/schemas/LibraryBook" fileExtensionType: - $ref: '#/components/schemas/FileExtensionType' + $ref: "#/components/schemas/FileExtensionType" additionalProperties: false LoanListResult: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true loans: type: array items: - $ref: '#/components/schemas/Loan' + $ref: "#/components/schemas/Loan" nullable: true libraryData: - $ref: '#/components/schemas/LibraryData' + $ref: "#/components/schemas/LibraryData" userData: - $ref: '#/components/schemas/UserData' + $ref: "#/components/schemas/UserData" additionalProperties: false LoanResult: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true loan: - $ref: '#/components/schemas/Loan' + $ref: "#/components/schemas/Loan" libraryData: - $ref: '#/components/schemas/LibraryData' + $ref: "#/components/schemas/LibraryData" userData: - $ref: '#/components/schemas/UserData' + $ref: "#/components/schemas/UserData" additionalProperties: false LoanStatusItem: type: object properties: loanStatus: - $ref: '#/components/schemas/ContentLoanStatusEnum' + $ref: "#/components/schemas/ContentLoanStatusEnum" onChecklist: type: boolean identifier: @@ -993,26 +993,26 @@ components: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true items: type: array items: - $ref: '#/components/schemas/LoanStatusItem' + $ref: "#/components/schemas/LoanStatusItem" nullable: true additionalProperties: false LoanStatusResult: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true loanStatus: - $ref: '#/components/schemas/ContentLoanStatusEnum' + $ref: "#/components/schemas/ContentLoanStatusEnum" onChecklist: type: boolean identifier: @@ -1049,14 +1049,14 @@ components: type: integer format: int32 externalProductId: - $ref: '#/components/schemas/LibraryProductExternalId' + $ref: "#/components/schemas/LibraryProductExternalId" internalProductId: type: string nullable: true contributors: type: array items: - $ref: '#/components/schemas/LibraryProductContributor' + $ref: "#/components/schemas/LibraryProductContributor" nullable: true format: type: string @@ -1080,7 +1080,7 @@ components: productCategories: type: array items: - $ref: '#/components/schemas/LibraryProductCategory' + $ref: "#/components/schemas/LibraryProductCategory" nullable: true costFree: type: boolean @@ -1089,14 +1089,14 @@ components: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true products: type: array items: - $ref: '#/components/schemas/Product' + $ref: "#/components/schemas/Product" nullable: true additionalProperties: false description: "Get product list result. Product items are found in\r\n
Products\r\n." @@ -1104,12 +1104,12 @@ components: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true product: - $ref: '#/components/schemas/Product' + $ref: "#/components/schemas/Product" additionalProperties: false description: Get product result. Reservation: @@ -1155,14 +1155,14 @@ components: type: object properties: code: - $ref: '#/components/schemas/ApiResponseCode' + $ref: "#/components/schemas/ApiResponseCode" message: type: string nullable: true reservations: type: array items: - $ref: '#/components/schemas/Reservation' + $ref: "#/components/schemas/Reservation" nullable: true additionalProperties: false description: "Reservation list result. Reservation items are found in\r\n
Reservations\r\n." @@ -1204,12 +1204,11 @@ components: securitySchemes: oauth: type: oauth2 - description: 'OAuth 2.0 password Grant' + description: "OAuth 2.0 password Grant" flows: password: - tokenUrl: 'https://login.bib.dk/oauth/token' - scopes: { } + tokenUrl: "https://login.bib.dk/oauth/token" + scopes: {} security: - - - oauth: [] + - oauth: [] tags: [] diff --git a/lib/types/session.ts b/lib/types/session.ts index feb03b26..cc44d87c 100644 --- a/lib/types/session.ts +++ b/lib/types/session.ts @@ -1,7 +1,7 @@ -import { TokenSet } from "openid-client"; +import { TokenSet } from "openid-client" -export type TSessionType = "adgangsplatformen" | "unilogin" | "anonymous"; +export type TSessionType = "adgangsplatformen" | "unilogin" | "anonymous" -export type TApiType = "dpl-cms"; +export type TApiType = "dpl-cms" -export type TTokenSet = TokenSet & {id_token: string, refresh_expires_in: number}; +export type TTokenSet = TokenSet & { id_token: string; refresh_expires_in: number } diff --git a/package.json b/package.json index ed828761..05e9bbf4 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "build": "next build", "start": "next start", "lint": "next lint", + "format:check": "prettier --check .", + "format:write": "prettier --write .", "test:unit": "vitest", "codegen:graphql": "graphql-codegen --config codegen.ts", "codegen:all-rest-services": "orval", @@ -73,6 +75,7 @@ "@vitejs/plugin-react": "^4.3.2", "eslint": "^8.0.0", "eslint-config-next": "14.2.13", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-storybook": "^0.10.1", "jsdom": "^25.0.1", "next-test-api-route-handler": "^4.0.12", diff --git a/postcss.config.mjs b/postcss.config.mjs index 1a69fd2a..0dc456ad 100644 --- a/postcss.config.mjs +++ b/postcss.config.mjs @@ -3,6 +3,6 @@ const config = { plugins: { tailwindcss: {}, }, -}; +} -export default config; +export default config diff --git a/vitest.config.ts b/vitest.config.ts index a7323161..f00cd0a5 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,18 +1,18 @@ -import env from '@next/env'; -import react from '@vitejs/plugin-react' -import tsconfigPaths from 'vite-tsconfig-paths' -import { defineConfig } from 'vitest/config' -const { loadEnvConfig } = env; +import env from "@next/env" +import react from "@vitejs/plugin-react" +import tsconfigPaths from "vite-tsconfig-paths" +import { defineConfig } from "vitest/config" + +const { loadEnvConfig } = env loadEnvConfig(process.cwd()) export default defineConfig({ - plugins: [react(), tsconfigPaths()], test: { - environment: 'jsdom', + environment: "jsdom", alias: { - '@/': new URL('./', import.meta.url).pathname, + "@/": new URL("./", import.meta.url).pathname, }, }, }) diff --git a/yarn.lock b/yarn.lock index 48361426..66162c4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6199,6 +6199,11 @@ eslint-config-next@14.2.13: eslint-plugin-react "^7.33.2" eslint-plugin-react-hooks "^4.5.0 || 5.0.0-canary-7118f5dd7-20230705" +eslint-config-prettier@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" + integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw== + eslint-import-resolver-node@^0.3.6, eslint-import-resolver-node@^0.3.9: version "0.3.9" resolved "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz" @@ -10136,7 +10141,16 @@ string-env-interpolation@^1.0.1: resolved "https://registry.npmjs.org/string-env-interpolation/-/string-env-interpolation-1.0.1.tgz" integrity sha512-78lwMoCcn0nNu8LszbP1UA7g55OeE4v7rCeWnM5B453rnNr4aq+5it3FEYtZrSEiMvHZOZ9Jlqb0OD0M2VInqg== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -10231,7 +10245,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -11199,7 +11220,7 @@ word-wrap@^1.2.5: resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -11217,6 +11238,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz"