Skip to content

Commit

Permalink
Rename orderid to lowercase
Browse files Browse the repository at this point in the history
This caused issues when passing the URL parameter from Drupal into the `Reader` app.
  • Loading branch information
kasperbirch1 committed Nov 27, 2024
1 parent f2bf874 commit d95ae06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/apps/reader/Reader.entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { withUrls } from "../../core/utils/url";
import { withText } from "../../core/utils/text";
import Reader, { ReaderType } from "../../components/reader-player/Reader";

const ReaderEntry: React.FC<ReaderType> = ({ identifier, orderId }) => {
return <Reader identifier={identifier} orderId={orderId} />;
const ReaderEntry: React.FC<ReaderType> = ({ identifier, orderid }) => {
return <Reader identifier={identifier} orderid={orderid} />;
};

export default withConfig(withUrls(withText(ReaderEntry)));
4 changes: 2 additions & 2 deletions src/components/reader-player/Reader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const meta: Meta<typeof Reader> = {
identifier: {
control: { type: "text" }
},
orderId: {
orderid: {
control: { type: "text" }
}
}
Expand All @@ -25,5 +25,5 @@ export const WithIdentifier: Story = {

// Works only if the matrial is reserved
export const WithOrderId: Story = {
render: () => <Reader orderId="97cb3a6f-e23b-41ad-97ca-e939541feba7" />
render: () => <Reader orderid="97cb3a6f-e23b-41ad-97ca-e939541feba7" />
};
13 changes: 7 additions & 6 deletions src/components/reader-player/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@ import { appendAsset, readerAssets, removeAppendedAssets } from "./helper";

export type ReaderType = {
identifier?: string;
orderId?: string;
// orderid must be in lowercase bacause its comes from the url / Drupal
orderid?: string;
};

const Reader: React.FC<ReaderType> = ({ identifier, orderId }: ReaderType) => {
const Reader: React.FC<ReaderType> = ({ identifier, orderid }: ReaderType) => {
useEffect(() => {
readerAssets.forEach(appendAsset);

return () => {
removeAppendedAssets();
};
}, [identifier, orderId]);
}, [identifier, orderid]);

const readerStyles: CSSProperties = {
height: "100vh"
};

if (orderId) {
if (orderid) {
return (
<div
style={readerStyles}
id="pubhub-reader"
// eslint-disable-next-line react/no-unknown-property
order-id={orderId}
order-id={orderid}
// eslint-disable-next-line react/no-unknown-property, no-script-url
close-href="javascript:window.history.back()"
/>
Expand All @@ -48,7 +49,7 @@ const Reader: React.FC<ReaderType> = ({ identifier, orderId }: ReaderType) => {
}

// eslint-disable-next-line no-console
console.warn("No identifier or orderId provided for the Reader app.");
console.warn("No identifier or orderid provided for the Reader app.");
return null;
};

Expand Down

0 comments on commit d95ae06

Please sign in to comment.