From 7bf74903d27dc78b3b5a5dee53d01a31d7223e6f Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Fri, 6 Oct 2023 20:09:52 +0200 Subject: [PATCH 1/9] Rename loginUrl to userinfoUrl In order to reflect what the purpose of the url actually is. Also use useEffect which is recommended best practise when fetching data in React components. --- .../CreatePatron.dev.tsx | 2 +- .../create-patron-user-info/CreatePatron.tsx | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/apps/create-patron-user-info/CreatePatron.dev.tsx b/src/apps/create-patron-user-info/CreatePatron.dev.tsx index 5f8d1e3a69..584937af1c 100644 --- a/src/apps/create-patron-user-info/CreatePatron.dev.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.dev.tsx @@ -23,7 +23,7 @@ export default { '[\n {\n "branchId":"DK-775120",\n "title":"Højbjerg"\n },\n {\n "branchId":"DK-775122",\n "title":"Beder-Malling"\n },\n {\n "branchId":"DK-775144",\n "title":"Gellerup"\n },\n {\n "branchId":"DK-775167",\n "title":"Lystrup"\n },\n {\n "branchId":"DK-775146",\n "title":"Harlev"\n },\n {\n "branchId":"DK-775168",\n "title":"Skødstrup"\n },\n {\n "branchId":"FBS-751010",\n "title":"Arresten"\n },\n {\n "branchId":"DK-775147",\n "title":"Hasle"\n },\n {\n "branchId":"FBS-751032",\n "title":"Må ikke benyttes"\n },\n {\n "branchId":"FBS-751031",\n "title":"Fjernlager 1"\n },\n {\n "branchId":"DK-775126",\n "title":"Solbjerg"\n },\n {\n "branchId":"FBS-751030",\n "title":"ITK"\n },\n {\n "branchId":"DK-775149",\n "title":"Sabro"\n },\n {\n "branchId":"DK-775127",\n "title":"Tranbjerg"\n },\n {\n "branchId":"DK-775160",\n "title":"Risskov"\n },\n {\n "branchId":"DK-775162",\n "title":"Hjortshøj"\n },\n {\n "branchId":"DK-775140",\n "title":"Åby"\n },\n {\n "branchId":"FBS-751009",\n "title":"Fjernlager 2"\n },\n {\n "branchId":"FBS-751029",\n "title":"Stadsarkivet"\n },\n {\n "branchId":"FBS-751027",\n "title":"Intern"\n },\n {\n "branchId":"FBS-751026",\n "title":"Fælles undervejs"\n },\n {\n "branchId":"FBS-751025",\n "title":"Fællessekretariatet"\n },\n {\n "branchId":"DK-775133",\n "title":"Bavnehøj"\n },\n {\n "branchId":"FBS-751024",\n "title":"Fjernlånte materialer"\n },\n {\n "branchId":"DK-775100",\n "title":"Hovedbiblioteket"\n },\n {\n "branchId":"DK-775170",\n "title":"Trige"\n },\n {\n "branchId":"DK-775150",\n "title":"Tilst"\n },\n {\n "branchId":"DK-775130",\n "title":"Viby"\n },\n {\n "branchId":"DK-775164",\n "title":"Egå"\n }\n]', control: { type: "text" } }, - loginUrl: { + userinfoUrl: { defaultValue: "https://login.bib.dk/userinfo", control: { type: "text" } }, diff --git a/src/apps/create-patron-user-info/CreatePatron.tsx b/src/apps/create-patron-user-info/CreatePatron.tsx index 01382ffacd..ae67dca4bd 100644 --- a/src/apps/create-patron-user-info/CreatePatron.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.tsx @@ -1,4 +1,4 @@ -import React, { useState, FC } from "react"; +import React, { useState, FC, useEffect } from "react"; import UserInfo from "./UserInfo"; import { useUrls } from "../../core/utils/url"; @@ -8,18 +8,24 @@ interface CreatePatronProps { const CreatePatron: FC = ({ userToken }) => { const [cpr, setCpr] = useState(null); - const { loginUrl } = useUrls(); + const { userinfoUrl } = useUrls(); - fetch(String(loginUrl), { - method: "get", - headers: { Authorization: `Bearer ${userToken}` } - }) - .then((response) => response.json()) - .then((data) => { - if (data?.attributes?.cpr) { - setCpr(data.attributes.cpr); - } - }); + if (!userinfoUrl) { + throw new Error("userinfoUrl is not defined"); + } + + useEffect(() => { + fetch(String(userinfoUrl), { + method: "get", + headers: { Authorization: `Bearer ${userToken}` } + }) + .then((response) => response.json()) + .then((data) => { + if (data?.attributes?.cpr) { + setCpr(data.attributes.cpr); + } + }); + }, [userToken, userinfoUrl]); if (cpr === null) return null; From 99312d25b45b648362c194e4db1e41143bab558e Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Fri, 6 Oct 2023 20:59:51 +0200 Subject: [PATCH 2/9] Add check if user token is set If the user token is not set the user should be asked to log in. --- .../create-patron-user-info/CreatePatron.entry.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/apps/create-patron-user-info/CreatePatron.entry.tsx b/src/apps/create-patron-user-info/CreatePatron.entry.tsx index bccc2d157d..ba2d1ca652 100644 --- a/src/apps/create-patron-user-info/CreatePatron.entry.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.entry.tsx @@ -47,10 +47,21 @@ export interface CreatePatronProps extends CreatePatronConfigProps, CreatePatronUrlProps, CreatePatronTextProps { - userToken: string; + userToken?: string; } const CreatePatronEntry: FC = ({ userToken }) => { + if (!userToken) { + return ( + <> +

Please Log ind..

+

+ When the flash message/info bar has been implemented, we will use it + here to tell the user to log in. +

+ + ); + } return ; }; From 52424823f463f3bdedf37d192665824bad70628c Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Sat, 7 Oct 2023 16:45:29 +0200 Subject: [PATCH 3/9] Refactor contact info input And add a test for wrapping the contact info depending on that the input fields should be shown inline or not. --- .../contact-info-section/ContactInfoEmail.tsx | 52 ++++++++++ .../ContactInfoInputs.tsx | 46 +++++++++ .../contact-info-section/ContactInfoPhone.tsx | 52 ++++++++++ .../ContactInfoSection.tsx | 94 +++++-------------- .../__snapshots__/ContactInfoInputs.tsx.snap | 36 +++++++ src/components/contact-info-section/types.ts | 3 + .../__snapshots__/contact-info.test.tsx.snap | 36 +++++++ src/tests/unit/contact-info.test.tsx | 36 +++++++ 8 files changed, 282 insertions(+), 73 deletions(-) create mode 100644 src/components/contact-info-section/ContactInfoEmail.tsx create mode 100644 src/components/contact-info-section/ContactInfoInputs.tsx create mode 100644 src/components/contact-info-section/ContactInfoPhone.tsx create mode 100644 src/components/contact-info-section/__snapshots__/ContactInfoInputs.tsx.snap create mode 100644 src/components/contact-info-section/types.ts create mode 100644 src/tests/unit/__snapshots__/contact-info.test.tsx.snap create mode 100644 src/tests/unit/contact-info.test.tsx diff --git a/src/components/contact-info-section/ContactInfoEmail.tsx b/src/components/contact-info-section/ContactInfoEmail.tsx new file mode 100644 index 0000000000..fb47b4269f --- /dev/null +++ b/src/components/contact-info-section/ContactInfoEmail.tsx @@ -0,0 +1,52 @@ +import * as React from "react"; +import { FC } from "react"; +import TextInput from "../atoms/input/TextInput"; +import { PatronSettingsV3, PatronV5 } from "../../core/fbs/model"; +import { useText } from "../../core/utils/text"; +import CheckBox from "../checkbox/Checkbox"; +import { ChangePatronProps } from "./types"; + +export interface ContactInfoEmailProps { + className?: string; + patron: PatronV5 | PatronSettingsV3 | null; + changePatron: ChangePatronProps; + showCheckboxes: boolean; + isRequired?: boolean; +} + +const ContactInfoEmail: FC = ({ + className = "", + patron, + changePatron, + showCheckboxes, + isRequired = false +}) => { + const t = useText(); + return ( + <> + changePatron(newEmail, "emailAddress")} + value={patron?.emailAddress} + label={t("patronContactEmailLabelText")} + /> + {showCheckboxes && ( + + changePatron(newReceiveEmail, "receiveEmail") + } + id="email-messages" + selected={patron?.receiveEmail} + disabled={false} + label={t("patronContactEmailCheckboxText")} + /> + )} + + ); +}; + +export default ContactInfoEmail; diff --git a/src/components/contact-info-section/ContactInfoInputs.tsx b/src/components/contact-info-section/ContactInfoInputs.tsx new file mode 100644 index 0000000000..89f4b214f9 --- /dev/null +++ b/src/components/contact-info-section/ContactInfoInputs.tsx @@ -0,0 +1,46 @@ +import clsx from "clsx"; +import * as React from "react"; +import { FC } from "react"; + +export interface ContactInfoInputsProps { + isInline: boolean; + children: React.ReactNode; + dataCy?: string; + className?: string; +} + +// This component wraps the input fields for the contact info section +// depending on the isInline prop. +const ContactInfoInputs: FC = ({ + isInline, + children, + dataCy = "contact-info-input", + className = undefined +}) => { + if (!isInline) { + return ( +
+ {children} +
+ ); + } + + const renderableChildren = React.Children.toArray(children); + return ( +
+ {renderableChildren.map((child, i) => { + const childClassName = clsx("patron__input--desktop", { + "mr-16": i < renderableChildren.length - 1 + }); + return
{child}
; + })} +
+ ); +}; + +export default ContactInfoInputs; diff --git a/src/components/contact-info-section/ContactInfoPhone.tsx b/src/components/contact-info-section/ContactInfoPhone.tsx new file mode 100644 index 0000000000..6237e83138 --- /dev/null +++ b/src/components/contact-info-section/ContactInfoPhone.tsx @@ -0,0 +1,52 @@ +import * as React from "react"; +import { FC } from "react"; +import TextInput from "../atoms/input/TextInput"; +import { PatronSettingsV3, PatronV5 } from "../../core/fbs/model"; +import CheckBox from "../checkbox/Checkbox"; +import { useText } from "../../core/utils/text"; +import { ChangePatronProps } from "./types"; + +export interface ContactInfoPhoneProps { + patron: PatronV5 | PatronSettingsV3 | null; + changePatron: ChangePatronProps; + showCheckboxes: boolean; + className?: string; +} + +const ContactInfoPhone: FC = ({ + patron, + changePatron, + showCheckboxes, + className = "" +}) => { + const t = useText(); + return ( + <> + + changePatron(newPhoneNumber, "phoneNumber") + } + value={patron?.phoneNumber} + label={t("patronContactPhoneLabelText")} + /> + {showCheckboxes && ( + + changePatron(newReceiveSms, "receiveSms") + } + id="phone-messages" + selected={patron?.receiveSms} + disabled={false} + label={t("patronContactPhoneCheckboxText")} + /> + )} + + ); +}; + +export default ContactInfoPhone; diff --git a/src/components/contact-info-section/ContactInfoSection.tsx b/src/components/contact-info-section/ContactInfoSection.tsx index 7565d697a8..335a0db24f 100644 --- a/src/components/contact-info-section/ContactInfoSection.tsx +++ b/src/components/contact-info-section/ContactInfoSection.tsx @@ -1,14 +1,12 @@ import React, { FC } from "react"; import clsx from "clsx"; import { PatronV5, PatronSettingsV3 } from "../../core/fbs/model"; -import TextInput from "../atoms/input/TextInput"; -import CheckBox from "../checkbox/Checkbox"; import { useText } from "../../core/utils/text"; import { useConfig } from "../../core/utils/config"; - -export interface ChangePatronProps { - (newValue: string | boolean, key: string): void; -} +import ContactInfoInputs from "./ContactInfoInputs"; +import ContactInfoPhone from "./ContactInfoPhone"; +import ContactInfoEmail from "./ContactInfoEmail"; +import { ChangePatronProps } from "./types"; interface ContactInfoSectionProps { patron: PatronV5 | PatronSettingsV3 | null; @@ -26,64 +24,9 @@ const ContactInfoSection: FC = ({ const t = useText(); const inputsClass = clsx("dpl-input", { input__desktop: inLine }); const config = useConfig(); - const textNotificationsEnabled = + const textNotificationsEnabledConfig = config("textNotificationsEnabledConfig") === "1"; - const phoneNode = ( - <> - - changePatron(newPhoneNumber, "phoneNumber") - } - value={patron?.phoneNumber} - label={t("patronContactPhoneLabelText")} - /> - {showCheckboxes && textNotificationsEnabled && ( - - changePatron(newReceiveSms, "receiveSms") - } - id="phone-messages" - selected={patron?.receiveSms} - disabled={false} - label={t("patronContactPhoneCheckboxText")} - /> - )} - - ); - const emailNode = ( - <> - changePatron(newEmail, "emailAddress")} - value={patron?.emailAddress} - label={t("patronContactEmailLabelText")} - /> - {showCheckboxes && ( - - changePatron(newReceiveEmail, "receiveEmail") - } - id="email-messages" - selected={patron?.receiveEmail} - disabled={false} - label={t("patronContactEmailCheckboxText")} - /> - )} - - ); - return (

@@ -94,17 +37,22 @@ const ContactInfoSection: FC = ({ {t("patronContactInfoBodyText")}

)} - {inLine && ( -
-
{phoneNode}
-
{emailNode}
-
- )} - {!inLine && ( - <> - {phoneNode} {emailNode} - - )} + + + +

); }; diff --git a/src/components/contact-info-section/__snapshots__/ContactInfoInputs.tsx.snap b/src/components/contact-info-section/__snapshots__/ContactInfoInputs.tsx.snap new file mode 100644 index 0000000000..c2591cf8f7 --- /dev/null +++ b/src/components/contact-info-section/__snapshots__/ContactInfoInputs.tsx.snap @@ -0,0 +1,36 @@ +// Vitest Snapshot v1 + +exports[`ContactInfoInputs > Should NOT wrap the input fields if it is NOT inline 1`] = ` +
+

+ One input component +

+

+ Another input component +

+
+`; + +exports[`ContactInfoInputs > Should wrap the input fields if it is inline 1`] = ` +
+
+

+ One input component +

+
+
+

+ Another input component +

+
+
+`; diff --git a/src/components/contact-info-section/types.ts b/src/components/contact-info-section/types.ts new file mode 100644 index 0000000000..ec855d2c17 --- /dev/null +++ b/src/components/contact-info-section/types.ts @@ -0,0 +1,3 @@ +export interface ChangePatronProps { + (newValue: string | boolean, key: string): void; +} diff --git a/src/tests/unit/__snapshots__/contact-info.test.tsx.snap b/src/tests/unit/__snapshots__/contact-info.test.tsx.snap new file mode 100644 index 0000000000..c2591cf8f7 --- /dev/null +++ b/src/tests/unit/__snapshots__/contact-info.test.tsx.snap @@ -0,0 +1,36 @@ +// Vitest Snapshot v1 + +exports[`ContactInfoInputs > Should NOT wrap the input fields if it is NOT inline 1`] = ` +
+

+ One input component +

+

+ Another input component +

+
+`; + +exports[`ContactInfoInputs > Should wrap the input fields if it is inline 1`] = ` +
+
+

+ One input component +

+
+
+

+ Another input component +

+
+
+`; diff --git a/src/tests/unit/contact-info.test.tsx b/src/tests/unit/contact-info.test.tsx new file mode 100644 index 0000000000..f72b3cf513 --- /dev/null +++ b/src/tests/unit/contact-info.test.tsx @@ -0,0 +1,36 @@ +import { describe, expect, it } from "vitest"; +import React from "react"; +import { render } from "@testing-library/react"; +import { configure } from "@testing-library/dom"; +import ContactInfoInputs from "../../components/contact-info-section/ContactInfoInputs"; + +configure({ + testIdAttribute: "data-cy" +}); + +describe("ContactInfoInputs", () => { + it("Should wrap the input fields if it is inline", async () => { + const { getByTestId } = render( + +

One input component

+

Another input component

+
+ ); + + const contactInfoInputs = getByTestId("contact-info-input"); + + expect(contactInfoInputs).toMatchSnapshot(); + }); + it("Should NOT wrap the input fields if it is NOT inline", async () => { + const { getByTestId } = render( + +

One input component

+

Another input component

+
+ ); + + const contactInfoInputs = getByTestId("contact-info-input-inline"); + + expect(contactInfoInputs).toMatchSnapshot(); + }); +}); From 16d7cf6d29b851d15bb8dc1c4f177401f96a1304 Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Sat, 7 Oct 2023 20:56:01 +0200 Subject: [PATCH 4/9] Get the user token from the onse stored in mount We should get the token in the apps in a unified manner not passing it as a prop to the app --- src/apps/create-patron-user-info/CreatePatron.dev.tsx | 4 ---- src/apps/create-patron-user-info/CreatePatron.entry.tsx | 9 +++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/apps/create-patron-user-info/CreatePatron.dev.tsx b/src/apps/create-patron-user-info/CreatePatron.dev.tsx index 584937af1c..8d8cf39b65 100644 --- a/src/apps/create-patron-user-info/CreatePatron.dev.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.dev.tsx @@ -27,10 +27,6 @@ export default { defaultValue: "https://login.bib.dk/userinfo", control: { type: "text" } }, - userToken: { - defaultValue: "", - control: { type: "text" } - }, textNotificationsEnabledConfig: { defaultValue: "1", control: { type: "text" } diff --git a/src/apps/create-patron-user-info/CreatePatron.entry.tsx b/src/apps/create-patron-user-info/CreatePatron.entry.tsx index ba2d1ca652..754152fa71 100644 --- a/src/apps/create-patron-user-info/CreatePatron.entry.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.entry.tsx @@ -3,6 +3,7 @@ import { withConfig } from "../../core/utils/config"; import { withText } from "../../core/utils/text"; import { withUrls } from "../../core/utils/url"; import CreatePatron from "./CreatePatron"; +import getToken, { hasToken } from "../../core/token"; interface CreatePatronConfigProps { pincodeLengthMinConfig: string; @@ -46,11 +47,11 @@ interface CreatePatronTextProps { export interface CreatePatronProps extends CreatePatronConfigProps, CreatePatronUrlProps, - CreatePatronTextProps { - userToken?: string; -} + CreatePatronTextProps {} + +const CreatePatronEntry: FC = () => { + const userToken = hasToken("user") ? getToken("user") : null; -const CreatePatronEntry: FC = ({ userToken }) => { if (!userToken) { return ( <> From 674967848f8544d84a43817d8bb2807a9c44cc54 Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Sun, 8 Oct 2023 12:24:41 +0200 Subject: [PATCH 5/9] Use same way of using required on phone as on email MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in contact info. Just to make things more clear.´ --- src/apps/create-patron-user-info/CreatePatron.entry.tsx | 2 +- src/components/contact-info-section/ContactInfoPhone.tsx | 6 ++++-- src/components/contact-info-section/ContactInfoSection.tsx | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/apps/create-patron-user-info/CreatePatron.entry.tsx b/src/apps/create-patron-user-info/CreatePatron.entry.tsx index 754152fa71..571dff5b7d 100644 --- a/src/apps/create-patron-user-info/CreatePatron.entry.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.entry.tsx @@ -3,7 +3,7 @@ import { withConfig } from "../../core/utils/config"; import { withText } from "../../core/utils/text"; import { withUrls } from "../../core/utils/url"; import CreatePatron from "./CreatePatron"; -import getToken, { hasToken } from "../../core/token"; +import { getToken, hasToken } from "../../core/token"; interface CreatePatronConfigProps { pincodeLengthMinConfig: string; diff --git a/src/components/contact-info-section/ContactInfoPhone.tsx b/src/components/contact-info-section/ContactInfoPhone.tsx index 6237e83138..cebc0e27d7 100644 --- a/src/components/contact-info-section/ContactInfoPhone.tsx +++ b/src/components/contact-info-section/ContactInfoPhone.tsx @@ -11,13 +11,15 @@ export interface ContactInfoPhoneProps { changePatron: ChangePatronProps; showCheckboxes: boolean; className?: string; + isRequired?: boolean; } const ContactInfoPhone: FC = ({ patron, changePatron, showCheckboxes, - className = "" + className = "", + isRequired = false }) => { const t = useText(); return ( @@ -25,7 +27,7 @@ const ContactInfoPhone: FC = ({ changePatron(newPhoneNumber, "phoneNumber") diff --git a/src/components/contact-info-section/ContactInfoSection.tsx b/src/components/contact-info-section/ContactInfoSection.tsx index 335a0db24f..bf79ad33f1 100644 --- a/src/components/contact-info-section/ContactInfoSection.tsx +++ b/src/components/contact-info-section/ContactInfoSection.tsx @@ -43,6 +43,7 @@ const ContactInfoSection: FC = ({ changePatron={changePatron} patron={patron} showCheckboxes={showCheckboxes && textNotificationsEnabledConfig} + isRequired /> Date: Sun, 8 Oct 2023 18:34:51 +0200 Subject: [PATCH 6/9] Correct order of elements in create patron form Maybe I am wrong but things seemed of and messed around. This is my attempt to make things look more sensible. --- src/apps/create-patron-user-info/UserInfo.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/apps/create-patron-user-info/UserInfo.tsx b/src/apps/create-patron-user-info/UserInfo.tsx index beb0598c7e..6e7cfee8d5 100644 --- a/src/apps/create-patron-user-info/UserInfo.tsx +++ b/src/apps/create-patron-user-info/UserInfo.tsx @@ -76,17 +76,17 @@ const UserInfo: FC = ({ cpr }) => { changePatron={changePatron} patron={patron} /> + {t("createPatronChangePickupHeaderText") && ( -

+

{t("createPatronChangePickupHeaderText")}

)} {t("createPatronChangePickupBodyText") && ( -

+

{t("createPatronChangePickupBodyText")}

)} -
Date: Tue, 10 Oct 2023 10:15:47 +0200 Subject: [PATCH 7/9] Swap required user info fields I accidentally swapped the logic. It should be EMAIL that is required. NOT PHONE. --- src/components/contact-info-section/ContactInfoSection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/contact-info-section/ContactInfoSection.tsx b/src/components/contact-info-section/ContactInfoSection.tsx index bf79ad33f1..1969da85c9 100644 --- a/src/components/contact-info-section/ContactInfoSection.tsx +++ b/src/components/contact-info-section/ContactInfoSection.tsx @@ -43,7 +43,6 @@ const ContactInfoSection: FC = ({ changePatron={changePatron} patron={patron} showCheckboxes={showCheckboxes && textNotificationsEnabledConfig} - isRequired /> = ({ changePatron={changePatron} patron={patron} showCheckboxes={showCheckboxes} + isRequired /> From e9b9c830c1f4259db074bd234b1fe1bc475cbc1f Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Tue, 10 Oct 2023 14:33:17 +0200 Subject: [PATCH 8/9] Correcting cypress selector on contact info wrappers --- src/tests/unit/__snapshots__/contact-info.test.tsx.snap | 4 ++-- src/tests/unit/contact-info.test.tsx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tests/unit/__snapshots__/contact-info.test.tsx.snap b/src/tests/unit/__snapshots__/contact-info.test.tsx.snap index c2591cf8f7..42e2dda746 100644 --- a/src/tests/unit/__snapshots__/contact-info.test.tsx.snap +++ b/src/tests/unit/__snapshots__/contact-info.test.tsx.snap @@ -2,7 +2,7 @@ exports[`ContactInfoInputs > Should NOT wrap the input fields if it is NOT inline 1`] = `

One input component @@ -16,7 +16,7 @@ exports[`ContactInfoInputs > Should NOT wrap the input fields if it is NOT inlin exports[`ContactInfoInputs > Should wrap the input fields if it is inline 1`] = `

{ it("Should wrap the input fields if it is inline", async () => { const { getByTestId } = render( - +

One input component

Another input component

); - const contactInfoInputs = getByTestId("contact-info-input"); + const contactInfoInputs = getByTestId("contact-info-input-inline"); expect(contactInfoInputs).toMatchSnapshot(); }); it("Should NOT wrap the input fields if it is NOT inline", async () => { const { getByTestId } = render( - +

One input component

Another input component

); - const contactInfoInputs = getByTestId("contact-info-input-inline"); + const contactInfoInputs = getByTestId("contact-info-input"); expect(contactInfoInputs).toMatchSnapshot(); }); From 7a9a2bcf3c3a6cbf7e6c27af06fbba10e2e44b19 Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Tue, 10 Oct 2023 16:48:02 +0200 Subject: [PATCH 9/9] Do not show anything in create patron app if anonymous The hosting application/site should handle this situation --- .../create-patron-user-info/CreatePatron.entry.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/apps/create-patron-user-info/CreatePatron.entry.tsx b/src/apps/create-patron-user-info/CreatePatron.entry.tsx index 571dff5b7d..76c4f8332d 100644 --- a/src/apps/create-patron-user-info/CreatePatron.entry.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.entry.tsx @@ -52,17 +52,12 @@ export interface CreatePatronProps const CreatePatronEntry: FC = () => { const userToken = hasToken("user") ? getToken("user") : null; + // The application using this app should handle the case where the user is not logged in. + // Eg by returning 403 Forbidden or redirecting to the login page. if (!userToken) { - return ( - <> -

Please Log ind..

-

- When the flash message/info bar has been implemented, we will use it - here to tell the user to log in. -

- - ); + return null; } + return ; };