Skip to content

Commit

Permalink
Merge branch 'develop' into DDFHER-83-implementer-nyt-beholdnings-end…
Browse files Browse the repository at this point in the history
…point
  • Loading branch information
kasperbirch1 committed Nov 28, 2024
2 parents 6b0c399 + 92fec11 commit 86f2f8d
Show file tree
Hide file tree
Showing 189 changed files with 2,684 additions and 2,774 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ updates:
- "redux-persist"
storybook:
patterns:
- "storybook"
- "@storybook/*"
testing-library:
patterns:
Expand Down
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@
"@chromatic-com/storybook": "^3",
"@csstools/postcss-sass": "^5.1.1",
"@cypress/browserify-preprocessor": "^3.0.2",
"@cypress/code-coverage": "^3.13.6",
"@graphql-codegen/add": "^3.1.1",
"@graphql-codegen/cli": "^2.6.2",
"@graphql-codegen/introspection": "^2.1.1",
"@graphql-codegen/typescript": "^2.4.11",
"@graphql-codegen/typescript-graphql-files-modules": "^2.1.1",
"@graphql-codegen/typescript-operations": "^2.4.0",
"@graphql-codegen/typescript-react-query": "^3.5.12",
"@cypress/code-coverage": "^3.13.7",
"@graphql-codegen/add": "^5.0.3",
"@graphql-codegen/cli": "^5.0.3",
"@graphql-codegen/introspection": "^4.0.3",
"@graphql-codegen/typescript": "^4.1.1",
"@graphql-codegen/typescript-graphql-files-modules": "^3.0.0",
"@graphql-codegen/typescript-operations": "^4.3.1",
"@graphql-codegen/typescript-react-query": "^6.1.0",
"@graphql-typed-document-node/core": "^3.1.1",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@namics/stylelint-bem": "^10.1.0",
"@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-queryparams": "^7.0.1",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/react": "^8.2.9",
"@storybook/react-webpack5": "^8.4.2",
"@storybook/react-webpack5": "^8.4.5",
"@testing-library/dom": "^9.3.4",
"@testing-library/react": "^14.2.2",
"@testing-library/react-hooks": "^8.0.1",
Expand All @@ -81,13 +81,13 @@
"@types/react-redux": "^7.1.24",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^7.16.0",
"@vitest/coverage-istanbul": "^2.1.4",
"@vitest/coverage-istanbul": "^2.1.5",
"autoprefixer": "^10.4.20",
"babel-loader": "^9.2.1",
"babel-plugin-istanbul": "^7.0.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"caniuse-lite": "^1.0.30001680",
"caniuse-lite": "^1.0.30001684",
"change-case-all": "^2.1.0",
"chokidar-cli": "^3.0.0",
"concurrently": "^9.1.0",
Expand Down Expand Up @@ -115,22 +115,22 @@
"markdownlint-cli2": "^0.4.0",
"mutationobserver-shim": "^0.3.7",
"nyc": "^17.1.0",
"orval": "^6.26.0",
"postcss": "^8.4.48",
"orval": "^7.2.0",
"postcss": "^8.4.49",
"postcss-cli": "^11.0.0",
"postcss-loader": "^8.1.1",
"postcss-scss": "^4.0.9",
"prettier": "^2.6.2",
"replace-in-file": "^6.3.2",
"sass": "^1.80.6",
"sass": "^1.81.0",
"source-map-support": "^0.5.21",
"storybook": "^8.4.2",
"storybook": "^8.4.5",
"style-loader": "^4.0.0",
"stylelint": "^15.11.0",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-recommended-scss": "^6.0.0",
"stylelint-prettier": "^2.0.0",
"stylelint-scss": "^6.8.1",
"stylelint-scss": "^6.10.0",
"stylelint-webpack-plugin": "^5.0.1",
"svg-url-loader": "^8.0.0",
"ts-node": "^10.9.2",
Expand All @@ -153,7 +153,7 @@
"@fullcalendar/timegrid": "^6.1.15",
"@reach/alert": "^0.18.0",
"@reach/dialog": "^0.18.0",
"@reduxjs/toolkit": "^1.9.7",
"@reduxjs/toolkit": "^2.3.0",
"@types/lodash": "^4.17.5",
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
Expand All @@ -169,13 +169,13 @@
"react-error-boundary": "^4.0.0",
"react-flatpickr": "^3.10.13",
"react-query": "^3.39.3",
"react-redux": "^8.1.3",
"react-redux": "^9.1.2",
"react-use": "^17.5.1",
"redux": "^4.2.1",
"redux": "^5.0.1",
"redux-persist": "^6.0.0",
"unfetch": "^5.0.0"
},
"peerDependencies": {
"postcss": "^8.4.48"
"postcss": "^8.4.49"
}
}
1 change: 1 addition & 0 deletions src/apps/search-result/search-result.entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface SearchResultEntryTextProps {
facetDk5Text: string;
facetFictionalCharactersText: string;
facetFictionNonfictionText: string;
facetGamePlatformText: string;
facetGenreAndFormText: string;
facetMainLanguagesText: string;
facetMaterialTypesText: string;
Expand Down
5 changes: 5 additions & 0 deletions src/apps/search-result/search-result.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ const meta: Meta<typeof SearchResultEntry> = {
description: "Genre and form text",
control: { type: "text" }
},
facetGamePlatformText: {
description: "Game platform text",
control: { type: "text" }
},
facetMainLanguagesText: {
description: "Main languages text",
control: { type: "text" }
Expand Down Expand Up @@ -239,6 +243,7 @@ export const Primary: Story = {
facetDk5Text: "Dk5",
facetFictionalCharactersText: "Fictional characters",
facetFictionNonfictionText: "Fiction or nonfiction",
facetGamePlatformText: "Game platform",
facetGenreAndFormText: "Genre and form",
facetMainLanguagesText: "Main languages",
facetMaterialTypesText: "Material types",
Expand Down
32 changes: 22 additions & 10 deletions src/components/button-favourite/button-favourite.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useCallback, useEffect, useState } from "react";
import { useQueryClient } from "react-query";
import LoadIcon from "@danskernesdigitalebibliotek/dpl-design-system/build/icons/collection/Reload.svg";
import { useQueryClient } from "react-query";
import { IconFavourite } from "../icon-favourite/icon-favourite";
import {
removeItem,
useHasItem
getGetListQueryKey,
useHasItem,
useRemoveItem
} from "../../core/material-list-api/material-list";
import { useText } from "../../core/utils/text";
import { Pid, WorkId } from "../../core/utils/types/ids";
Expand All @@ -25,20 +26,23 @@ const ButtonFavourite: React.FC<ButtonFavouriteProps> = ({
darkBackground,
title
}) => {
const queryClient = useQueryClient();
const [fillState, setFillState] = useState<boolean>(false);
const [isLoadingHeart, setIsLoadingHeart] = useState<boolean>(true);
const t = useText();
const { mutate } = useHasItem();
const { mutate: hasItem } = useHasItem();
const { mutate: removeItem } = useRemoveItem();
const { track } = useStatistics();
const queryClient = useQueryClient();

const listId = "default";

useEffect(() => {
// The heart icon needs to change into a loading icon while the material
// is being removed from the favorite list
setIsLoadingHeart(true);
mutate(
hasItem(
{
listId: "default",
listId,
itemId: id
},
{
Expand All @@ -55,13 +59,21 @@ const ButtonFavourite: React.FC<ButtonFavouriteProps> = ({
}
}
);
}, [id, mutate]);
}, [id, hasItem]);

const handleClick = useCallback(
(e: React.MouseEvent<HTMLButtonElement>) => {
if (fillState) {
removeItem("default", id, queryClient);
setFillState(false);
removeItem(
{ listId, itemId: id },
{
onSuccess: () => {
// Invalidate the query to remove any faved materials from favorites list
queryClient.invalidateQueries(getGetListQueryKey(listId));
}
}
);
} else {
track("click", {
id: statistics.addToFavorites.id,
Expand All @@ -75,7 +87,7 @@ const ButtonFavourite: React.FC<ButtonFavouriteProps> = ({
// this wont interfere with their click handler.
e.stopPropagation();
},
[addToListRequest, fillState, id, queryClient, track]
[addToListRequest, fillState, id, removeItem, track, queryClient]
);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useCallback, useId } from "react";
import { useDispatch } from "react-redux";
import { useQueryClient } from "react-query";
import { useText } from "../../../core/utils/text";
import { WorkId } from "../../../core/utils/types/ids";
import Arrow from "../../atoms/icons/arrow/arrow";
Expand Down Expand Up @@ -75,7 +74,6 @@ const CardListItem: React.FC<CardListItemProps> = ({
const bookManifestation = getFirstBookManifestation(manifestations);

const dispatch = useDispatch<TypedDispatch>();
const queryClient = useQueryClient();
const author = creatorsToString(flattenCreators(creators), t);
const manifestationPids = getManifestationsPids(manifestations);
const materialFullUrl = constructMaterialUrl(
Expand Down Expand Up @@ -106,7 +104,7 @@ const CardListItem: React.FC<CardListItemProps> = ({
dispatch(
guardedRequest({
type: "addFavorite",
args: { id, queryClient },
args: { id },
app: "search-result"
})
);
Expand Down
3 changes: 3 additions & 0 deletions src/components/facet-browser/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export const getFacetFieldTranslation = (name: FacetFieldEnum) => {
return "facetWorkTypesText";
case FacetFieldEnum.Year.toLowerCase():
return "facetYearText";
// TODO: Replace this case when FBI API specs have updated
case "gameplatform":
return "facetGamePlatformText";
default:
return invalidSwitchCase<string>(name as never);
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/material/MaterialHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useId } from "react";
import { useDispatch } from "react-redux";
import { useDeepCompareEffect } from "react-use";
import { useQueryClient } from "react-query";
import { guardedRequest } from "../../core/guardedRequests.slice";
import { TypedDispatch } from "../../core/store";
import {
Expand Down Expand Up @@ -65,12 +64,11 @@ const MaterialHeader: React.FC<MaterialHeaderProps> = ({
const { itemRef, hasBeenVisible: showItem } = useItemHasBeenVisible();
const t = useText();
const dispatch = useDispatch<TypedDispatch>();
const queryClient = useQueryClient();
const addToListRequest = (id: ButtonFavouriteId) => {
dispatch(
guardedRequest({
type: "addFavorite",
args: { id, queryClient },
args: { id },
app: "material"
})
);
Expand Down
4 changes: 1 addition & 3 deletions src/components/simple-material/SimpleMaterial.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react";
import { FC } from "react";
import { useDispatch } from "react-redux";
import { useQueryClient } from "react-query";
import ButtonFavourite, {
ButtonFavouriteId
} from "../button-favourite/button-favourite";
Expand Down Expand Up @@ -35,7 +34,6 @@ const SimpleMaterial: FC<SimpleMaterialProps> = ({
const materialUrl = u("materialUrl");

const dispatch = useDispatch<TypedDispatch>();
const queryClient = useQueryClient();
const materialFullUrl = constructMaterialUrl(materialUrl, workId);

// Create authors string
Expand All @@ -52,7 +50,7 @@ const SimpleMaterial: FC<SimpleMaterialProps> = ({
dispatch(
guardedRequest({
type: "addFavorite",
args: { id, queryClient },
args: { id },
app
})
);
Expand Down
9 changes: 5 additions & 4 deletions src/core/cover-service-api/cover-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down Expand Up @@ -78,7 +78,8 @@ export type GetCoverCollectionQueryError = ErrorType<void>;
/**
* @summary Search multiple covers
*/
export const useGetCoverCollection = <

export function useGetCoverCollection<
TData = Awaited<ReturnType<typeof getCoverCollection>>,
TError = ErrorType<void>
>(
Expand All @@ -90,7 +91,7 @@ export const useGetCoverCollection = <
TData
>;
}
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
const queryOptions = getGetCoverCollectionQueryOptions(params, options);

const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
Expand All @@ -100,4 +101,4 @@ export const useGetCoverCollection = <
query.queryKey = queryOptions.queryKey;

return query;
};
}
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/cover.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/coverImageUrls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/coverType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/getCoverCollectionType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/imageUrl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/imageUrlSize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
2 changes: 1 addition & 1 deletion src/core/cover-service-api/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v6.26.0 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand Down
Loading

0 comments on commit 86f2f8d

Please sign in to comment.