Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust patron storybook menu to reflect harcoded conf in dpl-cms #858

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"id": "bd783b91-b464-4137-9575-b093008866df",
"name": "Fees (v2)",
"request": {
"url": "/external/agencyid/patron/patronid/fees/v2",
"method": "GET"
"id" : "bd783b91-b464-4137-9575-b093008866df",
"name" : "Fees (v2)",
"request" : {
"url" : "/external/agencyid/patron/patronid/fees/v2?includepaid=false&includenonpayable=true",
"method" : "GET"
},
"response": {
"status": 200,
"body": "[\n {\n \"feeId\": 434536,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 70,\n \"dueDate\": \"2022-05-08\",\n \"creationDate\": \"2022-04-06\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"5237124059\",\n \"recordId\": \"48724566\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5119382558\",\n \"recordId\": \"52518563\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5324175956\",\n \"recordId\": \"38540335\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 434537,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 70,\n \"dueDate\": \"2022-05-08\",\n \"creationDate\": \"2022-04-06\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"3275348197\",\n \"recordId\": \"23790823\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5218297864\",\n \"recordId\": \"45951685\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 434538,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 120,\n \"dueDate\": \"2022-05-08\",\n \"creationDate\": \"2022-04-06\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"5136106556\",\n \"recordId\": \"53067034\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5232011841\",\n \"recordId\": \"54058969\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 306404,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 2.56,\n \"dueDate\": \"2020-04-15\",\n \"creationDate\": \"2019-10-18\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"3839631447\",\n \"recordId\": \"26285283\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 377242,\n \"type\": \"compensation\",\n \"reasonMessage\": \"Erstatning (test)\",\n \"amount\": 1,\n \"dueDate\": \"2021-08-10\",\n \"creationDate\": \"2021-02-11\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"271358741\",\n \"recordId\": \"01484524\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 411199,\n \"type\": \"compensation\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 1.5,\n \"dueDate\": \"2021-12-24\",\n \"creationDate\": \"2021-11-24\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"262088571\",\n \"recordId\": \"06964206\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n }\n]",
"headers": {
"content-type": "application/json; charset=utf-8",
"date": "{{now format='yyyy-MM-dd HH:mm:ssZ'}}",
"strict-transport-security": "max-age=15552000"
"response" : {
"status" : 200,
"body" : "[\n {\n \"feeId\": 434536,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 70,\n \"dueDate\": \"2022-05-08\",\n \"creationDate\": \"2022-04-06\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"5237124059\",\n \"recordId\": \"48724566\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5119382558\",\n \"recordId\": \"52518563\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5324175956\",\n \"recordId\": \"38540335\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 434537,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 70,\n \"dueDate\": \"2022-05-08\",\n \"creationDate\": \"2022-04-06\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"3275348197\",\n \"recordId\": \"23790823\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5218297864\",\n \"recordId\": \"45951685\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 434538,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 120,\n \"dueDate\": \"2022-05-08\",\n \"creationDate\": \"2022-04-06\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"5136106556\",\n \"recordId\": \"53067034\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n },\n {\n \"materialItemNumber\": \"5232011841\",\n \"recordId\": \"54058969\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 306404,\n \"type\": \"fee\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 2.56,\n \"dueDate\": \"2020-04-15\",\n \"creationDate\": \"2019-10-18\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"3839631447\",\n \"recordId\": \"26285283\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 377242,\n \"type\": \"compensation\",\n \"reasonMessage\": \"Erstatning (test)\",\n \"amount\": 1,\n \"dueDate\": \"2021-08-10\",\n \"creationDate\": \"2021-02-11\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"271358741\",\n \"recordId\": \"01484524\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n },\n {\n \"feeId\": 411199,\n \"type\": \"compensation\",\n \"reasonMessage\": \"Gebyr (for sent)\",\n \"amount\": 1.5,\n \"dueDate\": \"2021-12-24\",\n \"creationDate\": \"2021-11-24\",\n \"paidDate\": null,\n \"payableByClient\": true,\n \"materials\": [\n {\n \"materialItemNumber\": \"262088571\",\n \"recordId\": \"06964206\",\n \"periodical\": null,\n \"materialGroup\": {\n \"name\": \"standard\",\n \"description\": \"31 dages lånetid til alm lånere\"\n }\n }\n ]\n }\n]",
"headers" : {
"content-type" : "application/json; charset=utf-8",
"date" : "{{now format='yyyy-MM-dd HH:mm:ssZ'}}",
"strict-transport-security" : "max-age=15552000"
},
"transformers": ["response-template"]
"transformers" : [ "response-template" ]
},
"uuid": "bd783b91-b464-4137-9575-b093008866df",
"persistent": true,
"priority": 5,
"insertionIndex": 13,
"postServeActions": []
}
"uuid" : "bd783b91-b464-4137-9575-b093008866df",
"persistent" : true,
"priority" : 5,
"insertionIndex" : 18,
"postServeActions" : [ ]
}
7 changes: 6 additions & 1 deletion src/apps/fee-list/FeeList.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ export default {
defaultValue: "https://unsplash.com/photos/yjI3ozta2Zk", // Open source image of a fluffy floofer
control: { type: "text" }
},
materialNumberText: {
feeListAlreadyPaidInfoText: {
defaultValue:
"Already paid? It can take up to 72 hours to register the transaction.",
control: { type: "text" }
},
feeListMaterialNumberText: {
defaultValue: "# @materialNumber",
control: { type: "text" }
}
Expand Down
87 changes: 15 additions & 72 deletions src/apps/fee-list/FeeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,22 @@ import FeeDetailsModal from "./modal/fee-details-modal";
import MyPaymentOverviewModal from "./modal/my-payment-overview-modal";
import FeeDetailsContent from "./stackable-fees/fee-details-content";
import modalIdsConf from "../../core/configuration/modal-ids.json";
import {
getFeeObjectByFaustId,
getFeesInRelationToPaymentChangeDate
} from "./utils/helper";
import { getFeeObjectByFaustId } from "./utils/helper";
import ListHeader from "../../components/list-header/list-header";
import EmptyList from "../../components/empty-list/empty-list";

const FeeList: FC = () => {
const t = useText();
const u = useUrls();
const viewFeesAndCompensationRatesUrl = u("viewFeesAndCompensationRatesUrl");

const [feeDetailsModalId, setFeeDetailsModalId] = useState("");
const { open } = useModalButtonHandler();
const { data: fbsFees = [] } = useGetFeesV2<FeeV2[]>();
const [itemsPrePaymentChange, setItemsPrePaymentChange] = useState<
FeeV2[] | null
>(null);
const [totalFeePrePaymentChange, setTotalFeePrePaymentChange] =
useState<number>(0);
const [itemsPostPaymentChange, setItemsPostPaymentChange] = useState<
FeeV2[] | null
>(null);
const [totalFeePostPaymentChange, setTotalFeePostPaymentChange] =
useState<number>(0);
const { data: fbsFees = [] } = useGetFeesV2<FeeV2[]>({
includepaid: false,
includenonpayable: true
});
const [totalFeeAmount, setTotalFeeAmount] = useState<number>(0);
const [feeDetailsData, setFeeDetailsData] = useState<FeeV2[]>();

const openDetailsModalClickEvent = useCallback(
(faustId: string) => {
if (faustId) {
Expand All @@ -51,58 +40,21 @@ const FeeList: FC = () => {
);

useEffect(() => {
if (fbsFees) {
const feesPrePaymentChange = getFeesInRelationToPaymentChangeDate(
fbsFees,
true
).length;
if (feesPrePaymentChange > 0) {
setItemsPrePaymentChange(
getFeesInRelationToPaymentChangeDate(fbsFees, true)
);
}
const feesPostPaymentChange = getFeesInRelationToPaymentChangeDate(
fbsFees,
false
).length;
if (feesPostPaymentChange > 0) {
setItemsPostPaymentChange(
getFeesInRelationToPaymentChangeDate(fbsFees, false)
);
}
}
}, [fbsFees]);

useEffect(() => {
if (totalFeePrePaymentChange > 0) {
return;
}
const totalFee = itemsPrePaymentChange?.reduce(
(accumulator, { amount }) => accumulator + amount,
0
);
if (totalFee) {
setTotalFeePrePaymentChange(totalFee);
}
}, [itemsPrePaymentChange, totalFeePrePaymentChange]);

useEffect(() => {
if (totalFeePostPaymentChange > 0) {
if (totalFeeAmount > 0 || !fbsFees.length) {
return;
}
const totalFee = itemsPostPaymentChange?.reduce(
const totalFee = fbsFees.reduce(
(accumulator, { amount }) => accumulator + amount,
0
);

if (totalFee) {
setTotalFeePostPaymentChange(totalFee);
setTotalFeeAmount(totalFee);
}
}, [itemsPostPaymentChange, totalFeePostPaymentChange]);
}, [fbsFees, totalFeeAmount]);

return (
<>
<div className="fee-list-page">
<div className="fee-list-page" data-cy="fee-list-page">
<h1 data-cy="fee-list-headline" className="text-header-h1 my-32">
{t("feeListHeadlineText")}
</h1>
Expand All @@ -112,7 +64,7 @@ const FeeList: FC = () => {
{t("viewFeesAndCompensationRatesText")}
</Link>
</span>
{!itemsPrePaymentChange && !itemsPostPaymentChange && (
{!fbsFees.length && (
<>
<ListHeader
header={<>{t("unpaidFeesFirstHeadlineText")}</>}
Expand All @@ -125,21 +77,12 @@ const FeeList: FC = () => {
</>
)}
<List
dataCy="fee-list-before"
dataCy="fee-list"
listHeader={t("unpaidFeesFirstHeadlineText")}
openDetailsModalClickEvent={openDetailsModalClickEvent}
fees={itemsPrePaymentChange}
totalText={t("totalText", {
placeholders: { "@total": totalFeePrePaymentChange }
})}
/>
<List
listHeader={t("unpaidFeesSecondHeadlineText")}
dataCy="fee-list-after"
openDetailsModalClickEvent={openDetailsModalClickEvent}
fees={itemsPostPaymentChange}
fees={fbsFees}
totalText={t("totalText", {
placeholders: { "@total": totalFeePostPaymentChange }
placeholders: { "@total": totalFeeAmount.toString() }
})}
/>
</div>
Expand Down
56 changes: 17 additions & 39 deletions src/apps/fee-list/fee-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("Fee list", () => {
it("Fee list basics (physical loans)", () => {
// 2. System shows:
// 2.a. Headline "Fees & Replacement costs"
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.getBySel("fee-list-headline")
.should("exist")
.should("have.text", "Fees & Replacement costs");
Expand All @@ -130,19 +130,22 @@ describe("Fee list", () => {
cy.getBySel("list-header").should("contain.text", "Unsettled debt");

// 2.d link “See our fees and replacement costs”
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find("[data-cy='fee-list-body']")
.find(".link-tag")
.should("exist")
.should("not.have.attr", "href", "")
.should("have.text", "See our fees and replacement costs");

// 3.b list of intermediates
cy.get(".fee-list-page").find(".list-reservation").eq(0).should("exist");
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist");

// 3.c metadata
// 3.c.a material type
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -154,7 +157,7 @@ describe("Fee list", () => {
.should("have.text", "Dummy bog");

// 3.c.b title
cy.get("[data-cy='fee-list-before']")
cy.getBySel("fee-list")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -163,7 +166,7 @@ describe("Fee list", () => {
.should("have.text", "Dummy Some Title");

// 3.c.c author
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -178,7 +181,7 @@ describe("Fee list", () => {
);

// 3. d fees charged dd.mm.yyyy
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -187,10 +190,10 @@ describe("Fee list", () => {
.find(".list-reservation__deadline")
.find(".text-small-caption")
.should("exist")
.should("have.text", "Fees charged 18. 10. 2019");
.should("have.text", "Fees charged 06. 04. 2022");

// 3. e Label: reason
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
Expand All @@ -202,51 +205,26 @@ describe("Fee list", () => {
.should("have.text", "Gebyr (for sent)");

// 3. e Label: fee amount
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(0)
.should("exist")
.find(".list-reservation__status")
.find(".list-reservation__fee")
.find(".text-body-medium-regular")
.should("exist")
.should("have.text", "Fee 2.56,-");

// 4. a List after date
// Title
cy.get("[data-cy='fee-list-after']")
.find(".list-reservation")
.eq(0)
.should("exist")
.find(".text-header-h4")
.should("exist")
.should("have.text", "Dummy Some Title");

// Author && year
cy.get(".fee-list-page")
.find(".list-reservation")
.eq(1)
.should("exist")
.find(".list-reservation__material")
.find(".list-reservation__information")
.find(".list-reservation__about")
.find(".text-small-caption")
.should("exist")
.should(
"have.text",
"By Dummy Jens Jensen and Dummy Some Corporation (2006)"
);
.should("have.text", "Fee 70,-");

// 4.b +x other materials
cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(1)
.should("exist")
.getBySel("stack-size")
.should("exist")
.should("have.text", "+ 2 other materials");

cy.get(".fee-list-page")
cy.getBySel("fee-list-page")
.find(".list-reservation")
.eq(1)
.should("exist")
Expand All @@ -258,7 +236,7 @@ describe("Fee list", () => {
.find("div")
.find(".modal-loan__title")
.should("exist")
.should("have.text", "Turned in 6. April 2022");
.should("have.text", "Turned in 18. October 2019");

// book list
cy.get(".modal-loan__list-materials")
Expand Down
Loading
Loading