Skip to content

Commit

Permalink
Merge pull request #1094 from danskernesdigitalebibliotek/release/for…
Browse files Browse the repository at this point in the history
…m-sprint-11

Formidling sprint 11
  • Loading branch information
kasperg authored Apr 16, 2024
2 parents f006146 + 6346c6a commit 1a9f9df
Show file tree
Hide file tree
Showing 122 changed files with 3,477 additions and 2,533 deletions.
2 changes: 1 addition & 1 deletion orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default defineConfig({
prettier: true
},
input: {
target: "https://cover.dandigbib.org/api/v2/spec.yaml",
target: "https://cover.dandigbib.org/spec.yaml",
converterOptions: {
indent: 2
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"cypress:open": "cypress open",
"codegen:dbc:gateway": "CODEGEN_SCHEMA_PROFILE=next graphql-codegen -r dotenv/config --config dbc-gateway.codegen.yml",
"codegen:rest-services": "orval",
"codegen:client:fbs": "orval --project fbsAdapter",
"codegen:client:cover": "orval --project coverService",
"codegen:client:publizon": "orval --project publizonAdapter",
"codegen:client:fbs": "rm -rf src/core/fbs/model/*.* && orval --project fbsAdapter",
"codegen:client:cover": "rm -rf src/core/cover-service-api/model/*.* && orval --project coverService",
"codegen:client:publizon": "rm -rf src/core/publizon/model/*.* && orval --project publizonAdapter",
"codegen:client:dpl-cms": "rm -rf src/core/dpl-cms/model/*.* && orval --project dplCms",
"post-process-generated-graphql": "ts-node ./scripts/post-process-generated-graphql.ts"
},
Expand Down Expand Up @@ -144,7 +144,7 @@
"prop-types": "Since we use former ddb-react components that depend on prop-types we keep this. Should be removed when usage of prop-types is deprecated."
},
"dependencies": {
"@danskernesdigitalebibliotek/dpl-design-system": "^2024.15.0-25f5debbe4757dda1a1324bdd773fa6d9381bd27",
"@danskernesdigitalebibliotek/dpl-design-system": "^2024.16.0-bc3c62df13c140271e26a5d5be9c9c23de13b1bf",
"@fullcalendar/core": "^6.1.11",
"@fullcalendar/daygrid": "^6.1.11",
"@fullcalendar/interaction": "^6.1.11",
Expand Down
1 change: 1 addition & 0 deletions src/apps/opening-hours-editor/DialogFormEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const DialogFormEdit: React.FC<DialogFormEditProps> = ({
openingHoursCategories={openingHoursCategories}
>
<button
data-cy="opening-hours-editor-form__remove"
className="opening-hours-editor-form__remove"
type="button"
tabIndex={0}
Expand Down
10 changes: 9 additions & 1 deletion src/apps/opening-hours-editor/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,19 @@ const EventForm: React.FC<EventFormProps> = ({
};

return (
<form onSubmit={handleSubmit} className="opening-hours-editor-form">
<form
onSubmit={handleSubmit}
className="opening-hours-editor-form"
data-cy="opening-hours-editor-form"
>
<label
className="opening-hours-editor-form__label"
htmlFor="event-form-title"
>
{t("openingHoursEventFormTitleText")}
</label>
<select
data-cy="opening-hours-editor-form-select"
className="opening-hours-editor-form__select"
id="event-form-title"
value={category?.title}
Expand All @@ -84,6 +89,7 @@ const EventForm: React.FC<EventFormProps> = ({
{t("openingHoursEventFormStartTimeText")}
</label>
<input
data-cy="opening-hours-editor-form-start-time"
className="opening-hours-editor-form__time-input"
id="event-form-start-time"
type="time"
Expand All @@ -97,6 +103,7 @@ const EventForm: React.FC<EventFormProps> = ({
{t("openingHoursEventFormEndTimeText")}
</label>
<input
data-cy="opening-hours-editor-form-end-time"
className="opening-hours-editor-form__time-input"
id="event-form-end-time"
type="time"
Expand All @@ -107,6 +114,7 @@ const EventForm: React.FC<EventFormProps> = ({
/>
{children}
<button
data-cy="opening-hours-editor-form-submit"
type="submit"
className="opening-hours-editor-form__submit"
disabled={isSameTime}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/opening-hours-editor/OpeningHoursEditor.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import serviceUrlArgs from "../../core/storybook/serviceUrlArgs";
import OpeningHoursEditor from "./OpeningHoursEditor.entry";

export default {
title: "Apps / OpeningHoursEditor",
title: "Apps / Opening Hours Editor",
component: OpeningHoursEditor,
argTypes: {
...serviceUrlArgs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const OpeningHoursEditorEventContent: React.FC<
> = ({ eventInput }) => {
const { event } = eventInput;
return (
<div className="opening-hours-editor-event-content">
<div
className="opening-hours-editor-event-content"
data-cy="opening-hours-editor-event-content"
>
<b>{event.title}</b>
<div>
{extractTime(event.start)} - {extractTime(event.end)}
Expand Down
11 changes: 6 additions & 5 deletions src/apps/opening-hours/OpeningHourWeekList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import dayjs from "dayjs";
import "dayjs/locale/da";
import React from "react";
import { useText } from "../../core/utils/text";
import OpeningHourWeekListSkeleton from "./OpeningHourWeekListSkeleton";
import OpeningHoursDayEntry from "./OpeningHoursDayEntry";
import {
GroupedOpeningHours,
formatDateToWeekday
} from "./OpeningHoursHelpers";
import OpeningHourWeekListSkeleton from "./OpeningHourWeekListSkeleton";

interface OpeningHoursWeekListProps {
data: GroupedOpeningHours;
Expand All @@ -17,10 +18,12 @@ const OpeningHoursWeekList: React.FC<OpeningHoursWeekListProps> = ({
data,
isLoading
}) => {
const t = useText();

return isLoading ? (
<OpeningHourWeekListSkeleton />
) : (
<ul className="opening-hours__content">
<ul className="opening-hours__content" data-cy="opening-hours-week-list">
{data.map(({ dateTime, openingHourEntries }) => {
const dateAsWeekday = formatDateToWeekday(dateTime);
const formattedDateForDisplay = dayjs(dateTime).format("DD/MM");
Expand All @@ -39,9 +42,7 @@ const OpeningHoursWeekList: React.FC<OpeningHoursWeekListProps> = ({
))}
</ul>
) : (
<p>
Biblioteket er <strong>lukket</strong> denne dag.
</p>
<p>{t("libraryIsClosedText")}</p>
)}
</li>
);
Expand Down
4 changes: 4 additions & 0 deletions src/apps/opening-hours/OpeningHours.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default {
defaultValue: "Week",
control: { type: "text" }
},
libraryIsClosedText: {
defaultValue: "The library is closed this day",
control: { type: "text" }
},
openingHoursHeadingText: {
defaultValue: "Opening hours",
control: { type: "text" }
Expand Down
2 changes: 2 additions & 0 deletions src/apps/opening-hours/OpeningHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const OpeningHours: React.FC<OpeningHoursProps> = ({
</h2>
<div className="opening-hours__navigation-controls">
<button
data-cy="opening-hours-previous-week-button"
className="opening-hours__navigation-control"
aria-label={previousWeekString}
onClick={navigateToPreviousWeek}
Expand All @@ -63,6 +64,7 @@ const OpeningHours: React.FC<OpeningHoursProps> = ({
</button>
<div className="opening-hours__week-display">{currentWeekString}</div>
<button
data-cy="opening-hours-next-week-button"
className="opening-hours__navigation-control opening-hours__navigation-control--next"
aria-label={nextWeekString}
onClick={navigateToNextWeek}
Expand Down
17 changes: 10 additions & 7 deletions src/apps/recommended-material/RecommendedMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { DisplayMaterialType } from "../../core/utils/types/material-type";
import { useUrls } from "../../core/utils/url";
import { getManifestationBasedOnType } from "../material/helper";
import RecommendedMaterialSkeleton from "./RecommendedMaterialSkeleton";
import Link from "../../components/atoms/links/Link";

export type RecommendedMaterialProps = {
wid: WorkId;
Expand Down Expand Up @@ -98,18 +99,20 @@ const RecommendedMaterial: React.FC<RecommendedMaterialProps> = ({
shadow="medium"
/>
<div className="recommended-material__texts">
<p
<Link
href={materialFullUrl}
className="recommended-material__description"
data-cy="recommended-description"
dataCy="recommended-description"
>
{fullTitle}
</p>
<p
</Link>
<Link
href={materialFullUrl}
className="recommended-material__author"
data-cy="recommended-author"
dataCy="recommended-author"
>
{author}{" "}
</p>
{author}
</Link>
</div>
</div>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/reservation/ReservationModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ export const ReservationModalBody = ({
// This state is used to show the success or error modal.
setReservationResponse(res);
// Because after a successful reservation the holdings (reservations) are updated.
queryClient.invalidateQueries(getGetHoldingsV3QueryKey());
queryClient.invalidateQueries(
getGetHoldingsV3QueryKey({ recordid: faustIds })
);
}
}
);
Expand Down
81 changes: 51 additions & 30 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.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -8,58 +8,52 @@ The service is provided by [Det Digitale Folkebibliotek](https://detdigitalefolk
Authentication is done via OAuth2 against auth.dbc.dk. To obtain a valid token follow the instructions here: [Open Platform](https://openplatform.dbc.dk/v3/). To use the "Authorize" option in this tool use your 'client_id' and 'client_secret' and fill in '@agency' (e.g. '@123456') for both username and password.
* OpenAPI spec version: 2.0
*/
import {
useQuery,
UseQueryOptions,
import { useQuery } from "react-query";
import type {
QueryFunction,
UseQueryResult,
QueryKey
QueryKey,
UseQueryOptions,
UseQueryResult
} from "react-query";
import type { Cover, GetCoverCollectionParams } from "./model";
import { fetcher, ErrorType, BodyType } from "./mutator/fetcher";

type AwaitedInput<T> = PromiseLike<T> | T;

type Awaited<O> = O extends AwaitedInput<infer T> ? T : never;
import { fetcher } from "./mutator/fetcher";
import type { ErrorType } from "./mutator/fetcher";

/**
* Get covers by identifier in specific image format(s), specific image size(s) and with or without generic covers.
* @summary Search multiple covers
*/
export const getCoverCollection = (
params?: GetCoverCollectionParams,
params: GetCoverCollectionParams,
signal?: AbortSignal
) => {
return fetcher<Cover[]>({
url: `/api/v2/covers`,
method: "get",
signal,
params
method: "GET",
params,
signal
});
};

export const getGetCoverCollectionQueryKey = (
params?: GetCoverCollectionParams
) => [`/api/v2/covers`, ...(params ? [params] : [])];

export type GetCoverCollectionQueryResult = NonNullable<
Awaited<ReturnType<typeof getCoverCollection>>
>;
export type GetCoverCollectionQueryError = ErrorType<void>;
params: GetCoverCollectionParams
) => {
return [`/api/v2/covers`, ...(params ? [params] : [])] as const;
};

export const useGetCoverCollection = <
export const getGetCoverCollectionQueryOptions = <
TData = Awaited<ReturnType<typeof getCoverCollection>>,
TError = ErrorType<void>
>(
params?: GetCoverCollectionParams,
params: GetCoverCollectionParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof getCoverCollection>>,
TError,
TData
>;
}
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
) => {
const { query: queryOptions } = options ?? {};

const queryKey =
Expand All @@ -69,14 +63,41 @@ export const useGetCoverCollection = <
Awaited<ReturnType<typeof getCoverCollection>>
> = ({ signal }) => getCoverCollection(params, signal);

const query = useQuery<
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
Awaited<ReturnType<typeof getCoverCollection>>,
TError,
TData
>(queryKey, queryFn, queryOptions);
> & { queryKey: QueryKey };
};

export type GetCoverCollectionQueryResult = NonNullable<
Awaited<ReturnType<typeof getCoverCollection>>
>;
export type GetCoverCollectionQueryError = ErrorType<void>;

return {
queryKey,
...query
/**
* @summary Search multiple covers
*/
export const useGetCoverCollection = <
TData = Awaited<ReturnType<typeof getCoverCollection>>,
TError = ErrorType<void>
>(
params: GetCoverCollectionParams,
options?: {
query?: UseQueryOptions<
Awaited<ReturnType<typeof getCoverCollection>>,
TError,
TData
>;
}
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
const queryOptions = getGetCoverCollectionQueryOptions(params, options);

const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
queryKey: QueryKey;
};

query.queryKey = queryOptions.queryKey;

return query;
};
6 changes: 3 additions & 3 deletions 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.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -8,11 +8,11 @@ The service is provided by [Det Digitale Folkebibliotek](https://detdigitalefolk
Authentication is done via OAuth2 against auth.dbc.dk. To obtain a valid token follow the instructions here: [Open Platform](https://openplatform.dbc.dk/v3/). To use the "Authorize" option in this tool use your 'client_id' and 'client_secret' and fill in '@agency' (e.g. '@123456') for both username and password.
* OpenAPI spec version: 2.0
*/
import type { CoverType } from "./coverType";
import type { CoverImageUrls } from "./coverImageUrls";
import type { CoverType } from "./coverType";

export interface Cover {
id?: string;
type?: CoverType;
imageUrls?: CoverImageUrls;
type?: CoverType;
}
10 changes: 7 additions & 3 deletions 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.8.1 🍺
* Generated by orval v6.26.0 🍺
* Do not edit manually.
* DDF Cover Service
* This service provides covers for library materials indexed by isbn, issn, faust, pid.
Expand All @@ -12,8 +12,12 @@ import type { ImageUrl } from "./imageUrl";

export type CoverImageUrls = {
default?: ImageUrl;
large?: ImageUrl;
medium?: ImageUrl;
"medium-large"?: ImageUrl;
original?: ImageUrl;
small?: ImageUrl;
medium?: ImageUrl;
large?: ImageUrl;
"small-medium"?: ImageUrl;
"x-small"?: ImageUrl;
"xx-small"?: ImageUrl;
};
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.8.1 🍺
* Generated by orval v6.26.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 1a9f9df

Please sign in to comment.